From: bones_was_here Date: Tue, 2 Apr 2024 07:03:40 +0000 (+1000) Subject: menuqc: declare localcmd() and deduplicate it X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=812b494bd9c125b5f4d4e378d4a688d3ba51f706;p=xonotic%2Fdarkplaces.git menuqc: declare localcmd() and deduplicate it It's awkward having a different name for the same builtin in a different VM, Xonotic was working around it (for code sharing) with a macro. --- diff --git a/clvm_cmds.c b/clvm_cmds.c index a08bb6ba..f3e986ed 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -5028,7 +5028,7 @@ NULL, // #42 (QUAKE) VM_fabs, // #43 float(float f) fabs (QUAKE) NULL, // #44 vector(entity e, float speed) aim (QUAKE) VM_cvar, // #45 float(string s) cvar (QUAKE) -VM_localcmd_local, // #46 void(string s) localcmd (QUAKE) +VM_localcmd, // #46 void(string s) localcmd (QUAKE) VM_nextent, // #47 entity(entity e) nextent (QUAKE) VM_CL_particle, // #48 void(vector o, vector d, float color, float count) particle (QUAKE) VM_changeyaw, // #49 void() ChangeYaw (QUAKE) diff --git a/dpdefs/menudefs.qc b/dpdefs/menudefs.qc index b987491b..93bdff12 100644 --- a/dpdefs/menudefs.qc +++ b/dpdefs/menudefs.qc @@ -182,6 +182,7 @@ vector vectoangles(vector v) = #11; float random(void) = #12; // Returns a random number > 0 and < 1 void cmd(string command, ...) = #13; +void localcmd(string command, ...) = #13; // cvar cmds diff --git a/mvm_cmds.c b/mvm_cmds.c index 86ea2fd3..41c0d1bb 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -1075,7 +1075,7 @@ VM_vlen, // #9 VM_vectoyaw, // #10 VM_vectoangles, // #11 VM_random, // #12 -VM_localcmd_local, // #13 +VM_localcmd, // #13 VM_cvar, // #14 VM_cvar_set, // #15 VM_dprint, // #16 diff --git a/prvm_cmds.c b/prvm_cmds.c index 6a19baff..1fb432c9 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -667,36 +667,18 @@ void VM_break(prvm_prog_t *prog) /* ================= -VM_localcmd_local +VM_localcmd -Sends text over to the client's execution buffer +Appends text to the command buffer [localcmd (string, ...) or] cmd (string, ...) ================= */ -void VM_localcmd_local(prvm_prog_t *prog) +void VM_localcmd(prvm_prog_t *prog) { char string[VM_TEMPSTRING_MAXSIZE]; - VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd_local); - VM_VarString(prog, 0, string, sizeof(string)); - Cbuf_AddText(cmd_local, string); -} - -/* -================= -VM_localcmd_server - -Sends text over to the server's execution buffer - -[localcmd (string, ...) or] -cmd (string, ...) -================= -*/ -void VM_localcmd_server(prvm_prog_t *prog) -{ - char string[VM_TEMPSTRING_MAXSIZE]; - VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd_server); + VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd); VM_VarString(prog, 0, string, sizeof(string)); Cbuf_AddText(cmd_local, string); } diff --git a/prvm_cmds.h b/prvm_cmds.h index efc70f7d..292e8f55 100644 --- a/prvm_cmds.h +++ b/prvm_cmds.h @@ -239,8 +239,7 @@ void VM_vectoangles (prvm_prog_t *prog); void VM_random (prvm_prog_t *prog); void VM_localsound(prvm_prog_t *prog); void VM_break (prvm_prog_t *prog); -void VM_localcmd_local(prvm_prog_t *prog); -void VM_localcmd_server(prvm_prog_t *prog); +void VM_localcmd(prvm_prog_t *prog); void VM_cvar (prvm_prog_t *prog); void VM_cvar_string(prvm_prog_t *prog); void VM_cvar_type (prvm_prog_t *prog); diff --git a/svvm_cmds.c b/svvm_cmds.c index 8a6a81ec..4ad07559 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -3310,7 +3310,7 @@ NULL, // #42 (QUAKE) VM_fabs, // #43 float(float f) fabs (QUAKE) VM_SV_aim, // #44 vector(entity e, float speed) aim (QUAKE) VM_cvar, // #45 float(string s) cvar (QUAKE) -VM_localcmd_server, // #46 void(string s) localcmd (QUAKE) +VM_localcmd, // #46 void(string s) localcmd (QUAKE) VM_nextent, // #47 entity(entity e) nextent (QUAKE) VM_SV_particle, // #48 void(vector o, vector d, float color, float count) particle (QUAKE) VM_changeyaw, // #49 void() ChangeYaw (QUAKE)