*/
void globalsound(int channel, entity from, entity gs, float r, int chan, float vol, float atten)
{
+ assert(IS_PLAYER(from));
if (channel == MSG_ONE && !IS_REAL_CLIENT(msg_entity)) return;
WriteHeader(channel, globalsound);
WriteByte(channel, gs.m_id);
*/
void playersound(int channel, entity from, entity ps, float r, int chan, float vol, float atten)
{
+ assert(IS_PLAYER(from));
if (channel == MSG_ONE && !IS_REAL_CLIENT(msg_entity)) return;
WriteHeader(channel, playersound);
WriteByte(channel, ps.m_id);
#ifdef SVQC
- void _GlobalSound(entity gs, entity ps, string sample, int chan, int voicetype, bool fake)
+ void _GlobalSound(entity this, entity gs, entity ps, string sample, int chan, int voicetype, bool fake)
{
- SELFPARAM();
if (gs == NULL && ps == NULL && sample == "") return;
float r = random();
if (sample != "") sample = GlobalSound_sample(sample, r);
#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) \
+ void _GlobalSound(entity this, entity gs, entity ps, string sample, float chan, float voicetype, bool fake);
+ #define GlobalSound(this, def, chan, voicetype) _GlobalSound(this, def, NULL, string_null, chan, voicetype, false)
+ #define GlobalSound_string(this, def, chan, voicetype) _GlobalSound(this, NULL, NULL, def, chan, voicetype, false)
+ #define PlayerSound(thise, def, chan, voicetype) _GlobalSound(this, NULL, def, string_null, chan, voicetype, false)
+ #define VoiceMessage(this, def, msg) \
do \
{ \
entity VM = def; \
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); \
+ _GlobalSound(this, NULL, VM, string_null, CH_VOICE, voicetype, fake); \
} \
while (0)
if(delaytoo)
if(time < self.msound_delay)
return; // too early
- GlobalSound_string(self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
+ GlobalSound_string(self, self.(samplefield), chan, VOICETYPE_PLAYERSOUND);
self.msound_delay = time + sound_delay;
}
#ifdef SVQC
if (autocvar_sv_dodging_sound)
- PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
animdecide_setaction(this, ANIMACTION_JUMP, true);
#endif
animdecide_setaction(this, ANIMACTION_JUMP, true);
if (autocvar_g_jump_grunt)
- WITH(entity, self, this, PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND));
+ PlayerSound(this, playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND);
#endif
return true;
}
tracebox(this.origin, this.mins, this.maxs, this.origin - '0 0 1', MOVE_NOMONSTERS, this);
if ((trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS)) return;
entity fall = (trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS) ? GS_FALL_METAL : GS_FALL;
- WITH(entity, self, this, GlobalSound(fall, CH_PLAYER, VOICETYPE_PLAYERSOUND));
+ GlobalSound(this, fall, CH_PLAYER, VOICETYPE_PLAYERSOUND);
#endif
}
} \
while (0)
-#define assert(expr, ...) \
+#define assert(expr, ...) _assert(LOG_WARNING, expr, __VA_ARGS__)
+#define ASSERT(expr, ...) _assert(LOG_FATAL, expr, __VA_ARGS__)
+#define _assert(f, expr, then) \
do \
{ \
- if (!(expr)) LOG_WARNINGF(__VA_ARGS__); \
+ if (!(expr)) \
+ { \
+ f("assertion failed: `" #expr "`\n"); \
+ then; \
+ } \
} \
while (0)
+#define ASSERT_LESS(name, var, const) noref int name[(const - var + 1)];
+
#define _LOG(f, level, s) f("[::"level "] ["__FILE__ ":%s:%.0f] %s", __FUNC__, __LINE__, s)
#define LOG_FATAL(...) _LOG_FATAL(strcat("", __VA_ARGS__))
} \
while (0)
-#define ASSERT(expr) \
- do \
- { \
- if (!(expr)) LOG_FATAL("assertion failed: " #expr "\n"); \
- } \
- while (0)
-
-#define ASSERT_LESS(name, var, const) noref int name[(const - var + 1)];
-
#endif
{
self.teamkill_soundtime = 0;
- setself(self.teamkill_soundsource);
- entity oldpusher = self.pusher;
- self.pusher = this;
-
- PlayerSound(playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
-
- self.pusher = oldpusher;
- setself(this);
+ entity e = self.teamkill_soundsource;
+ entity oldpusher = e.pusher;
+ e.pusher = this;
+ PlayerSound(e, playersound_teamshoot, CH_VOICE, VOICETYPE_LASTATTACKER_ONLY);
+ e.pusher = oldpusher;
}
if(self.taunt_soundtime)
if(time > self.taunt_soundtime)
{
self.taunt_soundtime = 0;
- PlayerSound(playersound_taunt, CH_VOICE, VOICETYPE_AUTOTAUNT);
+ PlayerSound(self, playersound_taunt, CH_VOICE, VOICETYPE_AUTOTAUNT);
}
target_voicescript_next(self);
// exclude pain sounds for laserjumps as long as you aren't REALLY low on health and would die of the next two
{
if(deathtype == DEATH_FALL.m_id)
- PlayerSound(playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_fall, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 75) // TODO make a "gentle" version?
- PlayerSound(playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain100, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 50)
- PlayerSound(playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain75, CH_PAIN, VOICETYPE_PLAYERSOUND);
else if(self.health > 25)
- PlayerSound(playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain50, CH_PAIN, VOICETYPE_PLAYERSOUND);
else
- PlayerSound(playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_pain25, CH_PAIN, VOICETYPE_PLAYERSOUND);
}
}
}
if(sound_allowed(MSG_BROADCAST, attacker))
{
if(deathtype == DEATH_DROWN.m_id)
- PlayerSound(playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_drown, CH_PAIN, VOICETYPE_PLAYERSOUND);
else
- PlayerSound(playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_death, CH_PAIN, VOICETYPE_PLAYERSOUND);
}
// get rid of kill indicator
sprint(this, sprintf("Invalid voice. Use one of: %s\n", allvoicesamples));
return;
}
- if (argc >= 3) VoiceMessage(e, substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
- else VoiceMessage(e, "");
+ if (argc >= 3) VoiceMessage(this, e, substring(command, argv_start_index(2), argv_end_index(-1) - argv_start_index(2)));
+ else VoiceMessage(this, e, "");
return;
}
PLAYERDEMO_FIELDS(playerdemo_read_)
{
time = this.playerdemo_time;
- WITH(entity, this, this, PlayerPreThink());
+ WITH(entity, self, this, PlayerPreThink());
// not running physics though... this is just so we can run weapon stuff
- WITH(entity, this, this, PlayerPostThink());
+ WITH(entity, self, this, PlayerPostThink());
}
this.playerdemo_time = stof(fgets(this.playerdemo_fh));
if(this.playerdemo_time == 0)
if (self.waterlevel != WATERLEVEL_SUBMERGED)
{
if(self.air_finished < time)
- PlayerSound(playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ PlayerSound(self, playersound_gasp, CH_PLAYER, VOICETYPE_PLAYERSOUND);
self.air_finished = time + autocvar_g_balance_contents_drowndelay;
self.dmg = 2;
}
if (!(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOSTEPS))
{
if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_METALSTEPS)
- GlobalSound(GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(self, GS_STEP_METAL, CH_PLAYER, VOICETYPE_PLAYERSOUND);
else
- GlobalSound(GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
+ GlobalSound(self, GS_STEP, CH_PLAYER, VOICETYPE_PLAYERSOUND);
}
}
}