float r = ReadByte() / 255;
int who = ReadByte();
entity e = findfloat(world, entnum, autocvar_cl_forceplayermodels ? player_currententnum : who);
- string s = e.(ps.m_playersoundfld); // TODO: populate this field
+ UpdatePlayerSounds(e);
+ string s = e.(ps.m_playersoundfld);
string sample = GlobalSound_sample(s, r);
int chan = ReadByte();
float vol = ReadByte() / 255;
}
}
- #ifdef SVQC
+ entity GetVoiceMessage(string type)
+ {
+ FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == true, LAMBDA(return it));
+ return NULL;
+ }
- entity GetVoiceMessage(string type)
- {
- FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == true, LAMBDA(return it));
- return NULL;
- }
+ entity GetPlayerSound(string type)
+ {
+ FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == false, LAMBDA(return it));
+ return NULL;
+ }
- entity GetPlayerSound(string type)
- {
- FOREACH(PlayerSounds, it.m_playersoundstr == type && it.instanceOfVoiceMessage == false, LAMBDA(return it));
- return NULL;
- }
+ string allvoicesamples;
+ STATIC_INIT(allvoicesamples)
+ {
+ FOREACH(PlayerSounds, it.instanceOfVoiceMessage, LAMBDA(
+ allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr)
+ ));
+ allvoicesamples = strzone(substring(allvoicesamples, 1, -1));
+ }
- .string _GetPlayerSoundSampleField(string type, bool voice)
- {
- GetPlayerSoundSampleField_notFound = false;
- entity e = voice ? GetVoiceMessage(type) : GetPlayerSound(type);
- if (e) return e.m_playersoundfld;
- GetPlayerSoundSampleField_notFound = true;
- return playersound_taunt.m_playersoundfld;
- }
+ .string _GetPlayerSoundSampleField(string type, bool voice)
+ {
+ GetPlayerSoundSampleField_notFound = false;
+ entity e = voice ? GetVoiceMessage(type) : GetPlayerSound(type);
+ if (e) return e.m_playersoundfld;
+ GetPlayerSoundSampleField_notFound = true;
+ return playersound_taunt.m_playersoundfld;
+ }
- .string GetVoiceMessageSampleField(string type)
- {
- return _GetPlayerSoundSampleField(type, true);
- }
+ .string GetVoiceMessageSampleField(string type)
+ {
+ return _GetPlayerSoundSampleField(type, true);
+ }
- .string GetPlayerSoundSampleField(string type)
+ void PrecachePlayerSounds(string f)
+ {
+ int fh = fopen(f, FILE_READ);
+ if (fh < 0)
{
- return _GetPlayerSoundSampleField(type, false);
+ LOG_WARNINGF("Player sound file not found: %s\n", f);
+ return;
}
-
- string allvoicesamples;
-
- void PrecachePlayerSounds(string f)
+ for (string s; (s = fgets(fh)); )
{
- int fh = fopen(f, FILE_READ);
- if (fh < 0)
- {
- LOG_WARNINGF("Player sound file not found: %s\n", f);
- return;
- }
- for (string s; (s = fgets(fh)); )
+ int n = tokenize_console(s);
+ if (n != 3)
{
- int n = tokenize_console(s);
- if (n != 3)
- {
- if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s);
- continue;
- }
- string file = argv(1);
- string variants = argv(2);
- PrecacheGlobalSound(strcat(file, " ", variants));
+ if (n != 0) LOG_WARNINGF("Invalid sound info line: %s\n", s);
+ continue;
}
- fclose(fh);
+ string file = argv(1);
+ string variants = argv(2);
+ PrecacheGlobalSound(strcat(file, " ", variants));
+ }
+ fclose(fh);
+ }
- if (!allvoicesamples)
- {
- FOREACH(PlayerSounds, it.instanceOfVoiceMessage, LAMBDA(
- allvoicesamples = strcat(allvoicesamples, " ", it.m_playersoundstr)
- ));
- allvoicesamples = strzone(substring(allvoicesamples, 1, -1));
- }
+ #ifdef CSQC
+
+ .string GetPlayerSoundSampleField(string type)
+ {
+ return _GetPlayerSoundSampleField(type, false);
}
void ClearPlayerSounds(entity this)
.int modelindex_for_playersound;
.int skin_for_playersound;
+ bool autocvar_g_debug_defaultsounds;
+
void UpdatePlayerSounds(entity this)
{
if (this.modelindex == this.modelindex_for_playersound && this.skin == this.skin_for_playersound) return;
this.skin_for_playersound = this.skin;
ClearPlayerSounds(this);
LoadPlayerSounds(this, "sound/player/default.sounds", true);
- if (autocvar_g_debug_defaultsounds) return;
- if (!LoadPlayerSounds(this, get_model_datafilename(this.model, this.skin, "sounds"), false))
- LoadPlayerSounds(this, get_model_datafilename(
- this.model, 0,
- "sounds"),
- true);
+ if (this.model == "null" || autocvar_g_debug_defaultsounds) return;
+ if (LoadPlayerSounds(this, get_model_datafilename(this.model, this.skin, "sounds"), false)) return;
+ LoadPlayerSounds(this, get_model_datafilename(this.model, 0, "sounds"), true);
}
+ #endif
+
+ #ifdef SVQC
+
void _GlobalSound(entity gs, entity ps, string sample, int chan, int voicetype, bool fake)
{
SELFPARAM();
if (gs == NULL && ps == NULL && sample == "") return;
float r = random();
- if (ps) // TODO: remove
- {
- sample = this.(ps.m_playersoundfld);
- ps = NULL;
- }
if (sample != "") sample = GlobalSound_sample(sample, r);
switch (voicetype)
{
}
REGISTER_REGISTRY(RegisterPlayerSounds)
REGISTRY_SORT(PlayerSounds, 0)
-STATIC_INIT(PlayerSounds_renumber) { FOREACH(PlayerSounds, true, LAMBDA(it.m_id = i)); }
+STATIC_INIT(PlayerSounds_renumber)
+{
+ FOREACH(PlayerSounds, true, LAMBDA(it.m_id = i));
+}
REGISTRY_CHECK(PlayerSounds)
// TODO implement fall and falling
}
REGISTER_REGISTRY(RegisterGlobalSounds)
REGISTRY_SORT(GlobalSounds, 0)
-STATIC_INIT(GlobalSounds_renumber) { FOREACH(GlobalSounds, true, LAMBDA(it.m_id = i)); }
+STATIC_INIT(GlobalSounds_renumber)
+{
+ FOREACH(GlobalSounds, true, LAMBDA(it.m_id = i));
+}
REGISTRY_CHECK(GlobalSounds)
void PrecacheGlobalSound(string samplestring);
PRECACHE(GlobalSounds)
REGISTER_GLOBALSOUND(FALL, "misc/hitground 4")
REGISTER_GLOBALSOUND(FALL_METAL, "misc/metalhitground 4")
-#ifdef SVQC
-
- bool GetPlayerSoundSampleField_notFound;
+bool GetPlayerSoundSampleField_notFound;
+void PrecachePlayerSounds(string f);
+#ifdef CSQC
.string GetVoiceMessageSampleField(string type);
.string GetPlayerSoundSampleField(string type);
- void PrecachePlayerSounds(string f);
void ClearPlayerSounds(entity this);
float LoadPlayerSounds(entity this, string f, bool strict);
void UpdatePlayerSounds(entity this);
+#endif
+
+#ifdef SVQC
+
void _GlobalSound(entity gs, entity ps, string sample, float chan, float voicetype, bool fake);
#define GlobalSound(def, chan, voicetype) _GlobalSound(def, NULL, string_null, chan, voicetype, false)
#define GlobalSound_string(def, chan, voicetype) _GlobalSound(NULL, NULL, def, chan, voicetype, false)
#define PlayerSound(def, chan, voicetype) _GlobalSound(NULL, def, string_null, chan, voicetype, false)
#define VoiceMessage(def, msg) \
- do \
- { \
- entity VM = def; \
- int voicetype = VM.m_playersoundvt; \
- bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
- int flood = Say(this, ownteam, world, msg, true); \
- bool fake; \
- if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
- else if (flood > 0) fake = false; \
- else break; \
- _GlobalSound(NULL, VM, string_null, CH_VOICE, voicetype, fake); \
- } \
- while (0)
+ do \
+ { \
+ entity VM = def; \
+ int voicetype = VM.m_playersoundvt; \
+ bool ownteam = (voicetype == VOICETYPE_TEAMRADIO); \
+ int flood = Say(this, ownteam, world, msg, true); \
+ bool fake; \
+ if (IS_SPEC(this) || IS_OBSERVER(this) || flood < 0) fake = true; \
+ else if (flood > 0) fake = false; \
+ else break; \
+ _GlobalSound(NULL, VM, string_null, CH_VOICE, voicetype, fake); \
+ } \
+ while (0)
#endif