]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cmd: Dynamically allocate the command interpreters
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 9 Mar 2021 00:12:25 +0000 (00:12 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 9 Mar 2021 00:12:25 +0000 (00:12 +0000)
Will help with threading and other stuff later.

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@13097 d7cf8633-e32d-0410-b094-e92efae38249

23 files changed:
cl_demo.c
cl_main.c
cl_parse.c
clvm_cmds.c
cmd.c
cmd.h
csprogs.c
cvar.c
fs.c
gl_rmain.c
host.c
keys.c
libcurl.c
menu.c
netconn.c
progsvm.h
prvm_cmds.c
r_shadow.c
sv_main.c
sv_user.c
svvm_cmds.c
sys_shared.c
vid_sdl.c

index 6858aea619833e8596c988e24e3e5d4b780049e1..a3be2148d09709c6ab33208eec19313ea9e0f585 100644 (file)
--- a/cl_demo.c
+++ b/cl_demo.c
@@ -67,7 +67,7 @@ void CL_NextDemo (void)
        }
 
        dpsnprintf (str, sizeof(str), "playdemo %s\n", cls.demos[cls.demonum]);
-       Cbuf_InsertText(&cmd_client, str);
+       Cbuf_InsertText(cmd_client, str);
        cls.demonum++;
 }
 
@@ -274,7 +274,7 @@ void CL_ReadDemoMessage(void)
                        CL_ParseServerMessage();
 
                        if (cls.signon != SIGNONS)
-                               Cbuf_Execute((&cmd_client)->cbuf); // immediately execute svc_stufftext if in the demo before connect!
+                               Cbuf_Execute((cmd_client)->cbuf); // immediately execute svc_stufftext if in the demo before connect!
 
                        // In case the demo contains a "svc_disconnect" message
                        if (!cls.demoplayback)
@@ -531,7 +531,7 @@ static void CL_FinishTimeDemo (void)
                        if(atoi(sys.argv[i + 1]) > benchmark_runs)
                        {
                                // restart the benchmark
-                               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", cls.demoname));
+                               Cbuf_AddText(cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", cls.demoname));
                                // cannot execute here
                        }
                        else
index 2a2b9976d204dd82cc6e41bf67c9c3e1b1e6cf50..d9256f16917dc859b178a7e8ce71cbd4c67ef71b 100644 (file)
--- a/cl_main.c
+++ b/cl_main.c
@@ -397,7 +397,7 @@ void CL_Disconnect(void)
                sizebuf_t buf;
                unsigned char bufdata[8];
                if (cls.demorecording)
-                       CL_Stop_f(&cmd_client);
+                       CL_Stop_f(cmd_client);
 
                // send disconnect message 3 times to improve chances of server
                // receiving it (but it still fails sometimes)
@@ -553,8 +553,8 @@ void CL_EstablishConnection(const char *address, int firstarg)
                {
                        int i;
                        *cls.connect_userinfo = 0;
-                       for(i = firstarg; i+2 <= Cmd_Argc(&cmd_client); i += 2)
-                               InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(&cmd_client, i), Cmd_Argv(&cmd_client, i+1));
+                       for(i = firstarg; i+2 <= Cmd_Argc(cmd_client); i += 2)
+                               InfoString_SetValue(cls.connect_userinfo, sizeof(cls.connect_userinfo), Cmd_Argv(cmd_client, i), Cmd_Argv(cmd_client, i+1));
                }
                else if(firstarg < -1)
                {
index 3d5274d232ae375e0b6b6b33ebef45efb2cd22ec..bd402e2fc6fc2c5818e6371f312a8e4b57c468aa 100644 (file)
@@ -499,7 +499,7 @@ static void CL_SetupWorldModel(void)
        World_Start(&cl.world);
 
        // load or reload .loc file for team chat messages
-       CL_Locs_Reload_f(&cmd_client);
+       CL_Locs_Reload_f(cmd_client);
 
        // make sure we send enough keepalives
        CL_KeepaliveMessage(false);
@@ -939,7 +939,7 @@ void QW_CL_StartUpload(unsigned char *data, int size)
                return;
 
        // abort existing upload if in progress
-       QW_CL_StopUpload_f(&cmd_client);
+       QW_CL_StopUpload_f(cmd_client);
 
        Con_DPrintf("Starting upload of %d bytes...\n", size);
 
@@ -948,7 +948,7 @@ void QW_CL_StartUpload(unsigned char *data, int size)
        cls.qw_uploadsize = size;
        cls.qw_uploadpos = 0;
 
-       QW_CL_NextUpload_f(&cmd_client);
+       QW_CL_NextUpload_f(cmd_client);
 }
 
 #if 0
@@ -1618,7 +1618,7 @@ static void CL_SignonReply (void)
                        // execute cl_begindownloads next frame
                        // (after any commands added by svc_stufftext have been executed)
                        // when done with downloads the "prespawn" will be sent
