]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Added optional CSQC function CSQC_Event_Sound with the following parameters : float...
authordresk <dresk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 16 Sep 2007 23:20:50 +0000 (23:20 +0000)
committerdresk <dresk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 16 Sep 2007 23:20:50 +0000 (23:20 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7565 d7cf8633-e32d-0410-b094-e92efae38249

cl_parse.c
csprogs.c
progsvm.h
prvm_edict.c

index 1dd0aed4947087e61613672c4433b0f0502bb3c0..e0c102e5762454b93cd3d34144fd432e96b62942 100644 (file)
@@ -184,6 +184,7 @@ void QW_CL_StartUpload(unsigned char *data, int size);
 //static qboolean QW_CL_IsUploading(void);
 static void QW_CL_StopUpload(void);
 void CL_VM_UpdateIntermissionState(int intermission);
+qboolean CL_VM_Event_Sound(int sound_num, int volume, int channel, float attenuation, int ent, vec3_t pos);
 
 /*
 ==================
@@ -267,7 +268,8 @@ void CL_ParseStartSoundPacket(int largesoundindex)
        if (ent >= cl.max_entities)
                CL_ExpandEntities(ent);
 
-       S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0f, attenuation);
+       if( !CL_VM_Event_Sound(sound_num, volume / 255.0f, channel, attenuation, ent, pos) )
+               S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0f, attenuation);
 }
 
 /*
index 518f28e7ca893fdd0ff956435e2813830fa44ad5..90aeb940708774b87902391b7118ac60b68ecaed 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
@@ -448,6 +449,29 @@ void CL_VM_UpdateShowingScoresState (int 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
index 43b34bee8540f8408c0a595d2272e1bc2a2ad942..ff2c3bbff38df24b8fcbfc54b0148887b4ea986c 100644 (file)
--- a/progsvm.h
+++ b/progsvm.h
@@ -255,6 +255,7 @@ typedef struct prvm_prog_funcoffsets_s
        func_t CSQC_Ent_Remove; // csqc
        func_t CSQC_Ent_Update; // csqc
        func_t CSQC_Event; // csqc [515]: engine call this for its own needs so csqc can do some things according to what engine it's running on.  example: to say about edicts increase, whatever...
+       func_t CSQC_Event_Sound; // csqc : called by engine when an incoming sound packet arrives so CSQC can act on it
        func_t CSQC_Init; // csqc
        func_t CSQC_InputEvent; // csqc
        func_t CSQC_Parse_CenterPrint; // csqc
index 02d15dbadd7ff413bc6c88aa2615128479c7b5d4..4d4be14b0027ac045ef741b2c07d15e3f150d7fb 100644 (file)
@@ -1418,6 +1418,7 @@ void PRVM_FindOffsets(void)
        prog->funcoffsets.CSQC_Ent_Remove                 = PRVM_ED_FindFunctionOffset("CSQC_Ent_Remove");
        prog->funcoffsets.CSQC_Ent_Update                 = PRVM_ED_FindFunctionOffset("CSQC_Ent_Update");
        prog->funcoffsets.CSQC_Event                      = PRVM_ED_FindFunctionOffset("CSQC_Event");
+       prog->funcoffsets.CSQC_Event_Sound                = PRVM_ED_FindFunctionOffset("CSQC_Event_Sound");
        prog->funcoffsets.CSQC_Init                       = PRVM_ED_FindFunctionOffset("CSQC_Init");
        prog->funcoffsets.CSQC_InputEvent                 = PRVM_ED_FindFunctionOffset("CSQC_InputEvent");
        prog->funcoffsets.CSQC_Parse_CenterPrint          = PRVM_ED_FindFunctionOffset("CSQC_Parse_CenterPrint");