]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
CLVM: remove cruft
authorbones_was_here <bones_was_here@xonotic.au>
Mon, 26 Feb 2024 11:40:17 +0000 (21:40 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Mon, 26 Feb 2024 16:06:25 +0000 (02:06 +1000)
Having more than one var tracking one state can lead to bugs.

Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
cl_input.c
cl_main.c
cl_screen.c
client.h
csprogs.c
mvm_cmds.c
prvm_cmds.c
prvm_cmds.h
svvm_cmds.c

index 8e0e96f600ea9ed3a1676ec85cdb1240ce7492b1..f41c4c91b757bddecfaaac8e7f3df427c4fd318b 100644 (file)
@@ -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)
                {
index efc6ba4da7fdea21fc9a8204263006d620f25883..a2c614ea51aad29018a641fc1d37e0ac41c6d78b 100644 (file)
--- 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();
index fd5188eb3386ebcb2168abb21cdc43b100d8204d..203322263ebdd0f09715a48a001cc3acbe0bbe19 100644 (file)
@@ -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
                {
index bed786369e4ae230a0c9a8ae34bdeede4eef0172..fc44f3483f8d1b2747b1a1b155775502e8d58b7b 100644 (file)
--- 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;
index 14946c82a3540233050f249e12a8106d3de6bf28..1025216fd4a379fd5761e369bf575033de46211b 100644 (file)
--- 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)
index 8e63f37a563830c3d52208de545795029744974f..86ea2fd346e38ca55a5256cb55191085ace45dd0 100644 (file)
@@ -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");
 }
 
 /*
index f60d2d4e5b28b1d60332ddea881865035329fa28..1fc2e58119ce9dcf73a5b6d35eed28842ffc4b33 100644 (file)
@@ -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)
index 217d67f1c7d1dbf5e7f1400c2cadaeed67fb9850..efc70f7db4dd8b2db45f5f3c9c6102a6ee2583a5 100644 (file)
@@ -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);
index ce0a4bf90dd071346e4cafec1bcb9d40c641be26..8a6a81ecb2aac735b999906c3df3f39fce02f1f7 100644 (file)
@@ -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)