// ==============================================
// CSQC client commands code, written by Samual
-// Last updated: November 8th, 2011
+// Last updated: November 26th, 2011
// ==============================================
/*
if(cmd == "mv_download") {
Cmd_MapVote_MapDownload(argc);
}
- else if(cmd == "settemp") {
- cvar_clientsettemp(argv(1), argv(2));
- }
else if(cmd == "scoreboard_columns_set") {
Cmd_HUD_SetFields(argc);
}
// Misc. Supporting Functions
// ============================
-void cvar_clientsettemp(string cv, string val)
+float cvar_clientsettemp(string tmp_cvar, string value)
{
entity e;
+
for(e = world; (e = find(e, classname, "saved_cvar_value")); )
- if(e.netname == cv)
+ if(e.netname == tmp_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(tmp_cvar);
+ e.message = strzone(cvar_string(tmp_cvar));
+ return TRUE;
+
+ // an entity for this cvar already exists, update the value
:saved
- cvar_set(cv, val);
+ cvar_set(tmp_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()
{
if(time - floor(time) > 0.5)
return;
}
+
+ case "scoreboard_columns_set":
+ {
+ Cmd_HUD_SetFields(argc); // todo update this function
+
+ return;
+ }
+
+ case "scoreboard_columns_help":
+ {
+ Cmd_HUD_Help(argc); // todo update this function
+
+ return;
+ }
}
return;
}
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)
{
}
}
+void GameCommand_settemp(float request, float argc)
+{
+ switch(request)
+ {
+ case GC_REQUEST_COMMAND:
+ {
+ if((argv(1) == "restore") && (argc == 3))
+ {
+ float i = cvar_clientsettemp_restore();
+
+ if(i)
+ print("Restored ", ftos(i), " temporary cvar settings to their original values.\n");
+ else
+ print("Nothing to restore.\n");
+ }
+ else
+ {
+ if(cvar_clientsettemp(argv(1), argv(2)))
+ print("Creating new settemp tracker for ", argv(1), " and setting it to \"", argv(2), "\" temporarily.\n");
+ else
+ print("Already had a tracker for ", argv(1), ", updating it to \"", argv(2), "\".\n");
+ }
+
+ return;
+ }
+
+ default:
+ case GC_REQUEST_USAGE:
+ {
+ print("\nUsage:^3 cl_cmd settemp <cvar> | [restore]\n");
+ print(" Where 'cvar' is the cvar plus arguments to send to the server,\n");
+ print(" or 'restore' allows you to restore all of the original temporary cvar values.\n");
+ return;
+ }
+ }
+}
+
/* use this when creating a new command, making sure to place it in alphabetical order.
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 is restored by command or end of each match") \
/* nothing */
void GameCommand_macro_help()
}
// nothing above caught the command, must be invalid
- print("Invalid command", (command ? strcat(" '", command, "'") : ""), ". For a list of supported commands, try cl_cmd help.\n");
+ print("Unknown client command", ((command != "") ? strcat(" \"", command, "\"") : ""), ". For a list of supported commands, try cl_cmd help.\n");
return;
}
{
// first init normal commands
#define CONSOLE_COMMAND(name,execution) \
- { registercmd(name); }
+ { registercommand(name); }
CONSOLE_COMMANDS_NORMAL
#undef CONSOLE_COMMAND
{
#endif
#define CONSOLE_COMMAND(name,execution) \
- { registercmd(name); }
+ { registercommand(name); }
CONSOLE_COMMANDS_MOVEMENT
#undef CONSOLE_COMMAND
// ======================================================
// Main Function Called By Engine (registered commands)
// ======================================================
-// Used to parse commands in the console that have been registered with the "registercmd" function
+// Used to parse commands in the console that have been registered with the "registercommand" function
float CSQC_ConsoleCommand(string command)
{