-                       Cbuf_AddText(&cmd_client, "\ncl_begindownloads\n");
+                       Cbuf_AddText(cmd_client, "\ncl_begindownloads\n");
 
                        //MSG_WriteByte (&cls.netcon->message, clc_stringcmd);
                        //MSG_WriteString (&cls.netcon->message, "prespawn");
@@ -1919,7 +1919,7 @@ static void CL_ParseServerInfo (void)
                        if (cls.demorecording)
                        {
                                // finish the previous level's demo file
-                               CL_Stop_f(&cmd_client);
+                               CL_Stop_f(cmd_client);
                        }
 
                        // start a new demo file
@@ -3660,7 +3660,7 @@ void CL_ParseServerMessage(void)
                                break;
 
                        case qw_svc_sellscreen:
-                               Cmd_ExecuteString(&cmd_client, "help", src_local, true);
+                               Cmd_ExecuteString(cmd_client, "help", src_local, true);
                                break;
 
                        case qw_svc_smallkick:
@@ -4169,7 +4169,7 @@ void CL_ParseServerMessage(void)
                                break;
 
                        case svc_sellscreen:
-                               Cmd_ExecuteString(&cmd_client, "help", src_local, true);
+                               Cmd_ExecuteString(cmd_client, "help", src_local, true);
                                break;
                        case svc_hidelmp:
                                if (gamemode == GAME_TENEBRAE)
@@ -4272,7 +4272,7 @@ void CL_Parse_DumpPacket(void)
 void CL_Parse_ErrorCleanUp(void)
 {
        CL_StopDownload(0, 0);
-       QW_CL_StopUpload_f(&cmd_client);
+       QW_CL_StopUpload_f(cmd_client);
 }
 
 void CL_Parse_Init(void)
index c3e9130db6390f588f39efc210036819f2462bac..ff68d4f8b4a0b2509a49fd5012002449604d59b0 100644 (file)
@@ -2402,7 +2402,7 @@ static void VM_CL_setlistener (prvm_prog_t *prog)
 static void VM_CL_registercmd (prvm_prog_t *prog)
 {
        VM_SAFEPARMCOUNT(1, VM_CL_registercmd);
-       if(!Cmd_Exists(&cmd_client, PRVM_G_STRING(OFS_PARM0)))
+       if(!Cmd_Exists(cmd_client, PRVM_G_STRING(OFS_PARM0)))
                Cmd_AddCommand(CF_CLIENT, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
 }
 
diff --git a/cmd.c b/cmd.c
index 722d1477ad9e1f03ad1ba0b6993b7a61e03ea743..490a987ec5abcd7394d3b87fff6f9bc846a717b0 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -22,9 +22,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "quakedef.h"
 #include "thread.h"
 
-cmd_state_t cmd_client;
-cmd_state_t cmd_server;
-cmd_state_t cmd_serverfromclient;
+cmd_state_t *cmd_client;
+cmd_state_t *cmd_server;
+cmd_state_t *cmd_serverfromclient;
 
 cmd_userdefined_t cmd_userdefined_all;
 cmd_userdefined_t cmd_userdefined_null;
@@ -34,12 +34,7 @@ typedef struct cmd_iter_s {
 }
 cmd_iter_t;
 
-static cmd_iter_t cmd_iter_all[] = {
-       {&cmd_client},
-       {&cmd_server},
-       {&cmd_serverfromclient},
-       {NULL},
-};
+static cmd_iter_t *cmd_iter_all;
 
 mempool_t *cbuf_mempool;
 
@@ -1602,6 +1597,25 @@ static void Cmd_Apropos_f(cmd_state_t *cmd)
        Con_Printf("%i result%s\n\n", count, (count > 1) ? "s" : "");
 }
 
