// ==============================================
// CSQC client commands code, written by Samual
-// Last updated: December 27th, 2011
+// Last updated: December 28th, 2011
// ==============================================
-/*
-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; // 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));
- created_saved_value = TRUE;
-
- // an entity for this cvar already exists
- :saved
-
- // update the cvar to the value given
- cvar_set(tmp_cvar, value);
-
- return created_saved_value;
-}
-
-float cvar_clientsettemp_restore()
-{
- float i;
- entity e;
-
- for(e = world; (e = find(e, classname, "saved_cvar_value")); )
- { cvar_set(e.netname, e.message); ++i; }
-
- return i;
-}*/
-
void DrawDebugModel()
{
if(time - floor(time) > 0.5)
}
}
-void LocalCommand_settemp(float request, float argc)
-{
- switch(request)
- {
- case CMD_REQUEST_COMMAND:
- {
- if(argc >= 3)
- {
- if(cvar_settemp(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;
- }
- }
-
- default:
- print("Incorrect parameters for ^2settemp^7\n");
- case CMD_REQUEST_USAGE:
- {
- print("\nUsage:^3 cl_cmd settemp \"cvar\" \"arguments\"\n");
- print(" Where 'cvar' is the cvar you want to temporarily set with 'arguments'.\n");
- return;
- }
- }
-}
-
-void LocalCommand_settemp_restore(float request, float argc)
-{
- switch(request)
- {
- case CMD_REQUEST_COMMAND:
- {
- float i = cvar_settemp_restore();
-
- if(i)
- dprint("Restored ", ftos(i), " temporary cvar settings to their original values.\n");
- else
- dprint("Nothing to restore.\n");
-
- return;
- }
-
- default:
- case CMD_REQUEST_USAGE:
- {
- print("\nUsage:^3 cl_cmd settemp_restore\n");
- print(" No arguments required.\n");
- return;
- }
- }
-}
-
/* use this when creating a new command, making sure to place it in alphabetical order... also,
** ADD ALL NEW COMMANDS TO commands.cfg WITH PROPER ALIASES IN THE SAME FASHION!
void LocalCommand_(float request)
CLIENT_COMMAND("localprint", LocalCommand_localprint(request, arguments), "Create your own centerprint sent to yourself") \
CLIENT_COMMAND("mv_download", LocalCommand_mv_download(request, arguments), "Retrieve mapshot picture from the server") \
CLIENT_COMMAND("sendcvar", LocalCommand_sendcvar(request, arguments), "Send a cvar to the server (like weaponpriority)") \
- CLIENT_COMMAND("settemp", LocalCommand_settemp(request, arguments), "Temporarily set a value to a cvar which is restored later") \
- CLIENT_COMMAND("settemp_restore", LocalCommand_settemp_restore(request, arguments), "Restore all cvars set by settemp command") \
/* nothing */
void LocalCommand_macro_help()
{
if(argc == 1)
{
- print("\nUsage:^3 cl_cmd COMMAND...^7, where possible commands are:\n");
+ print("\nClient console commands:\n");
LocalCommand_macro_help();
- GenericCommand("help");
- print("For help about specific commands, type cl_cmd help COMMAND\n");
+
+ print("\nGeneric commands shared by all programs:\n");
+ GenericCommand_macro_help();
+
+ print("\nUsage:^3 cl_cmd COMMAND...^7, where possible commands are listed above.\n");
+ print("For help about a specific command, type cl_cmd help COMMAND\n");
+
return;
}
- else if(LocalCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
+ else if(GenericCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
+ {
+ return;
+ }
+ else if(LocalCommand_macro_usage(argc)) // now try for normal commands too
{
return;
}
// argv: 0 - 1 - 2 - 3
// cmd vote - master - login - password
- if(strtolower(argv(0)) == "help")
- {
- if(argc == 1)
- {
- GenericCommand_macro_help();
- return TRUE;
- }
- else if(GenericCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
- {
- return TRUE;
- }
- }
- else if(GenericCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
+ if(GenericCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
{
return TRUE; // handled by one of the above GenericCommand_* functions
}
-float GenericCommand(string command); // returns true if handled, false if not. Note: It tokenizes its input, so be careful!
+// =========================================================
+// Declarations for common command code, written by Samual
+// Last updated: December 28th, 2011
+// =========================================================
-// returns command prefix specific for each program it is compiled in
+// Used by other game command systems for common commands,
+// and it returns true if handled, false if not.
+// Note: It tokenizes its input, so be careful!
+float GenericCommand(string command);
+
+// Returns command prefix specific for whatever program it is compiled in
string GetProgramCommandPrefix(void);
\ No newline at end of file
-// =========================================================
-// Markup chat characters command code, reworked by Samual
+// ==========================================================
+// Declarations for markup command code, reworked by Samual
// Last updated: December 28th, 2011
-// =========================================================
+// ==========================================================
#define NUM_MARKUPS 41
float markup_init;
+// ========================================
+// RPN command code, written by divVerent
+// Last updated: December 28th, 2011
+// ========================================
+
string rpn_pop()
{
if(rpn_sp > 0) {
+// =========================================================
+// Declarations for RPN command code, written by divVerent
+// Last updated: December 28th, 2011
+// =========================================================
+
#define MAX_RPN_STACK 16
float rpn_db;
float rpn_error;
// =========================================================
// Server side networked commands code, reworked by Samual
-// Last updated: December 26th, 2011
+// Last updated: December 28th, 2011
// =========================================================
float SV_ParseClientCommand_floodcheck()
// =====================================
// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
-// Common commands have double indentation to separate them a bit.
#define CLIENT_COMMANDS(request,arguments,command) \
CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(request, arguments), "Whether or not to switch automatically when getting a better weapon") \
CLIENT_COMMAND("checkfail", ClientCommand_checkfail(request, command), "Report if a client-side check failed") \
CLIENT_COMMAND("clientversion", ClientCommand_clientversion(request, arguments), "Release version of the game") \
- CLIENT_COMMAND("cvar_changes", CommonCommand_cvar_changes(request, self), "Prints a list of all changed server cvars") \
- CLIENT_COMMAND("cvar_purechanges", CommonCommand_cvar_purechanges(request, self), "Prints a list of all changed gameplay cvars") \
CLIENT_COMMAND("getmapvotepic", ClientCommand_getmapvotepic(request, arguments), "Retrieve mapshot picture from the server") \
- CLIENT_COMMAND("info", CommonCommand_info(request, self, arguments), "Request for unique server information set up by admin") \
CLIENT_COMMAND("join", ClientCommand_join(request), "Become a player in the game") \
- CLIENT_COMMAND("ladder", CommonCommand_ladder(request, self), "Get information about top players if supported") \
- CLIENT_COMMAND("lsmaps", CommonCommand_lsmaps(request, self), "List maps which can be used with the current game mode") \
- CLIENT_COMMAND("lsnewmaps", CommonCommand_lsnewmaps(request, self), "List maps which have no records or are seemingly unplayed yet") \
- CLIENT_COMMAND("maplist", CommonCommand_maplist(request, self), "Display full server maplist reply") \
- CLIENT_COMMAND("rankings", CommonCommand_rankings(request, self), "Print information about rankings") \
CLIENT_COMMAND("ready", ClientCommand_ready(request), "Qualify as ready to end warmup stage (or restart server if allowed)") \
- CLIENT_COMMAND("records", CommonCommand_records(request, self), "List top 10 records for the current map") \
CLIENT_COMMAND("reportcvar", ClientCommand_reportcvar(request, arguments, command), "Old system for sending a client cvar to the server") \
CLIENT_COMMAND("say", ClientCommand_say(request, arguments, command), "Print a message to chat to all players") \
CLIENT_COMMAND("say_team", ClientCommand_say_team(request, arguments, command), "Print a message to chat to all team mates") \
CLIENT_COMMAND("sentcvar", ClientCommand_sentcvar(request, arguments, command), "New system for sending a client cvar to the server") \
CLIENT_COMMAND("spectate", ClientCommand_spectate(request), "Become an observer") \
CLIENT_COMMAND("suggestmap", ClientCommand_suggestmap(request, arguments), "Suggest a map to the mapvote at match end") \
- CLIENT_COMMAND("teamstatus", CommonCommand_teamstatus(request, self), "Show information about player and team scores") \
CLIENT_COMMAND("tell", ClientCommand_tell(request, arguments, command), "Send a message directly to a player") \
- CLIENT_COMMAND("time", CommonCommand_time(request, self), "Print different formats/readouts of time") \
- CLIENT_COMMAND("timein", CommonCommand_timein(request, self), "Resume the game from being paused with a timeout") \
- CLIENT_COMMAND("timeout", CommonCommand_timeout(request, self), "Call a timeout which pauses the game for certain amount of time unless unpaused") \
CLIENT_COMMAND("voice", ClientCommand_voice(request, arguments, command), "Send voice message via sound") \
- CLIENT_COMMAND("vote", VoteCommand(request, self, arguments, command), "Request an action to be voted upon by players") \
- CLIENT_COMMAND("who", CommonCommand_who(request, self, arguments), "Display detailed client information about all players") \
/* nothing */
void ClientCommand_macro_help()
return FALSE;
}
-float ClientCommand_macro_usage(float argc, string command)
+float ClientCommand_macro_usage(float argc)
{
#define CLIENT_COMMAND(name,function,description) \
{ if(name == strtolower(argv(1))) { function; return TRUE; } }
- CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc, command)
+ CLIENT_COMMANDS(CMD_REQUEST_USAGE, argc, "")
#undef CLIENT_COMMAND
return FALSE;
return print("^1ERROR: ^7ANTISPAM CAUGHT: ", command, ".\n"); // "FALSE": not allowed to continue, halt
}
- /* NOTE: totally disabled for now for bandwidth/security reasons, however the functionality and descriptions are there if we ever want it.
+ /* NOTE: totally disabled for now for bandwidth/security reasons, however the functionality and descriptions are there if we ever want it. */
if(argv(0) == "help")
{
if(argc == 1)
{
- sprint(self, "\nUsage:^3 cmd COMMAND...^7, where possible commands are:\n");
- ClientCommand_macro_help;
- sprint(self, "For help about specific commands, type cmd help COMMAND\n");
+ print("\nClient networked commands:\n");
+ ClientCommand_macro_help();
+
+ print("\nCommon networked commands:\n");
+ CommonCommand_macro_help();
+
+ sprint(self, "\nUsage:^3 cmd COMMAND...^7, where possible commands are listed above.\n");
+ sprint(self, "For help about a specific command, type cmd help COMMAND\n");
return;
}
- else if(ClientCommand_macro_usage(argc, command)) // Instead of trying to call a command, we're going to see detailed information about it
+ else if(CommonCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
+ {
+ return;
+ }
+ else if(ClientCommand_macro_usage(argc)) // same, but for normal commands now
{
return;
}
}
- else*/ if(MUTATOR_CALLHOOK(SV_ParseClientCommand))
+ else if(MUTATOR_CALLHOOK(SV_ParseClientCommand))
{
return; // handled by a mutator
}
{
return; // handled by server/cheats.qc
}
+ else if(CommonCommand_macro_command(argc, command))
+ {
+ return; // handled by server/command/common.qc
+ }
else if(ClientCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
{
return; // handled by one of the above ClientCommand_* functions
}
}
}
-*/
\ No newline at end of file
+*/
+
+
+// ==================================
+// Macro system for common commands
+// ==================================
+
+// Do not hard code aliases for these, instead create them in commands.cfg... also: keep in alphabetical order, please ;)
+#define COMMON_COMMANDS(request,arguments,command) \
+ COMMON_COMMAND("cvar_changes", CommonCommand_cvar_changes(request, world), "Prints a list of all changed server cvars") \
+ COMMON_COMMAND("cvar_purechanges", CommonCommand_cvar_purechanges(request, world), "Prints a list of all changed gameplay cvars") \
+ COMMON_COMMAND("info", CommonCommand_info(request, world, arguments), "Request for unique server information set up by admin") \
+ COMMON_COMMAND("ladder", CommonCommand_ladder(request, world), "Get information about top players if supported") \
+ COMMON_COMMAND("lsmaps", CommonCommand_lsmaps(request, world), "List maps which can be used with the current game mode") \
+ COMMON_COMMAND("lsnewmaps", CommonCommand_lsnewmaps(request, world), "List maps which have no records or are seemingly unplayed yet") \
+ COMMON_COMMAND("maplist", CommonCommand_maplist(request, world), "Display full server maplist reply") \
+ COMMON_COMMAND("rankings", CommonCommand_rankings(request, world), "Print information about rankings") \
+ COMMON_COMMAND("records", CommonCommand_records(request, world), "List top 10 records for the current map") \
+ COMMON_COMMAND("teamstatus", CommonCommand_teamstatus(request, world), "Show information about player and team scores") \
+ COMMON_COMMAND("time", CommonCommand_time(request, world), "Print different formats/readouts of time") \
+ COMMON_COMMAND("timein", CommonCommand_timein(request, world), "Resume the game from being paused with a timeout") \
+ COMMON_COMMAND("timeout", CommonCommand_timeout(request, world), "Call a timeout which pauses the game for certain amount of time unless unpaused") \
+ COMMON_COMMAND("vote", VoteCommand(request, world, arguments, command), "Request an action to be voted upon by players") \
+ COMMON_COMMAND("who", CommonCommand_who(request, world, arguments), "Display detailed client information about all players") \
+ /* nothing */
+
+void CommonCommand_macro_help()
+{
+ #define COMMON_COMMAND(name,function,description) \
+ { print(" ^2", name, "^7: ", description, "\n"); }
+
+ COMMON_COMMANDS(0, 0, "")
+ #undef COMMON_COMMAND
+
+ return;
+}
+
+float CommonCommand_macro_command(float argc, string command)
+{
+ #define COMMON_COMMAND(name,function,description) \
+ { if(name == strtolower(argv(0))) { function; return TRUE; } }
+
+ COMMON_COMMANDS(CMD_REQUEST_COMMAND, argc, command)
+ #undef COMMON_COMMAND
+
+ return FALSE;
+}
+
+float CommonCommand_macro_usage(float argc)
+{
+ #define COMMON_COMMAND(name,function,description) \
+ { if(name == strtolower(argv(1))) { function; return TRUE; } }
+
+ COMMON_COMMANDS(CMD_REQUEST_USAGE, argc, "")
+ #undef COMMON_COMMAND
+
+ return FALSE;
+}
// =====================================================
// Server side game commands code, reworked by Samual
-// Last updated: December 25th, 2011
+// Last updated: December 28th, 2011
// =====================================================
// used by GameCommand_make_mapinfo()
cvar_set("timelimit", ftos(new / 60));
}
-// used by GameCommand_modelbug() // Samual: is this even needed?
-float g_clientmodel_genericsendentity (entity to, float sf);
-void modelbug_make_svqc();
-void modelbug_make_csqc()
-{
- Net_LinkEntity(self, TRUE, 0, g_clientmodel_genericsendentity);
- self.think = modelbug_make_svqc;
- self.nextthink = time + 1;
- setorigin(self, self.origin - '0 0 8');
-}
-void modelbug_make_svqc()
-{
- self.SendEntity = func_null;
- self.think = modelbug_make_csqc;
- self.nextthink = time + 1;
- setorigin(self, self.origin + '0 0 8');
-}
-void modelbug()
-{
- entity e;
- e = spawn();
- setorigin(e, nextent(world).origin);
- precache_model("models_portal.md3");
- setmodel(e, "models/portal.md3");
- e.think = modelbug_make_svqc;
- e.nextthink = time + 1;
-}
-
// =======================
// Command Sub-Functions
}
}
-void GameCommand_modelbug(float request) // legacy
-{
- switch(request)
- {
- case CMD_REQUEST_COMMAND:
- {
- modelbug();
- return;
- }
-
- default:
- case CMD_REQUEST_USAGE:
- {
- print("\nUsage:^3 sv_cmd modelbug\n");
- print(" No arguments required.\n");
- return;
- }
- }
-}
-
void GameCommand_moveplayer(float request, float argc)
{
switch(request)
}
}
-void GameCommand_onslaught_updatelinks(float request) // legacy // should this be here? Perhaps some mutatorhook call instead....
-{
- switch(request)
- {
- case CMD_REQUEST_COMMAND:
- {
- onslaught_updatelinks();
- print("ONS links updated\n");
- return;
- }
-
- default:
- case CMD_REQUEST_USAGE:
- {
- print("\nUsage:^3 sv_cmd onslaught_updatelinks\n");
- print(" No arguments required.\n");
- return;
- }
- }
-}
-
void GameCommand_playerdemo(float request, float argc) // mostly legacy
{
switch(request)
SERVER_COMMAND("bbox", GameCommand_bbox(request), "Print detailed information about world size") \
SERVER_COMMAND("bot_cmd", GameCommand_bot_cmd(request, arguments), "Control and send commands to bots") \
SERVER_COMMAND("cointoss", GameCommand_cointoss(request, arguments), "Flip a virtual coin and give random result") \
- SERVER_COMMAND("cvar_changes", CommonCommand_cvar_changes(request, world), "Prints a list of all changed server cvars") \
- SERVER_COMMAND("cvar_purechanges", CommonCommand_cvar_purechanges(request, world), "Prints a list of all changed gameplay cvars") \
SERVER_COMMAND("database", GameCommand_database(request, arguments), "Extra controls of the serverprogs database") \
SERVER_COMMAND("defer_clear", GameCommand_defer_clear(request, arguments), "Clear all queued defer commands for a specific client") \
SERVER_COMMAND("defer_clear_all", GameCommand_defer_clear_all(request), "Clear all queued defer commands for all clients") \
SERVER_COMMAND("gametype", GameCommand_gametype(request, arguments), "Simple command to change the active gametype") \
SERVER_COMMAND("gettaginfo", GameCommand_gettaginfo(request, arguments), "Get specific information about a weapon model") \
SERVER_COMMAND("gotomap", GameCommand_gotomap(request, arguments), "Simple command to switch to another map") \
- SERVER_COMMAND("info", CommonCommand_info(request, world, arguments), "Request for unique server information set up by admin") \
- SERVER_COMMAND("ladder", CommonCommand_ladder(request, world), "Get information about top players if supported") \
SERVER_COMMAND("lockteams", GameCommand_lockteams(request), "Disable the ability for players to switch or enter teams") \
- SERVER_COMMAND("lsmaps", CommonCommand_lsmaps(request, world), "List maps which can be used with the current game mode") \
- SERVER_COMMAND("lsnewmaps", CommonCommand_lsnewmaps(request, world), "List maps which have no records or are seemingly unplayed yet") \
SERVER_COMMAND("make_mapinfo", GameCommand_make_mapinfo(request), "Automatically rebuild mapinfo files") \
- SERVER_COMMAND("maplist", CommonCommand_maplist(request, world), "Display full server maplist reply") \
- SERVER_COMMAND("modelbug", GameCommand_modelbug(request), "Debugging tool for developers with weapon models") \
SERVER_COMMAND("moveplayer", GameCommand_moveplayer(request, arguments), "Change the team/status of a player") \
SERVER_COMMAND("nospectators", GameCommand_nospectators(request), "Automatically remove spectators from a match") \
- SERVER_COMMAND("onslaught_updatelinks", GameCommand_onslaught_updatelinks(request), "Refresh link status for onslaught") \
SERVER_COMMAND("playerdemo", GameCommand_playerdemo(request, arguments), "Control the ability to save demos of players") \
SERVER_COMMAND("printstats", GameCommand_printstats(request), "Dump eventlog player stats and other score information") \
SERVER_COMMAND("radarmap", GameCommand_radarmap(request, arguments), "Generate a radar image of the map") \
- SERVER_COMMAND("rankings", CommonCommand_rankings(request, world), "Print information about rankings") \
- SERVER_COMMAND("records", CommonCommand_records(request, world), "List top 10 records for the current map") \
SERVER_COMMAND("reducematchtime", GameCommand_reducematchtime(request), "Decrease the timelimit value incrementally") \
SERVER_COMMAND("setbots", GameCommand_setbots(request, arguments), "Adjust how many bots are in the match") \
SERVER_COMMAND("shuffleteams", GameCommand_shuffleteams(request), "Randomly move players to different teams") \
SERVER_COMMAND("stuffto", GameCommand_stuffto(request, arguments), "Send a command to be executed on a client") \
- SERVER_COMMAND("teamstatus", CommonCommand_teamstatus(request, world), "Show information about player and team scores") \
- SERVER_COMMAND("time", CommonCommand_time(request, world), "Print different formats/readouts of time") \
- SERVER_COMMAND("timein", CommonCommand_timein(request, world), "Resume the game from being paused with a timeout") \
- SERVER_COMMAND("timeout", CommonCommand_timeout(request, world), "Call a timeout which pauses the game for certain amount of time unless unpaused") \
SERVER_COMMAND("trace", GameCommand_trace(request, arguments), "Various debugging tools with tracing") \
SERVER_COMMAND("unlockteams", GameCommand_unlockteams(request), "Enable the ability for players to switch or enter teams") \
SERVER_COMMAND("warp", GameCommand_warp(request, arguments), "Choose different level in campaign") \
- SERVER_COMMAND("vote", VoteCommand(request, world, arguments, command), "Server side control of voting") \
- SERVER_COMMAND("who", CommonCommand_who(request, world, arguments), "Display detailed client information about all players") \
/* nothing */
void GameCommand_macro_help()
{
if(argc == 1)
{
- print("\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are:\n");
+ print("\nServer console commands:\n");
GameCommand_macro_help();
+ print("\nBanning commands:\n");
GameCommand_Ban("help");
- GenericCommand("help");
- print("For help about specific commands, type sv_cmd help COMMAND\n");
+
+ print("\nCommon networked commands:\n");
+ CommonCommand_macro_help();
+
+ print("\nGeneric commands shared by all programs:\n");
+ GenericCommand_macro_help();
+
+ print("\nUsage:^3 sv_cmd COMMAND...^7, where possible commands are listed above.\n");
+ print("For help about a specific command, type sv_cmd help COMMAND\n");
+
return;
}
- else if(GameCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
+ else if(CommonCommand_macro_usage(argc)) // Instead of trying to call a command, we're going to see detailed information about it
+ {
+ return;
+ }
+ else if(GenericCommand_macro_usage(argc)) // same here, but for generic commands instead
+ {
+ return;
+ }
+ else if(GameCommand_macro_usage(argc)) // finally try for normal commands too
{
return;
}
}
else if(GameCommand_Ban(command))
{
- return; // handled by server/ipban.qc
+ return; // handled by server/command/ipban.qc
+ }
+ else if(CommonCommand_macro_command(argc, command))
+ {
+ return; // handled by server/command/common.qc
}
else if(GenericCommand(command))
{
- return; // handled by common/gamecommand.qc
+ return; // handled by common/command/generic.qc
}
else if(GameCommand_macro_command(argc, command)) // continue as usual and scan for normal commands
{
// allow functions to be used in other code like g_world.qc and teamplay.qc
void VoteThink();
void VoteReset();
+void VoteCommand(float request, entity caller, float argc, string vote_command);
// warmup and nagger stuff
#define RESTART_COUNTDOWN 10