]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - csprogs.c
XPM support for X11; WM_CLASS and WM_COMMAND are now set too
[xonotic/darkplaces.git] / csprogs.c
index bb51c500407901a6684019106685cb94aa4169de..6a0bf4c841a0ce2c9200d762e2636ba6b850ef05 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -3,6 +3,7 @@
 #include "clprogdefs.h"
 #include "csprogs.h"
 #include "cl_collision.h"
+#include "snd_main.h"
 
 //============================================================================
 // Client prog handling
@@ -44,7 +45,28 @@ void CL_VM_Error (const char *format, ...)   //[515]: hope it will be never execut
 //     Host_AbortCurrentFrame();       //[515]: hmmm... if server says it needs csqc then client MUST disconnect
        Host_Error(va("CL_VM_Error: %s", errorstring));
 }
-
+void CL_VM_UpdateDmgGlobals (int dmg_take, int dmg_save, vec3_t dmg_origin)
+{
+       prvm_eval_t *val;
+       if(cl.csqc_loaded)
+       {
+               CSQC_BEGIN
+               val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.dmg_take);
+               if(val)
+                       val->_float = dmg_take;
+               val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.dmg_save);
+               if(val)
+                       val->_float = dmg_save;
+               val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.dmg_origin);
+               if(val)
+               {
+                       val->vector[0] = dmg_origin[0];
+                       val->vector[1] = dmg_origin[1];
+                       val->vector[2] = dmg_origin[2];
+               }
+               CSQC_END
+       }
+}
 //[515]: set globals before calling R_UpdateView, WEIRD CRAP
 static void CSQC_SetGlobals (void)
 {
@@ -60,6 +82,13 @@ static void CSQC_SetGlobals (void)
                VectorSet(prog->globals.client->input_movevalues, cl.movecmd[0].forwardmove, cl.movecmd[0].sidemove, cl.movecmd[0].upmove);
                //VectorCopy(cl.movement_origin, cl.csqc_origin);
                Matrix4x4_OriginFromMatrix(&cl.entities[cl.viewentity].render.matrix, cl.csqc_origin);
+
+               // LordHavoc: Spike says not to do this, but without pmove_org the
+               // CSQC is useless as it can't alter the view origin without
+               // completely replacing it
+               VectorCopy(cl.csqc_origin, prog->globals.client->pmove_org);
+               VectorCopy(cl.velocity, prog->globals.client->pmove_vel);
+
                if ((val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.view_angles)))
                        VectorCopy(cl.viewangles, val->vector);
                prog->globals.client->maxclients = cl.maxclients;
@@ -232,6 +261,10 @@ qboolean CL_VM_InputEvent (qboolean pressed, int key)
 
 qboolean CL_VM_UpdateView (void)
 {
+       vec3_t emptyvector;
+       emptyvector[0] = 0;
+       emptyvector[1] = 0;
+       emptyvector[2] = 0;
 //     vec3_t oldangles;
        if(!cl.csqc_loaded)
                return false;
@@ -245,6 +278,8 @@ qboolean CL_VM_UpdateView (void)
                r_refdef.numlights = 0;
                PRVM_ExecuteProgram(prog->funcoffsets.CSQC_UpdateView, "QC function CSQC_UpdateView is missing");
                //VectorCopy(oldangles, cl.viewangles);
+               // Dresk : Reset Dmg Globals Here
+               CL_VM_UpdateDmgGlobals(0, 0, emptyvector);
        CSQC_END
        return true;
 }
@@ -409,6 +444,41 @@ void CL_VM_UpdateIntermissionState (int intermission)
                CSQC_END
        }
 }
+void CL_VM_UpdateShowingScoresState (int showingscores)
+{
+       prvm_eval_t *val;
+       if(cl.csqc_loaded)
+       {
+               CSQC_BEGIN
+               val = PRVM_GLOBALFIELDVALUE(prog->globaloffsets.sb_showscores);
+               if(val)
+                       val->_float = showingscores;
+               CSQC_END
+       }
+}
+qboolean CL_VM_Event_Sound(int sound_num, int volume, int channel, float attenuation, int ent, vec3_t pos)
+{
+       qboolean r = false;
+       if(cl.csqc_loaded)
+       {
+               CSQC_BEGIN
+               if(prog->funcoffsets.CSQC_Event_Sound)
+               {
+                       prog->globals.client->time = cl.time;
+                       PRVM_G_FLOAT(OFS_PARM0) = ent;
+                       PRVM_G_FLOAT(OFS_PARM1) = channel;
+                       PRVM_G_INT(OFS_PARM2) = PRVM_SetTempString(cl.sound_name[sound_num] );
+                       PRVM_G_FLOAT(OFS_PARM3) = volume;
+                       PRVM_G_FLOAT(OFS_PARM4) = attenuation;
+                       VectorCopy(pos, PRVM_G_VECTOR(OFS_PARM5) );
+                       PRVM_ExecuteProgram(prog->funcoffsets.CSQC_Event_Sound, "QC function CSQC_Event_Sound is missing");
+                       r = CSQC_RETURNVAL;
+               }
+               CSQC_END
+       }
+
+       return r;
+}
 void CL_VM_UpdateCoopDeathmatchGlobals (int gametype)
 {
        // Avoid global names for clean(er) coding
@@ -446,7 +516,6 @@ void CL_VM_UpdateCoopDeathmatchGlobals (int gametype)
                CSQC_END
        }
 }
-
 float CL_VM_Event (float event)                //[515]: needed ? I'd say "YES", but don't know for what :D
 {
        float r = 0;