+static cmd_state_t *Cmd_AddInterpreter(cmd_buf_t *cbuf, cvar_state_t *cvars, int cvars_flagsmask, int cmds_flagsmask, cmd_userdefined_t *userdefined, int autoflags, xcommand_t autofunction)
+{
+       cmd_state_t *cmd = (cmd_state_t *)Mem_Alloc(tempmempool, sizeof(cmd_state_t));
+       
+       cmd->mempool = Mem_AllocPool("commands", 0, NULL);
+       // space for commands and script files
+       cmd->cbuf = cbuf;
+       cmd->null_string = "";
+
+       cmd->cvars = cvars;
+       cmd->cvars_flagsmask = cvars_flagsmask;
+       cmd->cmd_flags = cmds_flagsmask;
+       cmd->auto_flags = autoflags;
+       cmd->auto_function = autofunction;
+       cmd->userdefined = userdefined;
+
+       return cmd;
+}
+
 /*
 ============
 Cmd_Init
@@ -1609,7 +1623,6 @@ Cmd_Init
 */
 void Cmd_Init(void)
 {
-       cmd_iter_t *cmd_iter;
        cmd_buf_t *cbuf;
        cbuf_mempool = Mem_AllocPool("Command buffer", 0, NULL);
        cbuf = (cmd_buf_t *)Mem_Alloc(cbuf_mempool, sizeof(cmd_buf_t));
@@ -1622,36 +1635,19 @@ void Cmd_Init(void)
        cbuf->deferred.prev = cbuf->deferred.next = &(cbuf->deferred);
        cbuf->free.prev = cbuf->free.next = &(cbuf->free);
 
-       for (cmd_iter = cmd_iter_all; cmd_iter->cmd; cmd_iter++)
-       {
-               cmd_state_t *cmd = cmd_iter->cmd;
-               cmd->mempool = Mem_AllocPool("commands", 0, NULL);
-               // space for commands and script files
-               cmd->cbuf = cbuf;
-               cmd->null_string = "";
-       }
+       // FIXME: Get rid of cmd_iter_all eventually. This is just a hack to reduce the amount of work to make the interpreters dynamic.
+       cmd_iter_all = (cmd_iter_t *)Mem_Alloc(tempmempool, sizeof(cmd_iter_t) * 4);
+
        // client console can see server cvars because the user may start a server
-       cmd_client.cvars = &cvars_all;
-       cmd_client.cvars_flagsmask = CF_CLIENT | CF_SERVER;
-       cmd_client.cmd_flags = CF_CLIENT | CF_CLIENT_FROM_SERVER;
-       cmd_client.auto_flags = CF_SERVER_FROM_CLIENT;
-       cmd_client.auto_function = CL_ForwardToServer_f; // FIXME: Move this to the client.
-       cmd_client.userdefined = &cmd_userdefined_all;
+       cmd_iter_all[0].cmd = cmd_client = Cmd_AddInterpreter(cbuf, &cvars_all, CF_CLIENT | CF_SERVER, CF_CLIENT | CF_CLIENT_FROM_SERVER, &cmd_userdefined_all, CF_SERVER_FROM_CLIENT, CL_ForwardToServer_f);
+
        // dedicated server console can only see server cvars, there is no client
-       cmd_server.cvars = &cvars_all;
-       cmd_server.cvars_flagsmask = CF_SERVER;
-       cmd_server.cmd_flags = CF_SERVER;
-       cmd_server.auto_flags = 0;
-       cmd_server.auto_function = NULL;
-       cmd_server.userdefined = &cmd_userdefined_all;
+       cmd_iter_all[1].cmd = cmd_server = Cmd_AddInterpreter(cbuf, &cvars_all, CF_SERVER, CF_SERVER, &cmd_userdefined_all, 0, NULL);
+
        // server commands received from clients have no reason to access cvars, cvar expansion seems perilous.
-       cmd_serverfromclient.cvars = &cvars_null;
-       cmd_serverfromclient.cvars_flagsmask = 0;
-       cmd_serverfromclient.cmd_flags = CF_SERVER_FROM_CLIENT | CF_USERINFO;
-       cmd_serverfromclient.auto_flags = 0;
-       cmd_serverfromclient.auto_function = NULL;
-       cmd_serverfromclient.userdefined = &cmd_userdefined_null;
+       cmd_iter_all[2].cmd = cmd_serverfromclient = Cmd_AddInterpreter(cbuf, &cvars_null, 0, CF_SERVER_FROM_CLIENT | CF_USERINFO, &cmd_userdefined_null, 0, NULL);
 
+       cmd_iter_all[3].cmd = NULL;
 //
 // register our commands
 //
diff --git a/cmd.h b/cmd.h
index b10560077b9baa6abbc712a8158fdb07f65264f6..e9b2404aeee069d825f2adbf49b2eb23dd4cc792 100644 (file)
--- a/cmd.h
+++ b/cmd.h
@@ -170,13 +170,13 @@ 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;
+extern cmd_state_t *cmd_client;
 // 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;
+extern cmd_state_t *cmd_server;
 // command interpreter for server commands received over network from clients
 // uses cmddefs_null
-extern cmd_state_t cmd_serverfromclient;
+extern cmd_state_t *cmd_serverfromclient;
 
 extern qbool host_stuffcmdsrun;
 
index f5d3f9ea38b420f49369dde8a5fda63af4824909..80666f5edaaf06eb652cdd2a01021694a92d0316 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -571,7 +571,7 @@ void CL_VM_Parse_StuffCmd (const char *msg)
                int crcflags = csqc_progcrc.flags;
                csqc_progcrc.flags &= ~CF_READONLY;
                csqc_progsize.flags &= ~CF_READONLY;
-               Cmd_ExecuteString(&cmd_client, msg, src_local, true);
+               Cmd_ExecuteString(cmd_client, msg, src_local, true);
                csqc_progcrc.flags = csqc_progsize.flags = crcflags;
                return;
        }
@@ -603,7 +603,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_client, buf, src_local, true);
+                       Cmd_ExecuteString(cmd_client, buf, src_local, true);
 
                        p += l;
                        if(*p == '\n')
@@ -611,13 +611,13 @@ void CL_VM_Parse_StuffCmd (const char *msg)
                        else
                                break; // end of string or overflow
                }
