Fix some missing ambient sounds on large bloated maps/mods (this really should have been fixed years ago).

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6281 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2022-06-29 07:20:24 +00:00
parent 4afdb54861
commit c4b043d39f
5 changed files with 34 additions and 12 deletions

View file

@ -4973,23 +4973,34 @@ static void CL_ParseStaticProt (int baselinetype)
CL_ParseStaticSound
===================
*/
static void CL_ParseStaticSound (qboolean large)
static void CL_ParseStaticSound (unsigned int flags)
{
extern cvar_t cl_staticsounds;
vec3_t org;
int sound_num;
size_t sound_num;
float vol, atten;
int i;
if (flags & ~(1))
Host_EndGame("CL_ParseStaticSound: unsupported flags & %x\n", flags&~(1));
for (i=0 ; i<3 ; i++)
org[i] = MSG_ReadCoord ();
if (large || (cls.protocol == CP_NETQUAKE && cls.protocol_nq == CPNQ_BJP2))
if (flags || (cls.protocol == CP_NETQUAKE && cls.protocol_nq == CPNQ_BJP2))
{
if (cls.fteprotocolextensions2&PEXT2_LERPTIME)
sound_num = (unsigned short)MSG_ReadULEB128();
else
sound_num = (unsigned short)MSG_ReadShort();
}
else
sound_num = MSG_ReadByte ();
vol = MSG_ReadByte ()/255.0;
atten = MSG_ReadByte ()/64.0;
if (sound_num >= countof(cl.sound_precache))
return; //no crashing, please.
vol *= cl_staticsounds.value;
if (vol < 0)
return;
@ -7520,6 +7531,9 @@ void CLQW_ParseServerMessage (void)
case svc_spawnstaticsound:
CL_ParseStaticSound (false);
break;
case svcfte_spawnstaticsound2:
CL_ParseStaticSound (MSG_ReadByte());
break;
case svc_cdtrack:
{

View file

@ -334,6 +334,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define svcfte_temp_entity_sized 91 //svc_temp_entity with an extra short size right after the svc (high bit means nq, unset means qw).
#define svcfte_csqcentities_sized 92 //entity lump for csqc (with size info)
#define svcfte_setanglebase 93 //updates the base angle (and optionally locks the view, otherwise nudging it without race conditions.)
#define svcfte_spawnstaticsound2 94 //*sigh*
//fitz svcs
#define svcfitz_skybox 37

View file

@ -3675,7 +3675,7 @@ void PF_ambientsound_Internal (float *pos, const char *samp, float vol, float at
VectorCopy(pos, state->position);
state->soundnum = soundnum;
state->volume = bound(0, (int)(vol*255), 255);
state->attenuation = attenuation*64;
state->attenuation = bound(0,attenuation*64,255);
}
static void QCBUILTIN PF_ambientsound (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)

View file

@ -1201,11 +1201,8 @@ void SV_StartSound (int ent, vec3_t origin, float *velocity, int seenmask, int c
return;
}
if (attenuation < 0 || attenuation > 4)
{
Con_Printf ("SV_StartSound: attenuation = %f", attenuation);
return;
}
if (attenuation < 0 || attenuation >= 4)
Con_DPrintf ("SV_StartSound: attenuation = %f", attenuation);
if (channel < 0 || channel > 255)
{

View file

@ -1694,9 +1694,14 @@ void SV_SendClientPrespawnInfo(client_t *client)
large = true;
if (client->protocol == SCP_BJP3)
continue; //not supported
else if (ISQWCLIENT(client) && (client->fteprotocolextensions2 & PEXT2_REPLACEMENTDELTAS))
{
MSG_WriteByte(&client->netchan.message, svcfte_spawnstaticsound2);
MSG_WriteByte(&client->netchan.message, 1);
}
else if (ISDPCLIENT(client))
MSG_WriteByte(&client->netchan.message, svcdp_spawnstaticsound2);
else if (ISNQCLIENT(client))
else if (client->protocol == SCP_FITZ666)
MSG_WriteByte(&client->netchan.message, svcfitz_spawnstaticsound2);
else
continue; //not supported
@ -1707,7 +1712,12 @@ void SV_SendClientPrespawnInfo(client_t *client)
for (i=0 ; i<3 ; i++)
MSG_WriteCoord(&client->netchan.message, sound->position[i]);
if (large)
{
if (client->fteprotocolextensions2&PEXT2_LERPTIME)
MSG_WriteULEB128(&client->netchan.message, sound->soundnum);
else
MSG_WriteShort(&client->netchan.message, sound->soundnum);
}
else
MSG_WriteByte(&client->netchan.message, sound->soundnum);
MSG_WriteByte(&client->netchan.message, sound->volume);