// Start a sound effect
// =======================================================================
-void S_PlaySfxOnChannel (sfx_t *sfx, channel_t *target_chan, unsigned int flags, vec3_t origin, float fvol, float attenuation, qboolean isstatic)
+static void S_SetChannelVolume_WithSfx (unsigned int ch_ind, float fvol, sfx_t *sfx);
+void S_PlaySfxOnChannel (sfx_t *sfx, channel_t *target_chan, unsigned int flags, vec3_t origin, float fvol, float attenuation, qboolean isstatic, int entnum, int entchannel, int startpos)
{
if (!sfx)
{
memset (target_chan, 0, sizeof (*target_chan));
VectorCopy (origin, target_chan->origin);
target_chan->flags = flags;
- target_chan->pos = 0; // start of the sound
+ target_chan->pos = startpos; // start of the sound
+ target_chan->entnum = entnum;
+ target_chan->entchannel = entchannel;
// If it's a static sound
if (isstatic)
else
target_chan->dist_mult = attenuation / snd_soundradius.value;
+ // we have to set the channel volume AFTER the sfx because the function
+ // needs it for replaygain support
+ S_SetChannelVolume_WithSfx(target_chan - channels, fvol, sfx);
+
+ // set the listener volumes
+ SND_Spatialize (target_chan, isstatic);
+
// Lock the SFX during play
S_LockSfx (sfx);
// finally, set the sfx pointer, so the channel becomes valid for playback
// and will be noticed by the mixer
target_chan->sfx = sfx;
-
- // we have to set the channel volume AFTER the sfx because the function
- // needs it for replaygain support
- S_SetChannelVolume(target_chan - channels, fvol);
+ SND_Spatialize (target_chan, isstatic);
}
int S_StartSound (int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation)
{
channel_t *target_chan, *check, *ch;
- int ch_idx;
+ int ch_idx, startpos;
if (snd_renderbuffer == NULL || sfx == NULL || nosound.integer)
return -1;
if (!target_chan)
return -1;
- S_PlaySfxOnChannel (sfx, target_chan, CHANNELFLAG_NONE, origin, fvol, attenuation, false);
- target_chan->entnum = entnum;
- target_chan->entchannel = entchannel;
-
- SND_Spatialize(target_chan, false);
-
// if an identical sound has also been started this frame, offset the pos
// a bit to keep it from just making the first one louder
check = &channels[NUM_AMBIENTS];
+ startpos = 0;
for (ch_idx=NUM_AMBIENTS ; ch_idx < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS ; ch_idx++, check++)
{
if (check == target_chan)
continue;
- if (check->sfx == sfx && !check->pos)
+ if (check->sfx == sfx && check->pos == 0)
{
// use negative pos offset to delay this sound effect
- target_chan->pos += (int)lhrandom(0, -0.1 * snd_renderbuffer->format.speed);
+ startpos = (int)lhrandom(0, -0.1 * snd_renderbuffer->format.speed);
break;
}
}
+ S_PlaySfxOnChannel (sfx, target_chan, CHANNELFLAG_NONE, origin, fvol, attenuation, false, entnum, entchannel, startpos);
+
return (target_chan - channels);
}
}
}
-void S_SetChannelVolume (unsigned int ch_ind, float fvol)
+static void S_SetChannelVolume_WithSfx (unsigned int ch_ind, float fvol, sfx_t *sfx)
{
- sfx_t *sfx = channels[ch_ind].sfx;
if(sfx->volume_peak > 0)
{
// Replaygain support
channels[ch_ind].master_vol = (int)(fvol * 255.0f);
}
+void S_SetChannelVolume(unsigned int ch_ind, float fvol)
+{
+ sfx_t *sfx = channels[ch_ind].sfx;
+ S_SetChannelVolume_WithSfx(ch_ind, fvol, sfx);
+}
+
float S_GetChannelPosition (unsigned int ch_ind)
{
// note: this is NOT accurate yet
}
target_chan = &channels[total_channels++];
- S_PlaySfxOnChannel (sfx, target_chan, CHANNELFLAG_FORCELOOP, origin, fvol, attenuation, true);
-
- SND_Spatialize (target_chan, true);
+ S_PlaySfxOnChannel (sfx, target_chan, CHANNELFLAG_FORCELOOP, origin, fvol, attenuation, true, 0, 0, 0);
}
if (msg_badread) Con_Printf("SV_ReadClientMessage: badread at %s:%i\n", __FILE__, __LINE__);
}
+ if(move->impulse)
+ Con_Printf("MOVEMENT DEBUGGING: received impulse %d\n", move->impulse);
+
// if the previous move has not been applied yet, we need to accumulate
// the impulse/buttons from it
if (!host_client->cmd.applied)
// execute it but it has higher
// sequence count
if(host_client->movesequence)
+ {
if(move->sequence > host_client->movesequence)
host_client->movement_count[(move->sequence) % NETGRAPH_PACKETS] = -1;
+ Con_Printf("MOVEMENT DEBUGGING: invalid packet timing (less than 0.5ms), discarded packet\n");
+ }
continue;
}
// the server and qc frametime values must be changed temporarily
prog->globals.server->frametime = sv.frametime = moveframetime;
// if move is more than 50ms, split it into two moves (this matches QWSV behavior and the client prediction)
+
+ if(host_client->cmd.impulse)
+ Con_Printf("MOVEMENT DEBUGGING: applying impulse %d\n", host_client->cmd.impulse);
+
if (sv.frametime > 0.05)
{
prog->globals.server->frametime = sv.frametime = moveframetime * 0.5f;