-               Cmd_ExecuteString(&cmd_client, "curl --clear_autodownload", src_local, true); // don't inhibit CSQC loading
+               Cmd_ExecuteString(cmd_client, "curl --clear_autodownload", src_local, true); // don't inhibit CSQC loading
                return;
        }
 
        if(!cl.csqc_loaded)
        {
-               Cbuf_AddText(&cmd_client, msg);
+               Cbuf_AddText(cmd_client, msg);
                return;
        }
        CSQC_BEGIN
@@ -631,7 +631,7 @@ void CL_VM_Parse_StuffCmd (const char *msg)
                prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
        }
        else
-               Cbuf_AddText(&cmd_client, msg);
+               Cbuf_AddText(cmd_client, msg);
        CSQC_END
 }
 
@@ -1056,7 +1056,7 @@ void CL_VM_Init (void)
                return;
        }
 
-       PRVM_Prog_Init(prog, &cmd_client);
+       PRVM_Prog_Init(prog, cmd_client);
 
        // allocate the mempools
        prog->progs_mempool = Mem_AllocPool(csqc_progname.string, 0, NULL);
@@ -1156,7 +1156,7 @@ void CL_VM_Init (void)
 void CL_VM_ShutDown (void)
 {
        prvm_prog_t *prog = CLVM_prog;
-       Cmd_ClearCSQCCommands(&cmd_client);
+       Cmd_ClearCSQCCommands(cmd_client);
        //Cvar_SetValueQuick(&csqc_progcrc, -1);
        //Cvar_SetValueQuick(&csqc_progsize, -1);
        if(!cl.csqc_loaded)
diff --git a/cvar.c b/cvar.c
index f60a212eb9c7ed9d5ef0976a68b0620266dc8cc1..b4f18c6b30e9104c107a0a9cd585a4cf12f63754 100644 (file)
--- a/cvar.c
+++ b/cvar.c
@@ -621,7 +621,7 @@ void Cvar_RegisterVariable (cvar_t *variable)
        }
 
        // check for overlap with a command
-       if (Cmd_Exists(&cmd_client, variable->name) || Cmd_Exists(&cmd_server, variable->name))
+       if (Cmd_Exists(cmd_client, variable->name) || Cmd_Exists(cmd_server, variable->name))
        {
                Con_Printf("Cvar_RegisterVariable: %s is a command\n", variable->name);
                return;
@@ -685,7 +685,7 @@ cvar_t *Cvar_Get(cvar_state_t *cvars, const char *name, const char *value, int f
        }
 
        // check for overlap with a command
-       if (Cmd_Exists(&cmd_client, name) || Cmd_Exists(&cmd_server, name))
+       if (Cmd_Exists(cmd_client, name) || Cmd_Exists(cmd_server, name))
        {
                Con_Printf("Cvar_Get: %s is a command\n", name);
                return NULL;
diff --git a/fs.c b/fs.c
index 74733bfb0f55ced81ac21d06f33ea18a15c2303c..87c5df4accacaa479f96ab0e2ebf5e4ca565fa84 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1574,15 +1574,15 @@ qbool FS_ChangeGameDirs(int numgamedirs, char gamedirs[][MAX_QPATH], qbool compl
 
        if (cls.demoplayback)
        {
-               CL_Disconnect_f(&cmd_client);
+               CL_Disconnect_f(cmd_client);
                cls.demonum = 0;
        }
 
        // unload all sounds so they will be reloaded from the new files as needed
-       S_UnloadAllSounds_f(&cmd_client);
+       S_UnloadAllSounds_f(cmd_client);
 
        // restart the video subsystem after the config is executed
-       Cbuf_InsertText(&cmd_client, "\nloadconfig\nvid_restart\n\n");
+       Cbuf_InsertText(cmd_client, "\nloadconfig\nvid_restart\n\n");
 
        return true;
 }
index 7764d9044af9c87a4afcd812b8dc6379f3907b2f..3b9994f0ffdc2bf250d0ed538979a772de0f60d0 100644 (file)
@@ -3197,7 +3197,7 @@ static void gl_main_shutdown(void)
        r_texture_numcubemaps = 0;
        //r_texture_fogintensity = NULL;
        memset(&r_fb, 0, sizeof(r_fb));
-       R_GLSL_Restart_f(&cmd_client);
+       R_GLSL_Restart_f(cmd_client);
 
        r_glsl_permutation = NULL;
        memset(r_glsl_permutationhash, 0, sizeof(r_glsl_permutationhash));
@@ -5692,7 +5692,7 @@ void R_RenderView(int fbo, rtexture_t *depthtexture, rtexture_t *colortexture, i
        rsurface.entity = NULL; // used only by R_GetCurrentTexture and RSurf_ActiveModelEntity
 
        if(R_CompileShader_CheckStaticParms())
-               R_GLSL_Restart_f(&cmd_client);
+               R_GLSL_Restart_f(cmd_client);
 
        if (!r_drawentities.integer)
                r_refdef.scene.numentities = 0;
diff --git a/host.c b/host.c
index 268c1467ee2ba715baa6e62c900da2ec411b353b..1dc4b0d5b8d2c65dd569bad28d0f6d1b302e98bf 100644 (file)
--- a/host.c
+++ b/host.c
@@ -293,10 +293,10 @@ void Host_LoadConfig_f(cmd_state_t *cmd)
        Cmd_RestoreInitState();
 #ifdef CONFIG_MENU
        // prepend a menu restart command to execute after the config
-       Cbuf_InsertText(&cmd_client, "\nmenu_restart\n");
+       Cbuf_InsertText(cmd_client, "\nmenu_restart\n");
 #endif
        // reset cvars to their defaults, and then exec startup scripts again
-       Host_AddConfigText(&cmd_client);
+       Host_AddConfigText(cmd_client);
 }
 
 //============================================================================
@@ -315,9 +315,9 @@ static void Host_GetConsoleCommands (void)
        while ((line = Sys_ConsoleInput()))
        {
                if (cls.state == ca_dedicated)
-                       Cbuf_AddText(&cmd_server, line);
+                       Cbuf_AddText(cmd_server, line);
                else
-                       Cbuf_AddText(&cmd_client, line);
+                       Cbuf_AddText(cmd_client, line);
        }
 }
 
@@ -558,7 +558,6 @@ static void Host_Init (void)
        int i;
        const char* os;
        char vabuf[1024];
-       cmd_state_t *cmd = &cmd_client;
 
        host.hook.ConnectLocal = NULL;
        host.hook.Disconnect = NULL;
@@ -672,13 +671,13 @@ static void Host_Init (void)
 
        // here comes the not so critical stuff
 
-       Host_AddConfigText(cmd);
+       Host_AddConfigText(cmd_client);
 
        // if quake.rc is missing, use default
        if (!FS_FileExists("quake.rc"))
        {
-               Cbuf_AddText(cmd, "exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\n");
-               Cbuf_Execute(cmd->cbuf);
+               Cbuf_AddText(cmd_client, "exec default.cfg\nexec " CONFIGFILENAME "\nexec autoexec.cfg\n");
+               Cbuf_Execute(cmd_client->cbuf);
        }
 
        host.state = host_active;
@@ -699,8 +698,8 @@ static void Host_Init (void)
        if (i && i + 1 < sys.argc)
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
-               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", sys.argv[i + 1]));
-               Cbuf_Execute((&cmd_client)->cbuf);
+               Cbuf_AddText(cmd_client, va(vabuf, sizeof(vabuf), "timedemo %s\n", sys.argv[i + 1]));
+               Cbuf_Execute(cmd_client->cbuf);
        }
 
        // check for special demo mode
