CL_LinkEdict(e);
}
-// #8 void(entity e, float chan, string samp, float volume, float atten) sound
+// #8 void(entity e, float chan, string samp, float volume, float atten[, float pitchchange[, float flags]]) sound
static void VM_CL_sound (prvm_prog_t *prog)
{
const char *sample;
float volume;
float attenuation;
float pitchchange;
+ float startposition;
/*
int flags;
*/
flags = PRVM_G_FLOAT(OFS_PARM6);
*/
+ // sound_starttime exists instead of sound_startposition because in a
+ // networking sense you might not know when something is being received,
+ // so making sounds match up in sync would be impossible if relative
+ // position was sent
+ if (PRVM_clientglobalfloat(sound_starttime))
+ startposition = cl.time - PRVM_clientglobalfloat(sound_starttime);
+ else
+ startposition = 0;
+
channel = CHAN_USER2ENGINE(channel);
if (!IS_CHAN(channel))
// We want to, in a later extension, expose more flags.
CL_VM_GetEntitySoundOrigin(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), org);
- S_StartSound_StartPosition_Flags(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), org, volume, attenuation, 0, 0, pitchchange > 0.0f ? pitchchange * 0.01f : 1.0f);
+ S_StartSound_StartPosition_Flags(MAX_EDICTS + PRVM_NUM_FOR_EDICT(entity), channel, S_FindName(sample), org, volume, attenuation, startposition, 0, pitchchange > 0.0f ? pitchchange * 0.01f : 1.0f);
}
// #483 void(vector origin, string sample, float volume, float attenuation) pointsound
PRVM_DECLARE_clientglobalvector(view_angles)
PRVM_DECLARE_clientglobalvector(view_punchangle)
PRVM_DECLARE_clientglobalvector(view_punchvector)
+PRVM_DECLARE_clientglobalfloat(sound_starttime)
PRVM_DECLARE_field(SendEntity)
PRVM_DECLARE_field(SendFlags)
PRVM_DECLARE_field(Version)
PRVM_DECLARE_global(view_punchvector)
PRVM_DECLARE_global(world)
PRVM_DECLARE_global(worldstatus)
+PRVM_DECLARE_global(sound_starttime)
PRVM_DECLARE_menufieldstring(classname)
PRVM_DECLARE_menufunction(GameCommand)
PRVM_DECLARE_menufunction(URI_Get_Callback)