From 5ac525ad06f9775fb38b1f8ad475dbccb9202d8f Mon Sep 17 00:00:00 2001 From: cloudwalk Date: Thu, 11 Jun 2020 14:46:58 +0000 Subject: [PATCH] Delete the cmd_clientfromserver interpreter. Use cmd_client instead This should eliminate an entire class of bugs related to commands missing from the appropriate interpreter. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12667 d7cf8633-e32d-0410-b094-e92efae38249 --- cd_shared.c | 2 -- cl_parse.c | 4 ---- cmd.c | 24 ++---------------------- cmd.h | 3 --- csprogs.c | 10 +++++----- host.c | 1 - host_cmd.c | 7 ++----- libcurl.c | 1 - view.c | 3 --- 9 files changed, 9 insertions(+), 46 deletions(-) diff --git a/cd_shared.c b/cd_shared.c index 6cb98dd5..5a4b3da6 100644 --- a/cd_shared.c +++ b/cd_shared.c @@ -571,8 +571,6 @@ int CDAudio_Init (void) } Cmd_AddCommand(&cmd_client, "cd", CD_f, "execute a CD drive command (cd on/off/reset/remap/close/play/loop/stop/pause/resume/eject/info) - use cd by itself for usage"); - Cmd_AddCommand(&cmd_clientfromserver, "cd", CD_f, "execute a CD drive command (cd on/off/reset/remap/close/play/loop/stop/pause/resume/eject/info) - use cd by itself for usage"); - return 0; } diff --git a/cl_parse.c b/cl_parse.c index 78797300..226794c1 100644 --- a/cl_parse.c +++ b/cl_parse.c @@ -4308,15 +4308,11 @@ void CL_Parse_Init(void) Cmd_AddCommand(&cmd_client, "nextul", QW_CL_NextUpload_f, "sends next fragment of current upload buffer (screenshot for example)"); Cmd_AddCommand(&cmd_client, "stopul", QW_CL_StopUpload_f, "aborts current upload (screenshot for example)"); Cmd_AddCommand(&cmd_client, "skins", QW_CL_Skins_f, "downloads missing qw skins from server"); - Cmd_AddCommand(&cmd_clientfromserver, "skins", QW_CL_Skins_f, "downloads missing qw skins from server"); Cmd_AddCommand(&cmd_client, "changing", QW_CL_Changing_f, "sent by qw servers to tell client to wait for level change"); Cmd_AddCommand(&cmd_client, "cl_begindownloads", CL_BeginDownloads_f, "used internally by darkplaces client while connecting (causes loading of models and sounds or triggers downloads for missing ones)"); Cmd_AddCommand(&cmd_client, "cl_downloadbegin", CL_DownloadBegin_f, "(networking) informs client of download file information, client replies with sv_startsoundload to begin the transfer"); - Cmd_AddCommand(&cmd_clientfromserver, "cl_downloadbegin", CL_DownloadBegin_f, "(networking) informs client of download file information, client replies with sv_startsoundload to begin the transfer"); Cmd_AddCommand(&cmd_client, "stopdownload", CL_StopDownload_f, "terminates a download"); - Cmd_AddCommand(&cmd_clientfromserver, "stopdownload", CL_StopDownload_f, "terminates a download"); Cmd_AddCommand(&cmd_client, "cl_downloadfinished", CL_DownloadFinished_f, "signals that a download has finished and provides the client with file size and crc to check its integrity"); - Cmd_AddCommand(&cmd_clientfromserver, "cl_downloadfinished", CL_DownloadFinished_f, "signals that a download has finished and provides the client with file size and crc to check its integrity"); Cmd_AddCommand(&cmd_client, "iplog_list", CL_IPLog_List_f, "lists names of players whose IP address begins with the supplied text (example: iplog_list 123.456.789)"); } diff --git a/cmd.c b/cmd.c index ec1bca74..47e5a6d2 100644 --- a/cmd.c +++ b/cmd.c @@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "thread.h" cmd_state_t cmd_client; -cmd_state_t cmd_clientfromserver; cmd_state_t cmd_server; cmd_state_t cmd_serverfromclient; @@ -37,7 +36,6 @@ cmd_iter_t; static cmd_iter_t cmd_iter_all[] = { {&cmd_client}, - {&cmd_clientfromserver}, {&cmd_server}, {&cmd_serverfromclient}, {NULL}, @@ -1512,10 +1510,6 @@ void Cmd_Init(void) cmd_client.cvars = &cvars_all; cmd_client.cvars_flagsmask = CVAR_CLIENT | CVAR_SERVER; cmd_client.userdefined = &cmd_userdefined_all; - // stuffcmd from server has access to the reasonable client things, but it probably doesn't need to access the client's server-only cvars - cmd_clientfromserver.cvars = &cvars_all; - cmd_clientfromserver.cvars_flagsmask = CVAR_CLIENT; - cmd_clientfromserver.userdefined = &cmd_userdefined_all; // dedicated server console can only see server cvars, there is no client cmd_server.cvars = &cvars_all; cmd_server.cvars_flagsmask = CVAR_SERVER; @@ -1533,7 +1527,6 @@ void Cmd_Init_Commands(qboolean dedicated_server) // // client-only commands Cmd_AddCommand(&cmd_client, "cmd", Cmd_ForwardToServer_f, "send a console commandline to the server (used by some mods)"); - Cmd_AddCommand(&cmd_clientfromserver, "cmd", Cmd_ForwardToServer_f, "send a console commandline to the server (used by some mods)"); Cmd_AddCommand(&cmd_client, "wait", Cmd_Wait_f, "make script execution wait for next rendered frame"); Cmd_AddCommand(&cmd_client, "cprint", Cmd_Centerprint_f, "print something at the screen center"); @@ -1557,13 +1550,6 @@ void Cmd_Init_Commands(qboolean dedicated_server) Cmd_AddCommand(&cmd_client, "set", Cvar_Set_f, "create or change the value of a console variable"); Cmd_AddCommand(&cmd_client, "seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to config.cfg"); Cmd_AddCommand(&cmd_client, "unset", Cvar_Del_f, "delete a cvar (does not work for static ones like _cl_name, or read-only ones)"); - Cmd_AddCommand(&cmd_clientfromserver, "exec", Cmd_Exec_f, "execute a script file"); - Cmd_AddCommand(&cmd_clientfromserver, "echo", Cmd_Echo_f, "print a message to the console (useful in scripts)"); - Cmd_AddCommand(&cmd_clientfromserver, "alias", Cmd_Alias_f, "create a script function (parameters are passed in as $X (being X a number), $* for all parameters, $X- for all parameters starting from $X). Without arguments show the list of all alias"); - Cmd_AddCommand(&cmd_clientfromserver, "unalias", Cmd_UnAlias_f, "remove an alias"); - Cmd_AddCommand(&cmd_clientfromserver, "set", Cvar_Set_f, "create or change the value of a console variable"); - Cmd_AddCommand(&cmd_clientfromserver, "seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to config.cfg"); - Cmd_AddCommand(&cmd_clientfromserver, "unset", Cvar_Del_f, "delete a cvar (does not work for static ones like _cl_name, or read-only ones)"); Cmd_AddCommand(&cmd_server, "exec", Cmd_Exec_f, "execute a script file"); Cmd_AddCommand(&cmd_server, "echo", Cmd_Echo_f, "print a message to the console (useful in scripts)"); Cmd_AddCommand(&cmd_server, "alias", Cmd_Alias_f, "create a script function (parameters are passed in as $X (being X a number), $* for all parameters, $X- for all parameters starting from $X). Without arguments show the list of all alias"); @@ -1593,7 +1579,6 @@ void Cmd_Init_Commands(qboolean dedicated_server) // Support Doom3-style Toggle Command Cmd_AddCommand(&cmd_client, "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)"); Cmd_AddCommand(&cmd_server, "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)"); - Cmd_AddCommand(&cmd_clientfromserver, "toggle", Cmd_Toggle_f, "toggles a console variable's values (use for more info)"); } /* @@ -2103,13 +2088,8 @@ void Cmd_ExecuteString (cmd_state_t *cmd, const char *text, cmd_source_t src, qb } // check cvars - if (!Cvar_Command(cmd) && host_framecount > 0) { - if (cmd == &cmd_clientfromserver) { - Con_Printf("Server tried to execute \"%s\"\n", Cmd_Argv(cmd, 0)); - } else { - Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0)); - } - } + if (!Cvar_Command(cmd) && host_framecount > 0) + Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(cmd, 0)); done: cmd->tokenizebufferpos = oldpos; if (lockmutex) diff --git a/cmd.h b/cmd.h index 02871000..674b3c19 100644 --- a/cmd.h +++ b/cmd.h @@ -125,9 +125,6 @@ extern cmd_userdefined_t cmd_userdefined_null; // intentionally empty // command interpreter for client commands injected by CSQC, MQC or client engine code // uses cmddefs_all extern cmd_state_t cmd_client; -// command interpreter for client commands received over network from server -// uses cmddefs_all -extern cmd_state_t cmd_clientfromserver; // command interpreter for server commands injected by MQC, SVQC, menu engine code or server engine code // uses cmddefs_all extern cmd_state_t cmd_server; diff --git a/csprogs.c b/csprogs.c index 7f1ea820..2b40adbe 100644 --- a/csprogs.c +++ b/csprogs.c @@ -565,7 +565,7 @@ void CL_VM_Parse_StuffCmd (const char *msg) int sizeflags = csqc_progcrc.flags; csqc_progcrc.flags &= ~CVAR_READONLY; csqc_progsize.flags &= ~CVAR_READONLY; - Cmd_ExecuteString(&cmd_clientfromserver, msg, src_command, true); + Cmd_ExecuteString(&cmd_client, msg, src_command, true); csqc_progcrc.flags = crcflags; csqc_progsize.flags = sizeflags; return; @@ -598,7 +598,7 @@ void CL_VM_Parse_StuffCmd (const char *msg) l = sizeof(buf) - 1; strlcpy(buf, p, l + 1); // strlcpy needs a + 1 as it includes the newline! - Cmd_ExecuteString(&cmd_clientfromserver, buf, src_command, true); + Cmd_ExecuteString(&cmd_client, buf, src_command, true); p += l; if(*p == '\n') @@ -606,13 +606,13 @@ void CL_VM_Parse_StuffCmd (const char *msg) else break; // end of string or overflow } - Cmd_ExecuteString(&cmd_clientfromserver, "curl --clear_autodownload", src_command, true); // don't inhibit CSQC loading + Cmd_ExecuteString(&cmd_client, "curl --clear_autodownload", src_command, true); // don't inhibit CSQC loading return; } if(!cl.csqc_loaded) { - Cbuf_AddText(&cmd_clientfromserver, msg); + Cbuf_AddText(&cmd_client, msg); return; } CSQC_BEGIN @@ -626,7 +626,7 @@ void CL_VM_Parse_StuffCmd (const char *msg) prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize; } else - Cbuf_AddText(&cmd_clientfromserver, msg); + Cbuf_AddText(&cmd_client, msg); CSQC_END } diff --git a/host.c b/host.c index 5c6af792..024aee42 100644 --- a/host.c +++ b/host.c @@ -783,7 +783,6 @@ void Host_Main(void) // process console commands // R_TimeReport("preconsole"); CL_VM_PreventInformationLeaks(); - Cbuf_Frame(&cmd_clientfromserver); Cbuf_Frame(&cmd_client); Cbuf_Frame(&cmd_server); diff --git a/host_cmd.c b/host_cmd.c index bcf349dc..46b261cc 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -3132,7 +3132,6 @@ void Host_InitCommands (void) Cmd_AddCommand(&cmd_client, "connect", Host_Connect_f, "connect to a server by IP address or hostname"); Cmd_AddCommand(&cmd_client, "reconnect", Host_Reconnect_f, "reconnect to the last server you were on, or resets a quakeworld connection (do not use if currently playing on a netquake server)"); - Cmd_AddCommand(&cmd_clientfromserver, "reconnect", Host_Reconnect_f, "reconnect to the last server you were on, or resets a quakeworld connection (do not use if currently playing on a netquake server)"); Cmd_AddCommand(&cmd_client, "startdemos", Host_Startdemos_f, "start playing back the selected demos sequentially (used at end of startup script)"); Cmd_AddCommand(&cmd_client, "demos", Host_Demos_f, "restart looping demos defined by the last startdemos command"); Cmd_AddCommand(&cmd_client, "stopdemo", Host_Stopdemo_f, "stop playing or recording demo (like stop command) and return to looping demos"); @@ -3143,9 +3142,7 @@ void Host_InitCommands (void) Cmd_AddCommand(&cmd_client, "fullinfo", Host_FullInfo_f, "allows client to modify their userinfo"); Cmd_AddCommand(&cmd_client, "setinfo", Host_SetInfo_f, "modifies your userinfo"); Cmd_AddCommand(&cmd_client, "packet", Host_Packet_f, "send a packet to the specified address:port containing a text string"); - Cmd_AddCommand(&cmd_clientfromserver, "packet", Host_Packet_f, "send a packet to the specified address:port containing a text string"); Cmd_AddCommand(&cmd_client, "topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color"); - Cmd_AddCommand(&cmd_clientfromserver, "topcolor", Host_TopColor_f, "QW command to set top color without changing bottom color"); Cmd_AddCommand(&cmd_client, "bottomcolor", Host_BottomColor_f, "QW command to set bottom color without changing top color"); Cmd_AddCommand(&cmd_client, "fixtrans", Image_FixTransparentPixels_f, "change alpha-zero pixels in an image file to sensible values, and write out a new TGA (warning: SLOW)"); @@ -3159,8 +3156,8 @@ void Host_InitCommands (void) Cmd_AddCommand(&cmd_client, "playerskin", Host_Playerskin_f, "change your player skin number"); // commands that are only sent by server to client for execution - Cmd_AddCommand(&cmd_clientfromserver, "pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)"); - Cmd_AddCommand(&cmd_clientfromserver, "fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string"); + Cmd_AddCommand(&cmd_client, "pingplreport", Host_PingPLReport_f, "command sent by server containing client ping and packet loss values for scoreboard, triggered by pings command from client (not used by QW servers)"); + Cmd_AddCommand(&cmd_client, "fullserverinfo", Host_FullServerinfo_f, "internal use only, sent by server to client to update client's local copy of serverinfo string"); } void Host_NoOperation_f(cmd_state_t *cmd) diff --git a/libcurl.c b/libcurl.c index b8f36dc2..e4274d1f 100644 --- a/libcurl.c +++ b/libcurl.c @@ -1553,7 +1553,6 @@ void Curl_Init_Commands(void) Cvar_RegisterVariable (&cl_curl_useragent); Cvar_RegisterVariable (&cl_curl_useragent_append); Cmd_AddCommand(&cmd_client, "curl", Curl_Curl_f, "download data from an URL and add to search path"); - Cmd_AddCommand(&cmd_clientfromserver, "curl", Curl_Curl_f, "download data from an URL and add to search path"); //Cmd_AddCommand(&cmd_client, "curlcat", Curl_CurlCat_f, "display data from an URL (debugging command)"); } diff --git a/view.c b/view.c index 7bea5a96..844f63fe 100644 --- a/view.c +++ b/view.c @@ -1204,9 +1204,6 @@ void V_Init (void) Cmd_AddCommand(&cmd_client, "bf", V_BonusFlash_f, "briefly flashes a bright color tint on view (used when items are picked up); optionally takes R G B [A [alphafade]] arguments to specify how the flash looks"); Cmd_AddCommand(&cmd_client, "centerview", V_StartPitchDrift_f, "gradually recenter view (stop looking up/down)"); - Cmd_AddCommand(&cmd_clientfromserver, "v_cshift", V_cshift_f, "sets tint color of view"); - Cmd_AddCommand(&cmd_clientfromserver, "bf", V_BonusFlash_f, "briefly flashes a bright color tint on view (used when items are picked up); optionally takes R G B [A [alphafade]] arguments to specify how the flash looks"); - Cvar_RegisterVariable (&v_centermove); Cvar_RegisterVariable (&v_centerspeed); -- 2.39.2