@@ -709,8 +708,8 @@ static void Host_Init (void)
        if (i && i + 1 < sys.argc)
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
-               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\n", sys.argv[i + 1]));
-               Cbuf_Execute((&cmd_client)->cbuf);
+               Cbuf_AddText(cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\n", sys.argv[i + 1]));
+               Cbuf_Execute(cmd_client->cbuf);
        }
 
 #ifdef CONFIG_VIDEO_CAPTURE
@@ -719,24 +718,24 @@ static void Host_Init (void)
        if (i && i + 1 < sys.argc)
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
-               Cbuf_AddText(&cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", sys.argv[i + 1]));
-               Cbuf_Execute((&cmd_client)->cbuf);
+               Cbuf_AddText(cmd_client, va(vabuf, sizeof(vabuf), "playdemo %s\ncl_capturevideo 1\n", sys.argv[i + 1]));
+               Cbuf_Execute((cmd_client)->cbuf);
        }
 #endif
 
        if (cls.state == ca_dedicated || Sys_CheckParm("-listen"))
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
-               Cbuf_AddText(&cmd_client, "startmap_dm\n");
-               Cbuf_Execute((&cmd_client)->cbuf);
+               Cbuf_AddText(cmd_client, "startmap_dm\n");
+               Cbuf_Execute(cmd_client->cbuf);
        }
 
        if (!sv.active && !cls.demoplayback && !cls.connect_trying)
        {
 #ifdef CONFIG_MENU
-               Cbuf_AddText(&cmd_client, "togglemenu 1\n");
+               Cbuf_AddText(cmd_client, "togglemenu 1\n");
 #endif
-               Cbuf_Execute((&cmd_client)->cbuf);
+               Cbuf_Execute(cmd_client->cbuf);
        }
 
        Con_DPrint("========Initialized=========\n");
diff --git a/keys.c b/keys.c
index d830e827abbecab806f3bab29991aef6c47f5f59..b41f46b332d458907331625908e55375682cc126 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -1832,7 +1832,7 @@ void Key_EventQueue_Unblock(void)
 void
 Key_Event (int key, int ascii, qbool down)
 {
-       cmd_state_t *cmd = &cmd_client;
+       cmd_state_t *cmd = cmd_client;
        const char *bind;
        qbool q;
        keydest_t keydest = key_dest;
@@ -1910,7 +1910,7 @@ Key_Event (int key, int ascii, qbool down)
                {
                        if(down)
                        {
-                               Con_ToggleConsole_f(&cmd_client);
+                               Con_ToggleConsole_f(cmd_client);
                                tbl_keydest[key] = key_void; // esc release should go nowhere (especially not to key_menu or key_game)
                        }
                        return;
@@ -1929,7 +1929,7 @@ Key_Event (int key, int ascii, qbool down)
 #endif
                                        }
                                        else
-                                               Con_ToggleConsole_f(&cmd_client);
+                                               Con_ToggleConsole_f(cmd_client);
                                }
                                break;
 
