]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Working on settemp command
authorSamual <samual@xonotic.org>
Fri, 11 Nov 2011 08:35:56 +0000 (03:35 -0500)
committerSamual <samual@xonotic.org>
Fri, 11 Nov 2011 08:35:56 +0000 (03:35 -0500)
qcsrc/client/gamecommand.qc

index 2d66d422808b475044b34cbb370e2db084796183..0ee13f06f2511d5c1dd1170146aa4cb6dfb24f36 100644 (file)
@@ -73,25 +73,36 @@ entity debug_shotorg;
 //  Misc. Supporting Functions
 // ============================
 
-void cvar_clientsettemp(string cv, string val)
+float cvar_clientsettemp(string cvar, string value)
 {
        entity e;
+       
        for(e = world; (e = find(e, classname, "saved_cvar_value")); )
-               if(e.netname == cv)
+               if(e.netname == cvar)
                        goto saved;
+                       
+       // creating a new entity to keep track of this cvar
        e = spawn();
        e.classname = "saved_cvar_value";
-       e.netname = strzone(cv);
-       e.message = strzone(cvar_string(cv));
+       e.netname = strzone(cvar);
+       e.message = strzone(cvar_string(cvar));
+       return TRUE;
+       
+       // an entity for this cvar already exists, update the value
        :saved
-       cvar_set(cv, val);
+       cvar_set(cvar, value);
+       return FALSE;
 }
 
-void cvar_clientsettemp_restore()
+float cvar_clientsettemp_restore()
 {
+       float i;
        entity e;
+       
        for(e = world; (e = find(e, classname, "saved_cvar_value")); )
-                       cvar_set(e.netname, e.message);
+               { cvar_set(e.netname, e.message); ++i } 
+               
+       return i;
 }
 void DrawDebugModel()
 {
@@ -194,14 +205,14 @@ void GameCommand_hud(float request, float argc) // TODO: Add aliases in commands
                        print("\nUsage:^3 cl_cmd hud action [configname | radartoggle]\n");
                        print("  Where 'action' is the command to complete,\n");
                        print("  'configname' is the name to save to for \"save\" action,\n");
-                       print("  and 'radartoggle' is what to set hud_panel_radar_maximized to.\n");
+                       print("  and 'radartoggle' is to control hud_panel_radar_maximized for \"radar\" action.\n");
                        print("  Full list of commands here: \"configure, save, radar.\"\n");
                        return;
                }
        }
 }
 
-void GameCommand_sendcvar(float request, float argc) // wtf? why?
+void GameCommand_sendcvar(float request, float argc)
 {
        switch(request)
        {
@@ -232,6 +243,26 @@ void GameCommand_sendcvar(float request, float argc) // wtf? why?
        }
 }
 
+void GameCommand_settemp(float request, float argc)
+{
+       switch(request)
+       {
+               case GC_REQUEST_COMMAND:
+               {
+                       
+                       return; 
+               }
+                       
+               default:
+               case GC_REQUEST_USAGE:
+               {
+                       print("\nUsage:^3 cl_cmd \n");
+                       print("  No arguments required.\n");
+                       return;
+               }
+       }
+}
+
 /* use this when creating a new command, making sure to place it in alphabetical order.
 void GameCommand_(float request)
 {
@@ -264,6 +295,7 @@ void GameCommand_(float request)
        CLIENT_COMMAND("blurtest", GameCommand_blurtest(request), "Feature for testing blur postprocessing") \
        CLIENT_COMMAND("hud", GameCommand_hud(request, arguments), "Commands regarding/controlling the HUD system") \
        CLIENT_COMMAND("sendcvar", GameCommand_sendcvar(request, arguments), "Send a cvar to the server (like weaponpriority)") \
+       CLIENT_COMMAND("settemp", GameCommand_settemp(request, arguments), "Temporarily set a value to a cvar which will be cleared next match") \
        /* nothing */
        
 void GameCommand_macro_help()