]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix some bugs with settemp and scoreboard_columns_set
authorSamual <samual@xonotic.org>
Fri, 16 Dec 2011 20:55:56 +0000 (15:55 -0500)
committerSamual <samual@xonotic.org>
Fri, 16 Dec 2011 20:55:56 +0000 (15:55 -0500)
qcsrc/client/command/cl_cmd.qc
qcsrc/client/scoreboard.qc
qcsrc/server/command/cmd.qc
qcsrc/server/command/sv_cmd.qc

index 519372efa3c8c9bf54f30c5e71cff418dd0d054d..800724a771dc16075048dd610d5c9b772fab5c4d 100644 (file)
@@ -5,23 +5,33 @@
 
 float cvar_clientsettemp(string tmp_cvar, string value)
 {
+       float created_saved_value;
        entity e;
        
+       if not(tmp_cvar || value)
+       {
+               dprint("Error: Invalid usage of cvar_clientsettemp(string, string); !\n");
+               return FALSE;
+       }
+       
        for(e = world; (e = find(e, classname, "saved_cvar_value")); )
                if(e.netname == tmp_cvar)
-                       goto saved;
+                       goto saved; // skip creation
                        
        // creating a new entity to keep track of this cvar
        e = spawn();
        e.classname = "saved_cvar_value";
        e.netname = strzone(tmp_cvar);
        e.message = strzone(cvar_string(tmp_cvar));
-       return TRUE;
+       created_saved_value = TRUE;
        
-       // an entity for this cvar already exists, update the value
+       // an entity for this cvar already exists
        :saved
+       
+       // update the cvar to the value given
        cvar_set(tmp_cvar, value);
-       return FALSE;
+       
+       return created_saved_value;
 }
 
 float cvar_clientsettemp_restore()
@@ -288,7 +298,7 @@ void GameCommand_settemp(float request, float argc)
        {
                case CMD_REQUEST_COMMAND:
                {
-                       if((argv(1) == "restore") && (argc == 3))
+                       if((argv(1) == "restore") && (argc == 2))
                        {
                                float i = cvar_clientsettemp_restore();
                                
@@ -296,19 +306,22 @@ void GameCommand_settemp(float request, float argc)
                                        dprint("Restored ", ftos(i), " temporary cvar settings to their original values.\n");
                                else
                                        dprint("Nothing to restore.\n");
+                               
+                               return;
                        }
-                       else
+                       else if(argc >= 3)
                        {
                                if(cvar_clientsettemp(argv(1), argv(2)))
                                        dprint("Creating new settemp tracker for ", argv(1), " and setting it to \"", argv(2), "\" temporarily.\n"); 
                                else
                                        dprint("Already had a tracker for ", argv(1), ", updating it to \"", argv(2), "\".\n");
+                       
+                               return;
                        }
-                               
-                       return; 
                }
                        
                default:
+                       print("Incorrect parameters for ^2settemp^7\n");
                case CMD_REQUEST_USAGE:
                {
                        print("\nUsage:^3 cl_cmd settemp <cvar> | [restore]\n");
index 3124b4b9b4d68056f968c4ca87f15c993edf8c99..7d452713be745e835f1b5e159842f3569c0495da 100644 (file)
@@ -308,17 +308,17 @@ void Cmd_HUD_SetFields(float argc)
        float missing;
 
        // TODO: re enable with gametype dependant cvars?
-       if(argc < 2) // no arguments provided
+       if(argc < 3) // no arguments provided
                argc = tokenizebyseparator(strcat("x ", autocvar_scoreboard_columns), " ");
 
-       if(argc < 2)
+       if(argc < 3)
                argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
 
-       if(argc == 2)
+       if(argc == 3)
        {
-               if(argv(1) == "default")
+               if(argv(2) == "default")
                        argc = tokenizebyseparator(strcat("x ", HUD_DefaultColumnLayout()), " ");
-               else if(argv(1) == "all")
+               else if(argv(2) == "all")
                {
                        string s;
                        s = "ping pl color name |";
@@ -341,10 +341,10 @@ void Cmd_HUD_SetFields(float argc)
 
        hud_fontsize = HUD_GetFontsize("hud_fontsize"); 
 
-       for(i = 0; i < argc - 1; ++i)
+       for(i = 0; i < argc - 2; ++i)
        {
                float nocomplain;
-               str = argv(i+1);
+               str = argv(i+2);
 
                nocomplain = FALSE;
                if(substring(str, 0, 1) == "?")
index c40f0bf713022cb01389fcc2e0c5b1bdb752b181..c5f10826b60bf6671360196f68354954af2c50c9 100644 (file)
@@ -610,6 +610,11 @@ void SV_ParseClientCommand(string command)
 {
        float argc = tokenize_console(command);
        
+       // Guide for working with argc arguments by example:
+       // argc:   1    - 2      - 3     - 4
+       // argv:   0    - 1      - 2     - 3 
+       // cmd     vote - master - login - password
+       
        // for floodcheck
        switch(strtolower(argv(0)))
        {
index 3e18ff1d62bb452473830e70f7f023bd84c24118..52de05f4066c143bd3735260088bf149ae46f585 100644 (file)
@@ -1832,6 +1832,11 @@ float GameCommand_macro_usage(float argc)
 void GameCommand(string command)
 {
        float argc = tokenize_console(command);
+       
+       // Guide for working with argc arguments by example:
+       // argc:   1    - 2      - 3     - 4
+       // argv:   0    - 1      - 2     - 3 
+       // cmd     vote - master - login - password
 
        if(strtolower(argv(0)) == "help") 
        {