@@ -1993,7 +1993,7 @@ Key_Event (int key, int ascii, qbool down)
                // (special exemption for german keyboard layouts)
                if (con_closeontoggleconsole.integer && bind && !strncmp(bind, "toggleconsole", strlen("toggleconsole")) && (key_consoleactive & KEY_CONSOLEACTIVE_USER) && (con_closeontoggleconsole.integer >= ((ascii != STRING_COLOR_TAG) ? 2 : 3) || key_linepos == 1))
                {
-                       Con_ToggleConsole_f(&cmd_client);
+                       Con_ToggleConsole_f(cmd_client);
                        return;
                }
 
index cd106e7e67ebfb60df40d0a1bb17b05d49dbf6d5..ce89092fe74371ae7212114359496c52e0962e5d 100644 (file)
--- a/libcurl.c
+++ b/libcurl.c
@@ -331,16 +331,16 @@ static void Curl_CheckCommandWhenDone(void)
                if(numdownloads_fail == 0)
                {
                        Con_DPrintf("cURL downloads occurred, executing %s\n", command_when_done);
-                       Cbuf_AddText(&cmd_client, "\n");
-                       Cbuf_AddText(&cmd_client, command_when_done);
-                       Cbuf_AddText(&cmd_client, "\n");
+                       Cbuf_AddText(cmd_client, "\n");
+                       Cbuf_AddText(cmd_client, command_when_done);
+                       Cbuf_AddText(cmd_client, "\n");
                }
                else
                {
                        Con_DPrintf("cURL downloads FAILED, executing %s\n", command_when_error);
-                       Cbuf_AddText(&cmd_client, "\n");
-                       Cbuf_AddText(&cmd_client, command_when_error);
-                       Cbuf_AddText(&cmd_client, "\n");
+                       Cbuf_AddText(cmd_client, "\n");
+                       Cbuf_AddText(cmd_client, command_when_error);
+                       Cbuf_AddText(cmd_client, "\n");
                }
                Curl_Clear_forthismap();
        }
@@ -1553,7 +1553,7 @@ void Curl_Init_Commands(void)
        Cvar_RegisterVariable (&cl_curl_useragent);
        Cvar_RegisterVariable (&cl_curl_useragent_append);
        Cmd_AddCommand(CF_CLIENT | CF_CLIENT_FROM_SERVER, "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)");
