From 4f047a2214d16d9a697ced6a60136bdcbd74f588 Mon Sep 17 00:00:00 2001 From: Shpoike Date: Tue, 15 Aug 2023 01:11:00 +0100 Subject: [PATCH] Sound channels should match actual channels, rather than matching the weird remapping done for the qw-specific legacy sound variation that packed the reliable flag in the middle of channels. --- engine/client/cl_parse.c | 3 +-- engine/server/pr_cmds.c | 13 ++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index e7beb2d60..b1ac4a40b 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -5330,8 +5330,7 @@ static void CLNQ_ParseStartSoundPacket(void) channel &= 7; } - /*unpack mangling*/ - channel = (channel & 7) | ((channel & 0x0f1) << 1); + //channel = (channel & 7) | ((channel & 0x0f1) << 1); //this line undoes the reliable=(channel&8) gap from qwssqc... but frankly just pass the flags arg properly. csqc's builtin doesn't use it, so don't give an inconsistent gap at all here. if ((field_mask & NQSND_LARGESOUND) || (cls.protocol == CP_NETQUAKE && (cls.protocol_nq == CPNQ_BJP2 || cls.protocol_nq == CPNQ_BJP3))) //bjp kinda sucks sound_num = (unsigned short)MSG_ReadShort(); diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 2d1811aaa..69b22d8f1 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -3731,13 +3731,20 @@ static void QCBUILTIN PF_sound (pubprogfuncs_t *prinst, struct globalvars_s *pr_ if (channel < 0) channel = 0; } - else + else if (progstype == PROG_QW) { //QW uses channel&8 to mean reliable. chflags = (channel & 8)?CF_SV_RELIABLE:0; - //demangle it so the upper bits are still useful. + //strip out that unused bit. channel = (channel & 7) | ((channel & ~15) >> 1); + if (channel > 7 && !ssqc_deprecated_warned && sv.csqcchecksum) + { //warn for extended channels (inconsistencies with csqc). + PR_RunWarning(prinst, "PF_sound: recommended to pass the flags arg when using extended channel numbers."); + ssqc_deprecated_warned = true; + } } + else + chflags = 0; timeofs = (svprogfuncs->callargc>7)?G_FLOAT(OFS_PARM7):0; if (volume < 0) //erm... @@ -13656,7 +13663,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_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. Such sounds can be safely 're-' started every single frame without harming anything. Tends not to make sense with CHAN_AUTO."), 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}, {"SOUNDFLAG_INACTIVE", "const float", CS, D("The sound will ignore the value of the snd_inactive cvar."), CF_CLI_INACTIVE},