Added support for assigning coop and deathmatch global float values to optional CSQC...
authordresk <dresk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 10 Aug 2007 18:09:01 +0000 (18:09 +0000)
committerdresk <dresk@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 10 Aug 2007 18:09:01 +0000 (18:09 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7516 d7cf8633-e32d-0410-b094-e92efae38249

csprogs.c
progsvm.h
prvm_edict.c

index 06e1a33..bb51c50 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -409,6 +409,43 @@ void CL_VM_UpdateIntermissionState (int intermission)
                CSQC_END
        }
 }
+void CL_VM_UpdateCoopDeathmatchGlobals (int gametype)
+{
+       // Avoid global names for clean(er) coding
+       int localcoop;
+       int localdeathmatch;
+
+       prvm_eval_t *val;
+       if(cl.csqc_loaded)
+       {
+               if(gametype == GAME_COOP)
+               {
+                       localcoop = 1;
+                       localdeathmatch = 0;
+               }
+               else
+               if(gametype == GAME_DEATHMATCH)
+               {
+                       localcoop = 0;
+                       localdeathmatch = 1;
+               }
+               else
+               {
+                       // How did the ServerInfo send an unknown gametype?
+                       // Better just assign the globals as 0...
+                       localcoop = 0;
+                       localdeathmatch = 0;
+               }
+               CSQC_BEGIN
+               val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.coop);
+               if(val)
+                       val->_float = localcoop;
+               val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.deathmatch);
+               if(val)
+                       val->_float = localdeathmatch;
+               CSQC_END
+       }
+}
 
 float CL_VM_Event (float event)                //[515]: needed ? I'd say "YES", but don't know for what :D
 {
@@ -660,6 +697,9 @@ void CL_VM_Init (void)
 
        cl.csqc_vidvars.drawcrosshair = false;
        cl.csqc_vidvars.drawenginesbar = false;
+
+       // Update Coop and Deathmatch Globals (at this point the client knows them from ServerInfo)
+       CL_VM_UpdateCoopDeathmatchGlobals(cl.gametype);
 }
 
 void CL_VM_ShutDown (void)
index c3346e3..727fa40 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -237,6 +237,8 @@ typedef struct prvm_prog_globaloffsets_s
        int trace_dphittexturename; // ssqc / csqc
        int trace_dpstartcontents; // ssqc / csqc
        int intermission; // csqc
+       int coop; // csqc
+       int deathmatch; // csqc
 }
 prvm_prog_globaloffsets_t;
 
index 555eaa2..50bd175 100644 (file)
@@ -1441,6 +1441,8 @@ void PRVM_FindOffsets(void)
        prog->globaloffsets.trace_dphittexturename        = PRVM_ED_FindGlobalOffset("trace_dphittexturename");
        prog->globaloffsets.trace_dpstartcontents         = PRVM_ED_FindGlobalOffset("trace_dpstartcontents");
        prog->globaloffsets.intermission                  = PRVM_ED_FindGlobalOffset("intermission");
+       prog->globaloffsets.coop                          = PRVM_ED_FindGlobalOffset("coop");
+       prog->globaloffsets.deathmatch                    = PRVM_ED_FindGlobalOffset("deathmatch");
 
        // menu qc only uses some functions, nothing else
        prog->funcoffsets.m_display                       = PRVM_ED_FindFunctionOffset("m_display");