+       //Cmd_AddCommand(cmd_client, "curlcat", Curl_CurlCat_f, "display data from an URL (debugging command)");
 }
 
 /*
diff --git a/menu.c b/menu.c
index 95202cacc0d2282f035f1c34fcd7ff0075035c74..4ef7d081c2a92cdd25b88db2b24683d1c80d4d28 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -282,7 +282,7 @@ static void M_ToggleMenu(int mode)
        {
                if(mode == 0)
                        return; // the menu is off, and we want it off
-               M_Menu_Main_f (&cmd_client);
+               M_Menu_Main_f (cmd_client);
        }
        else
        {
@@ -4910,7 +4910,7 @@ void M_Draw (void)
 
 void M_KeyEvent (int key, int ascii, qbool downevent)
 {
-       cmd_state_t *cmd = &cmd_client;
+       cmd_state_t *cmd = cmd_client;
        if (!downevent)
                return;
        switch (m_state)
@@ -5378,7 +5378,7 @@ static void MP_Shutdown (void)
 static void MP_Init (void)
 {
        prvm_prog_t *prog = MVM_prog;
-       PRVM_Prog_Init(prog, &cmd_client);
+       PRVM_Prog_Init(prog, cmd_client);
 
        prog->edictprivate_size = 0; // no private struct used
        prog->name = "menu";
index 1b48ac691764de43cc3e0a79bc44bd9d50e281c9..61ffeeda57765948744ddaa9818e2a282baa01aa 100755 (executable)
--- a/netconn.c
+++ b/netconn.c
@@ -2923,7 +2923,7 @@ static void RCon_Execute(lhnetsocket_t *mysocket, lhnetaddress_t *peeraddress, c
                        if(l)
                        {
                                client_t *host_client_save = host_client;
-                               Cmd_ExecuteString(&cmd_server, s, src_local, true);
+                               Cmd_ExecuteString(cmd_server, s, src_local, true);
                                host_client = host_client_save;
                                // in case it is a command that changes host_client (like restart)
                        }
index 0b624265da1ab91cc50cda39d3ca5a721fffc1c4..c2d70f144f86b3ef1905e0146e9fa7bfc3460ea2 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -631,7 +631,7 @@ typedef struct prvm_prog_s
        struct fssearch_s                       *opensearches[PRVM_MAX_OPENSEARCHES];
        const char *         opensearches_origin[PRVM_MAX_OPENSEARCHES];
        struct skeleton_s       *skeletons[MAX_EDICTS];
-       struct cmd_state_s      *console_cmd; // points to the relevant console command interpreter for this vm (&cmd_client or &cmd_server), also used to access cvars
+       struct cmd_state_s      *console_cmd; // points to the relevant console command interpreter for this vm (cmd_client or &cmd_server), also used to access cvars
 
        // buffer for storing all tempstrings created during one invocation of ExecuteProgram
        sizebuf_t                       tempstringsbuf;
index c83598b6479280bccfe204c90a7030a76c81e30b..67ccb3f31151dfc810137fcd1c4f71253da8d83d 100644 (file)
@@ -608,7 +608,7 @@ void VM_localcmd_client(prvm_prog_t *prog)
        char string[VM_STRINGTEMP_LENGTH];
        VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd_client);
        VM_VarString(prog, 0, string, sizeof(string));
-       Cbuf_AddText(&cmd_client, string);
+       Cbuf_AddText(cmd_client, string);
 }
 
 /*
@@ -626,7 +626,7 @@ void VM_localcmd_server(prvm_prog_t *prog)
        char string[VM_STRINGTEMP_LENGTH];
        VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd_server);
        VM_VarString(prog, 0, string, sizeof(string));
-       Cbuf_AddText(&cmd_server, string);
+       Cbuf_AddText(cmd_server, string);
 }
 
 static qbool PRVM_Cvar_ReadOk(prvm_prog_t *prog, const char *string)
@@ -1335,7 +1335,7 @@ coredump()
 */
 void VM_coredump(prvm_prog_t *prog)
 {
-       cmd_state_t *cmd =      !host_isclient.integer ? &cmd_server : &cmd_client;
+       cmd_state_t *cmd =      !host_isclient.integer ? cmd_server : cmd_client;
        VM_SAFEPARMCOUNT(0,VM_coredump);
 
        Cbuf_AddText(cmd, "prvm_edicts ");
@@ -1521,7 +1521,7 @@ void VM_changelevel(prvm_prog_t *prog)
                return;
        svs.changelevel_issued = true;
 
-       Cbuf_AddText(&cmd_server, va(vabuf, sizeof(vabuf), "changelevel %s\n", PRVM_G_STRING(OFS_PARM0)));
+       Cbuf_AddText(cmd_server, va(vabuf, sizeof(vabuf), "changelevel %s\n", PRVM_G_STRING(OFS_PARM0)));
 }
 
 /*
@@ -1669,7 +1669,7 @@ void VM_registercvar(prvm_prog_t *prog)
                return;
 
 // check for overlap with a command
-       if (Cmd_Exists(&cmd_client, name) || Cmd_Exists(&cmd_server, name))
+       if (Cmd_Exists(cmd_client, name) || Cmd_Exists(cmd_server, name))
        {
                VM_Warning(prog, "VM_registercvar: %s is a command\n", name);
                return;
index dcb5104d82db9f2ef42d639fd2fc1329237f1a58..c6ee977f2c4c54807249a53510bc8d369a45e376 100644 (file)
@@ -372,7 +372,7 @@ static void R_Shadow_SetShadowMode(void)
        }
 
        if(R_CompileShader_CheckStaticParms())
-               R_GLSL_Restart_f(&cmd_client);
+               R_GLSL_Restart_f(cmd_client);
 }
 
 qbool R_Shadow_ShadowMappingEnabled(void)
@@ -597,7 +597,7 @@ static void r_shadow_newmap(void)
        if (r_editlights_sprcubemapnoshadowlight) { R_SkinFrame_MarkUsed(r_editlights_sprcubemapnoshadowlight); }
        if (r_editlights_sprselection)            { R_SkinFrame_MarkUsed(r_editlights_sprselection); }
        if (strncmp(cl.worldname, r_shadow_mapname, sizeof(r_shadow_mapname)))
-               R_Shadow_EditLights_Reload_f(&cmd_client);
+               R_Shadow_EditLights_Reload_f(cmd_client);
 }
 
 void R_Shadow_Init(void)
@@ -5742,7 +5742,7 @@ static void R_Shadow_EditLights_EditAll_f(cmd_state_t *cmd)
                if (!light)
                        continue;
                R_Shadow_SelectLight(light);
-               R_Shadow_EditLights_Edit_f(&cmd_client);
+               R_Shadow_EditLights_Edit_f(cmd_client);
        }
        // return to old selected (to not mess editing once selection is locked)
        R_Shadow_SelectLight(oldselected);
index 37d085088feb3e6e2e15a21da89d905970bc7728..3ed6e110a6a4a9f43dfe6c26752a8f25b3c03654 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -2268,7 +2268,7 @@ static qbool SVVM_load_edict(prvm_prog_t *prog, prvm_edict_t *ent)
 static void SV_VM_Setup(void)
 {
        prvm_prog_t *prog = SVVM_prog;
-       PRVM_Prog_Init(prog, &cmd_server);
+       PRVM_Prog_Init(prog, cmd_server);
 
        // allocate the mempools
        // TODO: move the magic numbers/constants into #defines [9/13/2006 Black]
index 95f47224985200ed3eccca762a600b7005d42164..9e17dbfee03d0da0d8e65e19122b4cbb7b667667 100644 (file)
--- a/sv_user.c
+++ b/sv_user.c
@@ -1063,7 +1063,7 @@ void SV_ReadClientMessage(void)
                        if (strncasecmp(s, "spawn", 5) == 0
                         || strncasecmp(s, "begin", 5) == 0
                         || strncasecmp(s, "prespawn", 8) == 0)
-                               Cmd_ExecuteString (&cmd_serverfromclient, s, src_client, true);
+                               Cmd_ExecuteString (cmd_serverfromclient, s, src_client, true);
                        else if (PRVM_serverfunction(SV_ParseClientCommand))
                        {
                                int restorevm_tempstringsbuf_cursize;
@@ -1075,7 +1075,7 @@ void SV_ReadClientMessage(void)
                                prog->tempstringsbuf.cursize = restorevm_tempstringsbuf_cursize;
                        }
                        else
-                               Cmd_ExecuteString (&cmd_serverfromclient, s, src_client, true);
+                               Cmd_ExecuteString (cmd_serverfromclient, s, src_client, true);
                        break;
 
 clc_stringcmd_invalid:
index 5147a324fcf9e5e1adf53d3342b8c1e8fe76fd25..bece8d54fe82d5e841fc551e556e0cf51bfca211 100644 (file)
@@ -2359,7 +2359,7 @@ static void VM_SV_clientcommand(prvm_prog_t *prog)
 
        temp_client = host_client;
        host_client = svs.clients + i;
-       Cmd_ExecuteString(&cmd_serverfromclient, PRVM_G_STRING(OFS_PARM1), src_client, true);
+       Cmd_ExecuteString(cmd_serverfromclient, PRVM_G_STRING(OFS_PARM1), src_client, true);
        host_client = temp_client;
 }
 
@@ -2879,7 +2879,7 @@ qbool SV_VM_ConsoleCommand (const char *text)
 static void VM_SV_registercommand (prvm_prog_t *prog)
 {
        VM_SAFEPARMCOUNT(1, VM_SV_registercmd);
-       if(!Cmd_Exists(&cmd_server, PRVM_G_STRING(OFS_PARM0)))
+       if(!Cmd_Exists(cmd_server, PRVM_G_STRING(OFS_PARM0)))
                Cmd_AddCommand(CF_SERVER, PRVM_G_STRING(OFS_PARM0), NULL, "console command created by QuakeC");
 }
 
index e849a9bcc2c3c571c550a5d741b5a08876bafd1e..e9b76f4bc5a0800b2a777609ca960e94e6567fbb 100644 (file)
@@ -48,10 +48,10 @@ char *Sys_TimeString(const char *timeformat)
 void Sys_Quit (int returnvalue)
 {
        // Unlock mutexes because the quit command may jump directly here, causing a deadlock
-       if ((&cmd_client)->cbuf->lock)
-               Cbuf_Unlock((&cmd_client)->cbuf);
-       if ((&cmd_server)->cbuf->lock)
-               Cbuf_Unlock((&cmd_server)->cbuf);
+       if ((cmd_client)->cbuf->lock)
+               Cbuf_Unlock((cmd_client)->cbuf);
+       if ((cmd_server)->cbuf->lock)
+               Cbuf_Unlock((cmd_server)->cbuf);
        SV_UnlockThreadMutex();
        TaskQueue_Frame(true);
 
index 97e54735ed4c8a291af8ade55a46e3153741b650..23e9fe9cab003c16fc8372d5df457e364373d309 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -894,7 +894,7 @@ static void IN_Move_TouchScreen_Quake(void)
                if (!VID_ShowingKeyboard())
                {
                        // user entered a command, close the console now
-                       Con_ToggleConsole_f(&cmd_client);
+                       Con_ToggleConsole_f(cmd_client);
                }
                VID_TouchscreenArea( 0,   0,   0,   0,   0, NULL                         , 0.0f, NULL, NULL, &buttons[15], (keynum_t)0, NULL, 0, 0, 0, true);
                VID_TouchscreenArea( 0,   0,   0,   0,   0, NULL                         , 0.0f, NULL, move, &buttons[0], K_MOUSE4, NULL, 0, 0, 0, true);
@@ -1179,7 +1179,7 @@ void Sys_SendKeyEvents( void )
                                                        // so, let's better queue it for next frame
                                                        if(!sdl_needs_restart)
                                                        {
-                                                               Cbuf_AddText(&cmd_client, "\nr_restart\n");
+                                                               Cbuf_AddText(cmd_client, "\nr_restart\n");
                                                                sdl_needs_restart = true;
                                                        }
 #endif