#include <common/ent_cs.qh>
-#ifdef IMPLEMENTATION
#include <common/animdecide.qh>
#ifdef SVQC
- #include <server/cl_player.qh>
+ #include <server/player.qh>
#endif
REGISTER_NET_TEMP(globalsound)
REGISTER_NET_TEMP(playersound)
- string GlobalSound_sample(string pair, float r);
-
#ifdef SVQC
/**
* @param from the source entity, its position is sent
WriteByte(channel, floor(_atten * 64));
entcs_force_origin(from);
vector o = from.origin + 0.5 * (from.mins + from.maxs);
- WriteCoord(channel, o.x);
- WriteCoord(channel, o.y);
- WriteCoord(channel, o.z);
+ WriteVector(channel, o);
}
/**
WriteByte(channel, floor(_atten * 64));
entcs_force_origin(from);
vector o = from.origin + 0.5 * (from.mins + from.maxs);
- WriteCoord(channel, o.x);
- WriteCoord(channel, o.y);
- WriteCoord(channel, o.z);
+ WriteVector(channel, o);
}
#endif
int chan = ReadSByte();
float vol = ReadByte() / 255;
float atten = ReadByte() / 64;
- vector o;
- o.x = ReadCoord();
- o.y = ReadCoord();
- o.z = ReadCoord();
+ vector o = ReadVector();
// TODO: is this really what we want to be doing? Footsteps that follow the player at head height?
if (who == player_currententnum) e = findfloat(NULL, entnum, who); // play at camera position for full volume
else if (e) e.origin = o;
else
{
// Can this happen?
- LOG_WARNINGF("Missing entcs data for player %d\n", who);
+ LOG_WARNF("Missing entcs data for player %d", who);
sound8(e, o, chan, sample, vol, atten, 0, 0);
}
return true;
int chan = ReadSByte();
float vol = ReadByte() / 255;
float atten = ReadByte() / 64;
- vector o;
- o.x = ReadCoord();
- o.y = ReadCoord();
- o.z = ReadCoord();
+ vector o = ReadVector();
if (who == player_currententnum) e = findfloat(NULL, entnum, who); // play at camera position for full volume
else if (e) e.origin = o;
if (e)
else
{
// Can this happen?
- LOG_WARNINGF("Missing entcs data for player %d\n", who);
+ LOG_WARNF("Missing entcs data for player %d", who);
sound8(e, o, chan, sample, vol, atten, 0, 0);
}
return true;
int fh = fopen(f, FILE_READ);
if (fh < 0)
{
- LOG_WARNINGF("Player sound file not found: %s\n", f);
+ LOG_WARNF("Player sound file not found: %s", f);
return;
}
for (string s; (s = fgets(fh)); )
int n = tokenize_console(s);
if (n != 3)
{
- if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s);
+ if (n != 0) LOG_WARNF("Invalid sound info line: %s", s);
continue;
}
string file = argv(1);
.string fld = it.m_playersoundfld;
if (this.(fld))
{
- strunzone(this.(fld));
- this.(fld) = string_null;
+ strfree(this.(fld));
}
});
}
int fh = fopen(f, FILE_READ);
if (fh < 0)
{
- if (strict) LOG_WARNINGF("Player sound file not found: %s\n", f);
+ if (strict) LOG_WARNF("Player sound file not found: %s", f);
return false;
}
for (string s; (s = fgets(fh)); )
int n = tokenize_console(s);
if (n != 3)
{
- if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s);
+ if (n != 0) LOG_WARNF("Invalid sound info line: %s", s);
continue;
}
string key = argv(0);
if (GetPlayerSoundSampleField_notFound) field = GetVoiceMessageSampleField(key);
if (GetPlayerSoundSampleField_notFound)
{
- LOG_TRACEF("Invalid sound info field: %s\n", key);
+ LOG_TRACEF("Invalid sound info field: %s", key);
continue;
}
string file = argv(1);
string variants = argv(2);
- if (this.(field)) strunzone(this.(field));
- this.(field) = strzone(strcat(file, " ", variants));
+ strcpy(this.(field), strcat(file, " ", variants));
}
fclose(fh);
return true;
void UpdatePlayerSounds(entity this)
{
if (this.model == this.model_for_playersound && this.skin == this.skin_for_playersound) return;
- if (this.model_for_playersound) strunzone(this.model_for_playersound);
- this.model_for_playersound = strzone(this.model);
+ strcpy(this.model_for_playersound, this.model);
this.skin_for_playersound = this.skin;
ClearPlayerSounds(this);
LoadPlayerSounds(this, "sound/player/default.sounds", true);
#ifdef SVQC
- void _GlobalSound(entity this, entity gs, entity ps, string sample, int chan, int voicetype, bool fake)
+ void _GlobalSound(entity this, entity gs, entity ps, string sample, int chan, float vol, int voicetype, bool fake)
{
if (gs == NULL && ps == NULL && sample == "") return;
if(this.classname == "body") return;
msg_entity = this.pusher;
if (IS_REAL_CLIENT(msg_entity))
{
- float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE;
- if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASEVOICE, atten);
- else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASEVOICE, atten);
- else soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten);
+ float atten = (CS(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE;
+ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten);
+ else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten);
+ else soundto(MSG_ONE, this, chan, sample, vol, atten);
}
}
if (voicetype == VOICETYPE_LASTATTACKER_ONLY) break;
{
#define X() \
MACRO_BEGIN \
- { \
- float atten = (msg_entity.cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \
- if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASEVOICE, atten); \
- else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASEVOICE, atten); \
- else soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); \
- } MACRO_END
+ float atten = (CS(msg_entity).cvar_cl_voice_directional == 1) ? ATTEN_MIN : ATTEN_NONE; \
+ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); \
+ else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \
+ else soundto(MSG_ONE, this, chan, sample, vol, atten); \
+ MACRO_END
if (fake) { msg_entity = this; X(); }
else
{
- FOREACH_CLIENT(IS_REAL_CLIENT(it) && (!teamplay || msg_entity.team == this.team), {
+ FOREACH_CLIENT(IS_REAL_CLIENT(it) && SAME_TEAM(it, this), {
msg_entity = it;
X();
});
if (voicetype == VOICETYPE_AUTOTAUNT) tauntrand = random();
#define X() \
MACRO_BEGIN \
- { \
- if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < msg_entity.cvar_cl_autotaunt) \
+ if (voicetype != VOICETYPE_AUTOTAUNT || tauntrand < CS(msg_entity).cvar_cl_autotaunt) \
{ \
- float atten = (msg_entity.cvar_cl_voice_directional >= 1) \
- ? bound(ATTEN_MIN, msg_entity.cvar_cl_voice_directional_taunt_attenuation, \
+ float atten = (CS(msg_entity).cvar_cl_voice_directional >= 1) \
+ ? bound(ATTEN_MIN, CS(msg_entity).cvar_cl_voice_directional_taunt_attenuation, \
ATTEN_MAX) \
: ATTEN_NONE; \
- if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASEVOICE, atten); \
- else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASEVOICE, atten); \
- else soundto(MSG_ONE, this, chan, sample, VOL_BASEVOICE, atten); \
+ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, atten); \
+ else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, atten); \
+ else soundto(MSG_ONE, this, chan, sample, vol, atten); \
} \
- } MACRO_END
+ MACRO_END
if (fake)
{
msg_entity = this;
msg_entity = this;
if (fake)
{
- if (gs) globalsound(MSG_ONE, this, gs, r, chan, VOL_BASE, ATTEN_NORM);
- else if (ps) playersound(MSG_ONE, this, ps, r, chan, VOL_BASE, ATTEN_NORM);
- else soundto(MSG_ONE, this, chan, sample, VOL_BASE, ATTEN_NORM);
+ if (gs) globalsound(MSG_ONE, this, gs, r, chan, vol, ATTEN_NORM);
+ else if (ps) playersound(MSG_ONE, this, ps, r, chan, vol, ATTEN_NORM);
+ else soundto(MSG_ONE, this, chan, sample, vol, ATTEN_NORM);
}
else
{
- if (gs) globalsound(MSG_ALL, this, gs, r, chan, VOL_BASE, ATTEN_NORM);
- else if (ps) playersound(MSG_ALL, this, ps, r, chan, VOL_BASE, ATTEN_NORM);
- else _sound(this, chan, sample, VOL_BASE, ATTEN_NORM);
+ if (gs) globalsound(MSG_ALL, this, gs, r, chan, vol, ATTEN_NORM);
+ else if (ps) playersound(MSG_ALL, this, ps, r, chan, vol, ATTEN_NORM);
+ else _sound(this, chan, sample, vol, ATTEN_NORM);
}
break;
}
}
#endif
-#endif