implemented PF_localsound && svc_localsound for 2021 re-release.

This commit is contained in:
Ozkan Sezer 2022-04-22 18:11:20 +03:00
parent f86f1595f3
commit c0cfba160d
4 changed files with 71 additions and 1 deletions

View file

@ -194,6 +194,23 @@ void CL_ParseStartSoundPacket(void)
S_StartSound (ent, channel, cl.sound_precache[sound_num], pos, volume/255.0, attenuation);
}
/*
==================
CL_ParseLocalSound - for 2021 rerelease
==================
*/
void CL_ParseLocalSound(void)
{
int field_mask, sound_num;
field_mask = MSG_ReadByte();
sound_num = (field_mask&SND_LARGESOUND) ? MSG_ReadShort() : MSG_ReadByte();
if (sound_num >= MAX_SOUNDS)
Host_Error ("CL_ParseLocalSound: %i > MAX_SOUNDS", sound_num);
S_LocalSound (cl.sound_precache[sound_num]->name);
}
/*
==================
CL_KeepaliveMessage
@ -1258,6 +1275,9 @@ void CL_ParseServerMessage (void)
str = MSG_ReadString();
Con_DPrintf("Ignoring svc_achievement (%s)\n", str);
break;
case svc_localsound:
CL_ParseLocalSound();
break;
}
lastcmd = cmd; //johnfitz

View file

@ -1705,6 +1705,19 @@ static void PF_walkpathtogoal (void)
{
G_FLOAT(OFS_RETURN) = 0; /* PATH_ERROR */
}
void PF_localsound (void)
{
const char *sample;
int entnum;
entnum = G_EDICTNUM(OFS_PARM0);
sample = G_STRING(OFS_PARM1);
if (entnum < 1 || entnum > svs.maxclients) {
Con_Printf ("tried to localsound to a non-client\n");
return;
}
SV_LocalSound (&svs.clients[entnum-1], sample);
}
static void PF_Fixme (void)
{
@ -1804,7 +1817,7 @@ static builtin_t pr_builtin[] =
// 2021 re-release
PF_finalefinished, // float() finaleFinished = #79
PF_Fixme, // void localsound (entity client, string sample) = #80
PF_localsound, // void localsound (entity client, string sample) = #80
PF_Fixme, // void draw_point (vector point, float colormap, float lifetime, float depthtest) = #81
PF_Fixme, // void draw_line (vector start, vector end, float colormap, float lifetime, float depthtest) = #82
PF_Fixme, // void draw_arrow (vector start, vector end, float colormap, float size, float lifetime, float depthtest) = #83

View file

@ -197,6 +197,7 @@ void SV_Init (void);
void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
void SV_StartSound (edict_t *entity, int channel, const char *sample, int volume,
float attenuation);
void SV_LocalSound (client_t *client, const char *sample); // for 2021 rerelease
void SV_DropClient (qboolean crash);

View file

@ -265,6 +265,42 @@ void SV_StartSound (edict_t *entity, int channel, const char *sample, int volume
MSG_WriteCoord (&sv.datagram, entity->v.origin[i]+0.5*(entity->v.mins[i]+entity->v.maxs[i]), sv.protocolflags);
}
/*
==================
SV_LocalSound - for 2021 rerelease
==================
*/
void SV_LocalSound (client_t *client, const char *sample)
{
int sound_num, field_mask;
for (sound_num = 1; sound_num < MAX_SOUNDS && sv.sound_precache[sound_num]; sound_num++)
{
if (!strcmp(sample, sv.sound_precache[sound_num]))
break;
}
if (sound_num == MAX_SOUNDS || !sv.sound_precache[sound_num])
{
Con_Printf ("SV_LocalSound: %s not precached\n", sample);
return;
}
field_mask = 0;
if (sound_num >= 256)
{
if (sv.protocol == PROTOCOL_NETQUAKE)
return;
field_mask = SND_LARGESOUND;
}
MSG_WriteByte (&client->message, svc_localsound);
MSG_WriteByte (&client->message, field_mask);
if (field_mask & SND_LARGESOUND)
MSG_WriteShort (&client->message, sound_num);
else
MSG_WriteByte (&client->message, sound_num);
}
/*
==============================================================================