From: Samual Date: Fri, 11 Nov 2011 08:35:56 +0000 (-0500) Subject: Working on settemp command X-Git-Tag: xonotic-v0.6.0~188^2~28^2~217 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5af0163f335fdebf367a330bfb0f6fbb99acf761;p=xonotic%2Fxonotic-data.pk3dir.git Working on settemp command --- diff --git a/qcsrc/client/gamecommand.qc b/qcsrc/client/gamecommand.qc index 2d66d4228..0ee13f06f 100644 --- a/qcsrc/client/gamecommand.qc +++ b/qcsrc/client/gamecommand.qc @@ -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()