X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=clvm_cmds.c;h=6ca2749c89746e45e64f2fe6c918ce2e9c839a29;hb=64cdec7e5861924eb9aff7df36e419884e975c44;hp=f7de708f53b735f68354448446e5913f017f5be2;hpb=420af30827cfa5581169ce619316cc9b3f9f3d4c;p=xonotic%2Fdarkplaces.git diff --git a/clvm_cmds.c b/clvm_cmds.c index f7de708f..6ca2749c 100644 --- a/clvm_cmds.c +++ b/clvm_cmds.c @@ -165,7 +165,7 @@ static void VM_CL_setsize (prvm_prog_t *prog) 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; @@ -174,6 +174,7 @@ static void VM_CL_sound (prvm_prog_t *prog) float volume; float attenuation; float pitchchange; + float startposition; int flags; vec3_t org; @@ -201,12 +202,23 @@ static void VM_CL_sound (prvm_prog_t *prog) pitchchange = 0; else pitchchange = PRVM_G_FLOAT(OFS_PARM5); - // ignoring prog->argc < 7 for now (no flags supported yet) if (prog->argc < 7) flags = 0; else - flags = PRVM_G_FLOAT(OFS_PARM6); + { + // LordHavoc: we only let the qc set certain flags, others are off-limits + flags = (int)PRVM_G_FLOAT(OFS_PARM6) & (CHANNELFLAG_RELIABLE | CHANNELFLAG_FORCELOOP | CHANNELFLAG_PAUSED); + } + + // 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); @@ -216,12 +228,8 @@ static void VM_CL_sound (prvm_prog_t *prog) return; } - // TODO currently the only flag defined in the interface is - // SOUNDFLAG_RELIABLE. This one makes no sense at all from CSQC. - // 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, flags, pitchchange > 0.0f ? pitchchange * 0.01f : 1.0f); } // #483 void(vector origin, string sample, float volume, float attenuation) pointsound @@ -447,22 +455,6 @@ static void VM_CL_precache_model (prvm_prog_t *prog) VM_Warning(prog, "VM_CL_precache_model: model \"%s\" not found\n", name); } -static int CSQC_EntitiesInBox (prvm_prog_t *prog, vec3_t mins, vec3_t maxs, int maxlist, prvm_edict_t **list) -{ - prvm_edict_t *ent; - int i, k; - - ent = PRVM_NEXT_EDICT(prog->edicts); - for(k=0,i=1; inum_edicts ;i++, ent = PRVM_NEXT_EDICT(ent)) - { - if (ent->priv.required->free) - continue; - if(BoxesOverlap(mins, maxs, PRVM_clientedictvector(ent, absmin), PRVM_clientedictvector(ent, absmax))) - list[k++] = ent; - } - return k; -} - // #22 entity(vector org, float rad) findradius static void VM_CL_findradius (prvm_prog_t *prog) { @@ -494,7 +486,7 @@ static void VM_CL_findradius (prvm_prog_t *prog) maxs[0] = org[0] + (radius + 1); maxs[1] = org[1] + (radius + 1); maxs[2] = org[2] + (radius + 1); - numtouchedicts = CSQC_EntitiesInBox(prog, mins, maxs, MAX_EDICTS, touchedicts); + numtouchedicts = World_EntitiesInBox(&cl.world, mins, maxs, MAX_EDICTS, touchedicts); if (numtouchedicts > MAX_EDICTS) { // this never happens //[515]: for what then ?