Add SOUNDFLAG_NOREPLACE flag.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5932 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-07-01 01:16:54 +00:00
parent 713c5676ab
commit dc97689e9e
5 changed files with 16 additions and 5 deletions

View File

@ -5060,7 +5060,7 @@ static void CLNQ_ParseStartSoundPacket(void)
field_mask = MSG_ReadByte();
if (field_mask & FTESND_MOREFLAGS)
field_mask |= MSG_ReadByte()<<8;
field_mask |= MSG_ReadUInt64()<<8;
if (field_mask & NQSND_VOLUME)
volume = MSG_ReadByte ();

View File

@ -3047,6 +3047,15 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, vec3_t
S_LockMixer();
for (sc = sndcardinfo; sc; sc = sc->next)
{
if (flags & CF_NOREPLACE)
{
int i;
for (i = 0; i < sc->total_chans; i++)
if (sc->channel[i].entnum == entnum && sc->channel[i].entchannel == entchannel)
break;
if (i < sc->total_chans)
continue;
}
#ifdef Q3CLIENT
if (flags & CF_CLI_NODUPES)
{ //don't start too many simultaneous sounds. q3 sucks or something.

View File

@ -118,15 +118,16 @@ typedef struct
#define CF_NOREVERB 32 // disables reverb on this channel, if possible.
#define CF_FOLLOW 64 // follows the owning entity (stops moving if we lose track)
//#define CF_RESERVEDN 128 // reserved for things that should be networked.
#define CF_NOREPLACE 128 // start sound event is ignored if there's already a sound playing on that entchannel (probably paired with CF_FORCELOOP).
#define CF_SV_UNICAST 256 // serverside only. the sound is sent to msg_entity only.
#define CF_SV_SENDVELOCITY 512 // serverside hint that velocity is important
#define CF_CLI_AUTOSOUND 1024 // generated from q2 entities, which avoids breaking regular sounds, using it outside the sound system will probably break things.
#define CF_CLI_INACTIVE 2048 // try to play even when inactive
#ifdef Q3CLIENT
#define CF_CLI_NODUPES 4096 // block multiple identical sounds being started on the same entity within rapid succession. required by quake3.
#define CF_CLI_NODUPES 4096 // block multiple identical sounds being started on the same entity within rapid succession (regardless of channel). required by quake3.
#endif
#define CF_NETWORKED (CF_NOSPACIALISE|CF_NOREVERB|CF_FORCELOOP|CF_FOLLOW/*|CF_RESERVEDN*/)
#define CF_NETWORKED (CF_NOSPACIALISE|CF_NOREVERB|CF_FORCELOOP|CF_FOLLOW|CF_NOREPLACE)
typedef struct
{

View File

@ -13066,6 +13066,7 @@ void PR_DumpPlatform_f(void)
{"SOUNDFLAG_NOSPACIALISE", "const float", /*QW|NQ|*/CS,D("The different audio channels are played at the same volume regardless of which way the player is facing, without needing to use 0 attenuation."), CF_NOSPACIALISE},
{"SOUNDFLAG_NOREVERB", "const float", QW|NQ|CS, D("Disables the use of underwater/reverb effects on this sound effect."), CF_NOREVERB},
{"SOUNDFLAG_FOLLOW", "const float", QW|NQ|CS, D("The sound's origin will updated to follow the emitting entity."), CF_FOLLOW},
{"SOUNDFLAG_NOREPLACE", "const float", QW|NQ|CS, D("Sounds started with this flag will be ignored when there's already a sound playing on that same ent-channel."), CF_NOREPLACE},
{"SOUNDFLAG_UNICAST", "const float", QW|NQ, D("The sound will be sent only by the player specified by msg_entity. Spectators and related splitscreen players will also hear the sound."), CF_SV_UNICAST},
{"SOUNDFLAG_SENDVELOCITY", "const float", QW|NQ, D("The entity's current velocity will be sent to the client, only useful if doppler is enabled."), CF_SV_SENDVELOCITY},
@ -13194,7 +13195,7 @@ void PR_DumpPlatform_f(void)
{"FL_ONGROUND", "const float", QW|NQ|CS, NULL, FL_ONGROUND},
{"FL_PARTIALGROUND", "const float", QW|NQ|CS, NULL, FL_PARTIALGROUND},
{"FL_WATERJUMP", "const float", QW|NQ|CS, NULL, FL_WATERJUMP},
{"FL_JUMPRELEASED", "const float", NQ|CS, NULL, FL_JUMPRELEASED},
{"FL_JUMPRELEASED", "const float", NQ, NULL, FL_JUMPRELEASED},
{"FL_FINDABLE_NONSOLID","const float", QW|NQ|CS, D("Allows this entity to be found with findradius"), FL_FINDABLE_NONSOLID},
{"FL_MOVECHAIN_ANGLE", "const float", H2, NULL, FL_MOVECHAIN_ANGLE},
{"FL_LAGGEDMOVE", "const float", QW|NQ, D("Enables anti-lag on rockets etc."), FLQW_LAGGEDMOVE},

View File

@ -1310,7 +1310,7 @@ static void SV_SoundMulticast(client_t *client, sizebuf_t *msg, void *vctx)
}
MSG_WriteByte (msg, field_mask&0xff);
if (field_mask & FTESND_MOREFLAGS)
MSG_WriteByte (msg, field_mask>>8);
MSG_WriteUInt64 (msg, field_mask>>8);
if (field_mask & NQSND_VOLUME)
MSG_WriteByte (msg, bound(0, ctx->volume, 255));
if (field_mask & NQSND_ATTENUATION)