From: bones_was_here Date: Mon, 26 Feb 2024 11:40:17 +0000 (+1000) Subject: CLVM: remove cruft X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=db19154403c850ba097cc722b53f2ab3067e0c8c;p=xonotic%2Fdarkplaces.git CLVM: remove cruft Having more than one var tracking one state can lead to bugs. Signed-off-by: bones_was_here --- diff --git a/cl_input.c b/cl_input.c index 8e0e96f6..f41c4c91 100644 --- a/cl_input.c +++ b/cl_input.c @@ -527,7 +527,7 @@ void CL_Input (void) IN_Move (); // send mouse move to csqc - if (cl.csqc_loaded && cl_csqc_generatemousemoveevents.integer) + if (CLVM_prog->loaded && cl_csqc_generatemousemoveevents.integer) { if (cl.csqc_wantsmousemove) { diff --git a/cl_main.c b/cl_main.c index efc6ba4d..a2c614ea 100644 --- a/cl_main.c +++ b/cl_main.c @@ -2091,7 +2091,7 @@ void CL_UpdateWorld(void) CL_UpdateViewModel(); // when csqc is loaded, it will call this in CSQC_UpdateView - if (!cl.csqc_loaded) + if (!CLVM_prog->loaded) { // clear the CL_Mesh_Scene() used for some engine effects CL_MeshEntities_Scene_Clear(); diff --git a/cl_screen.c b/cl_screen.c index fd5188eb..20332226 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -1682,7 +1682,7 @@ static void SCR_DrawScreen (void) // if CSQC is loaded, it is required to provide the CSQC_UpdateView function, // and won't render a view if it does not call that. - if (cl.csqc_loaded) + if (CLVM_prog->loaded) CL_VM_UpdateView(r_stereo_side ? 0.0 : max(0.0, cl.time - cl.oldtime)); else { diff --git a/client.h b/client.h index bed78636..fc44f348 100644 --- a/client.h +++ b/client.h @@ -1109,7 +1109,6 @@ typedef struct client_state_s // csqc stuff: // server entity number corresponding to a clientside entity unsigned short csqc_server2csqcentitynumber[MAX_EDICTS]; - qbool csqc_loaded; vec3_t csqc_vieworigin; vec3_t csqc_viewangles; vec3_t csqc_vieworiginfromengine; diff --git a/csprogs.c b/csprogs.c index 14946c82..1025216f 100644 --- a/csprogs.c +++ b/csprogs.c @@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void CL_VM_PreventInformationLeaks(void) { prvm_prog_t *prog = CLVM_prog; - if(!cl.csqc_loaded) + if(!prog->loaded) return; CSQC_BEGIN VM_ClearTraceGlobals(prog); @@ -218,7 +218,7 @@ prvm_required_field_t cl_reqglobals[] = void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin) { prvm_prog_t *prog = CLVM_prog; - if(cl.csqc_loaded) + if(prog->loaded) { CSQC_BEGIN PRVM_clientglobalfloat(dmg_take) = dmg_take; @@ -231,7 +231,7 @@ void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin) void CSQC_UpdateNetworkTimes(double newtime, double oldtime) { prvm_prog_t *prog = CLVM_prog; - if(!cl.csqc_loaded) + if(!prog->loaded) return; CSQC_BEGIN PRVM_clientglobalfloat(servertime) = newtime; @@ -459,7 +459,7 @@ qbool CL_VM_InputEvent (int eventtype, float x, float y) prvm_prog_t *prog = CLVM_prog; qbool r; - if(!cl.csqc_loaded) + if(!prog->loaded) return false; CSQC_BEGIN @@ -489,7 +489,7 @@ qbool CL_VM_UpdateView (double frametime) emptyvector[1] = 0; emptyvector[2] = 0; // vec3_t oldangles; - if(!cl.csqc_loaded) + if(!prog->loaded) return false; R_TimeReport("pre-UpdateView"); CSQC_BEGIN @@ -532,7 +532,7 @@ qbool CL_VM_UpdateView (double frametime) qbool CL_VM_ConsoleCommand(const char *text, size_t textlen) { prvm_prog_t *prog = CLVM_prog; - return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.CSQC_ConsoleCommand, false, cl.csqc_server2csqcentitynumber[cl.playerentity], cl.time, cl.csqc_loaded, "QC function CSQC_ConsoleCommand is missing"); + return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.CSQC_ConsoleCommand, false, cl.csqc_server2csqcentitynumber[cl.playerentity], cl.time, "QC function CSQC_ConsoleCommand is missing"); } qbool CL_VM_Parse_TempEntity (void) @@ -540,7 +540,7 @@ qbool CL_VM_Parse_TempEntity (void) prvm_prog_t *prog = CLVM_prog; int t; qbool r = false; - if(!cl.csqc_loaded) + if(!prog->loaded) return false; CSQC_BEGIN if(PRVM_clientfunction(CSQC_Parse_TempEntity)) @@ -580,7 +580,7 @@ void CL_VM_Parse_StuffCmd(const char *msg, size_t msg_len) return; } - if(!cl.csqc_loaded) + if(!prog->loaded) { Cbuf_AddText(cmd_local, msg); return; @@ -619,7 +619,7 @@ void CSQC_AddPrintText(const char *msg, size_t msg_len) size_t writebytes = min(msg_len + 1, MAX_INPUTLINE - cl.csqc_printtextbuf_len); CSQC_BEGIN - if(cl.csqc_loaded && PRVM_clientfunction(CSQC_Parse_Print)) + if(prog->loaded && PRVM_clientfunction(CSQC_Parse_Print)) { if(msg[msg_len - 1] != '\n' && msg[msg_len - 1] != '\r') { @@ -652,7 +652,7 @@ void CL_VM_Parse_CenterPrint(const char *msg, size_t msg_len) prvm_prog_t *prog = CLVM_prog; int restorevm_tempstringsbuf_cursize; CSQC_BEGIN - if(cl.csqc_loaded && PRVM_clientfunction(CSQC_Parse_CenterPrint)) + if(prog->loaded && PRVM_clientfunction(CSQC_Parse_CenterPrint)) { PRVM_clientglobalfloat(time) = cl.time; PRVM_clientglobaledict(self) = cl.csqc_server2csqcentitynumber[cl.playerentity]; @@ -669,7 +669,7 @@ void CL_VM_Parse_CenterPrint(const char *msg, size_t msg_len) void CL_VM_UpdateIntermissionState (int intermission) { prvm_prog_t *prog = CLVM_prog; - if(cl.csqc_loaded) + if(prog->loaded) { CSQC_BEGIN PRVM_clientglobalfloat(intermission) = intermission; @@ -679,7 +679,7 @@ void CL_VM_UpdateIntermissionState (int intermission) void CL_VM_UpdateShowingScoresState (int showingscores) { prvm_prog_t *prog = CLVM_prog; - if(cl.csqc_loaded) + if(prog->loaded) { CSQC_BEGIN PRVM_clientglobalfloat(sb_showscores) = showingscores; @@ -690,7 +690,7 @@ qbool CL_VM_Event_Sound(int sound_num, float fvolume, int channel, float attenua { prvm_prog_t *prog = CLVM_prog; qbool r = false; - if(cl.csqc_loaded) + if(prog->loaded) { CSQC_BEGIN if(PRVM_clientfunction(CSQC_Event_Sound)) @@ -720,7 +720,7 @@ static void CL_VM_UpdateCoopDeathmatchGlobals (int gametype) int localcoop; int localdeathmatch; - if(cl.csqc_loaded) + if(prog->loaded) { if(gametype == GAME_COOP) { @@ -751,7 +751,7 @@ static float CL_VM_Event (float event) //[515]: needed ? I'd say "YES", but don { prvm_prog_t *prog = CLVM_prog; float r = 0; - if(!cl.csqc_loaded) + if(!prog->loaded) return 0; CSQC_BEGIN if(PRVM_clientfunction(CSQC_Event)) @@ -771,7 +771,7 @@ void CSQC_ReadEntities (void) { prvm_prog_t *prog = CLVM_prog; unsigned short entnum, oldself, realentnum; - if(!cl.csqc_loaded) + if(!prog->loaded) { Host_Error ("CSQC_ReadEntities: CSQC is not loaded"); return; @@ -1107,8 +1107,6 @@ void CL_VM_Init (void) // Once CSQC_Init was called, we consider csqc code fully initialized. prog->inittime = host.realtime; - cl.csqc_loaded = true; - cl.csqc_vidvars.drawcrosshair = false; cl.csqc_vidvars.drawenginesbar = false; @@ -1122,8 +1120,6 @@ void CL_VM_ShutDown (void) Cmd_ClearCSQCCommands(cmd_local); //Cvar_SetValueQuick(&csqc_progcrc, -1); //Cvar_SetValueQuick(&csqc_progsize, -1); - if(!cl.csqc_loaded) - return; CSQC_BEGIN if (prog->loaded) { @@ -1135,7 +1131,6 @@ CSQC_BEGIN PRVM_Prog_Reset(prog); CSQC_END Con_DPrint("CSQC ^1unloaded\n"); - cl.csqc_loaded = false; } qbool CL_VM_GetEntitySoundOrigin(int entnum, vec3_t out) diff --git a/mvm_cmds.c b/mvm_cmds.c index 8e63f37a..86ea2fd3 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -56,7 +56,7 @@ NULL qbool MP_ConsoleCommand(const char *text, size_t textlen) { prvm_prog_t *prog = MVM_prog; - return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.GameCommand, false, -1, 0, prog->loaded, "QC function GameCommand is missing"); + return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.GameCommand, false, -1, 0, "QC function GameCommand is missing"); } /* diff --git a/prvm_cmds.c b/prvm_cmds.c index f60d2d4e..1fc2e581 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -65,13 +65,13 @@ void VM_CheckEmptyString(prvm_prog_t *prog, const char *s) prog->error_cmd("%s: Bad string", prog->name); } -qbool PRVM_ConsoleCommand(prvm_prog_t *prog, const char *text, size_t textlen, int *func, qbool preserve_self, int curself, double ptime, qbool prog_loaded, const char *error_message) +qbool PRVM_ConsoleCommand(prvm_prog_t *prog, const char *text, size_t textlen, int *func, qbool preserve_self, int curself, double ptime, const char *error_message) { int restorevm_tempstringsbuf_cursize; int save_self = 0; // hush compiler warning qbool r = false; - if(!prog_loaded) + if(!prog->loaded) return false; if(func) diff --git a/prvm_cmds.h b/prvm_cmds.h index 217d67f1..efc70f7d 100644 --- a/prvm_cmds.h +++ b/prvm_cmds.h @@ -218,7 +218,7 @@ float getserverlistindexforkey(string key) void VM_CheckEmptyString (prvm_prog_t *prog, const char *s); /// Returns the length of the *out string excluding the \0 terminator. size_t VM_VarString(prvm_prog_t *prog, int first, char *out, size_t outsize); -qbool PRVM_ConsoleCommand(prvm_prog_t *prog, const char *text, size_t textlen, int *func, qbool preserve_self, int curself, double ptime, qbool prog_loaded, const char *error_message); +qbool PRVM_ConsoleCommand(prvm_prog_t *prog, const char *text, size_t textlen, int *func, qbool preserve_self, int curself, double ptime, const char *error_message); prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, unsigned flags, const char *format); void BufStr_Set(prvm_prog_t *prog, prvm_stringbuffer_t *stringbuffer, int strindex, const char *str); void BufStr_Del(prvm_prog_t *prog, prvm_stringbuffer_t *stringbuffer); diff --git a/svvm_cmds.c b/svvm_cmds.c index ce0a4bf9..8a6a81ec 100644 --- a/svvm_cmds.c +++ b/svvm_cmds.c @@ -2928,7 +2928,7 @@ static void VM_SV_pointparticles(prvm_prog_t *prog) qbool SV_VM_ConsoleCommand(const char *text, size_t textlen) { prvm_prog_t *prog = SVVM_prog; - return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.ConsoleCmd, true, PRVM_EDICT_TO_PROG(sv.world.prog->edicts), sv.time, !(!sv.active || !prog || !prog->loaded), "QC function ConsoleCmd is missing"); + return PRVM_ConsoleCommand(prog, text, textlen, &prog->funcoffsets.ConsoleCmd, true, PRVM_EDICT_TO_PROG(sv.world.prog->edicts), sv.time, "QC function ConsoleCmd is missing"); } // #352 void(string cmdname) registercommand (EXT_CSQC)