int volume;
int field_mask;
float attenuation;
+ float speed;
if (cls.protocol == PROTOCOL_QUAKEWORLD)
{
attenuation = MSG_ReadByte () / 64.0;
else
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
+
+ speed = 1.0f;
ent = (channel>>3)&1023;
channel &= 7;
else
attenuation = DEFAULT_SOUND_PACKET_ATTENUATION;
+ if (field_mask & SND_SPEEDUSHORT4000)
+ speed = ((unsigned short)MSG_ReadShort ()) / 4000.0f;
+ else
+ speed = 1.0f;
+
if (field_mask & SND_LARGEENTITY)
{
ent = (unsigned short) MSG_ReadShort ();
#define SND_LOOPING (1<<2) // a long
#define SND_LARGEENTITY (1<<3) // a short and a byte (instead of a short)
#define SND_LARGESOUND (1<<4) // a short (instead of a byte)
+#define SND_SPEEDUSHORT4000 (1<<5) // ushort speed*4000 (speed is usually 1.0, a value of 0.0 is the same as 1.0)
// defaults for clientinfo messages
void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
void SV_StartEffect (vec3_t org, int modelindex, int startframe, int framecount, int framerate);
-void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation, qboolean reliable);
-void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation);
+void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation, qboolean reliable, float speed);
+void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation, float speed);
void SV_ConnectClient (int clientnum, netconn_t *netconnection);
void SV_DropClient (qboolean crash);
==================
*/
-void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation, qboolean reliable)
+void SV_StartSound (prvm_edict_t *entity, int channel, const char *sample, int volume, float attenuation, qboolean reliable, float speed)
{
sizebuf_t *dest;
- int sound_num, field_mask, i, ent;
+ int sound_num, field_mask, i, ent, speed4000;
dest = (reliable ? &sv.reliable_datagram : &sv.datagram);
ent = PRVM_NUM_FOR_EDICT(entity);
+ speed4000 = (int)(speed * 40.0f);
field_mask = 0;
if (volume != DEFAULT_SOUND_PACKET_VOLUME)
field_mask |= SND_VOLUME;
field_mask |= SND_LARGEENTITY;
if (sound_num >= 256)
field_mask |= SND_LARGESOUND;
+ if (speed4000 && speed4000 != 4000)
+ field_mask |= SND_SPEEDUSHORT4000;
// directed messages go only to the entity they are targeted on
MSG_WriteByte (dest, svc_sound);
MSG_WriteByte (dest, volume);
if (field_mask & SND_ATTENUATION)
MSG_WriteByte (dest, (int)(attenuation*64));
+ if (field_mask & SND_SPEEDUSHORT4000)
+ MSG_WriteShort (dest, speed4000);
if (field_mask & SND_LARGEENTITY)
{
MSG_WriteShort (dest, ent);
==================
*/
-void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation)
+void SV_StartPointSound (vec3_t origin, const char *sample, int volume, float attenuation, float speed)
{
- int sound_num, field_mask, i;
+ int sound_num, field_mask, i, speed4000;
if (volume < 0 || volume > 255)
{
if (!sound_num)
return;
+ speed4000 = (int)(speed * 40.0f);
field_mask = 0;
if (volume != DEFAULT_SOUND_PACKET_VOLUME)
field_mask |= SND_VOLUME;
field_mask |= SND_ATTENUATION;
if (sound_num >= 256)
field_mask |= SND_LARGESOUND;
+ if (speed4000 && speed4000 != 4000)
+ field_mask |= SND_SPEEDUSHORT4000;
// directed messages go only to the entity they are targeted on
MSG_WriteByte (&sv.datagram, svc_sound);
MSG_WriteByte (&sv.datagram, volume);
if (field_mask & SND_ATTENUATION)
MSG_WriteByte (&sv.datagram, (int)(attenuation*64));
+ if (field_mask & SND_SPEEDUSHORT4000)
+ MSG_WriteShort (&sv.datagram, speed4000);
// Always write entnum 0 for the world entity
MSG_WriteShort (&sv.datagram, (0<<3) | 0);
if (field_mask & SND_LARGESOUND)
{ // Contents Transition Function Invalid; Potentially Play Water Sound
// check if the entity crossed into or out of water
if (sv_sound_watersplash.string && ((PRVM_serveredictfloat(ent, watertype) == CONTENTS_WATER || PRVM_serveredictfloat(ent, watertype) == CONTENTS_SLIME) != (cont == CONTENTS_WATER || cont == CONTENTS_SLIME)))
- SV_StartSound (ent, 0, sv_sound_watersplash.string, 255, 1, false);
+ SV_StartSound (ent, 0, sv_sound_watersplash.string, 255, 1, false, 1.0f);
}
if (cont <= CONTENTS_WATER)
else
// Check for Engine Landing Sound
if(sv_sound_land.string)
- SV_StartSound(ent, 0, sv_sound_land.string, 255, 1, false);
+ SV_StartSound(ent, 0, sv_sound_land.string, 255, 1, false, 1.0f);
}
ent->priv.server->waterposition_forceupdate = true;
}
if (prog->argc < 6)
pitchchange = 0;
else
- pitchchange = PRVM_G_FLOAT(OFS_PARM5);
+ pitchchange = PRVM_G_FLOAT(OFS_PARM5) * 0.01f;
if (prog->argc < 7)
{
return;
}
- SV_StartSound (entity, channel, sample, volume, attenuation, flags & CHANFLAG_RELIABLE);
+ SV_StartSound (entity, channel, sample, volume, attenuation, flags & CHANFLAG_RELIABLE, pitchchange);
}
/*
const char *sample;
int volume;
float attenuation;
+ float pitchchange;
vec3_t org;
- VM_SAFEPARMCOUNT(4, VM_SV_pointsound);
+ VM_SAFEPARMCOUNTRANGE(4, 5, VM_SV_pointsound);
VectorCopy(PRVM_G_VECTOR(OFS_PARM0), org);
sample = PRVM_G_STRING(OFS_PARM1);
volume = (int)(PRVM_G_FLOAT(OFS_PARM2) * 255);
attenuation = PRVM_G_FLOAT(OFS_PARM3);
+ pitchchange = prog->argc < 5 ? 0 : PRVM_G_FLOAT(OFS_PARM4) * 0.01f;
if (volume < 0 || volume > 255)
{
return;
}
- SV_StartPointSound (org, sample, volume, attenuation);
+ SV_StartPointSound (org, sample, volume, attenuation, pitchchange);
}
/*