From e6ebba90417024535539ac3561bcc1e7b86695c9 Mon Sep 17 00:00:00 2001 From: div0 Date: Wed, 5 Nov 2008 20:19:42 +0000 Subject: [PATCH] clean up voice message stuff a bit git-svn-id: svn://svn.icculus.org/nexuiz/trunk@4992 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- data/qcsrc/server/cl_player.qc | 53 +++++++----------------------- data/qcsrc/server/defs.qh | 59 ++++++++++++++++++++++------------ 2 files changed, 51 insertions(+), 61 deletions(-) diff --git a/data/qcsrc/server/cl_player.qc b/data/qcsrc/server/cl_player.qc index 49d792c15..ff7efcc3e 100644 --- a/data/qcsrc/server/cl_player.qc +++ b/data/qcsrc/server/cl_player.qc @@ -773,18 +773,11 @@ float GetPlayerSoundSampleField_fixed; GetPlayerSoundSampleField_fixed = 0; switch(type) { - case "attack": return playersound_attack; - case "attackinfive": return playersound_attackinfive; - case "coverme": return playersound_coverme; - case "defend": return playersound_defend; - case "freelance": return playersound_freelance; - case "incoming": return playersound_incoming; - case "meet": return playersound_meet; - case "needhelp": return playersound_needhelp; - case "seenflag": return playersound_seenflag; - case "taunt": return playersound_taunt; - case "teamshoot": return playersound_teamshoot; - case "teamshoot_auto": return playersound_teamshoot; +#define _VOICEMSG(m) case #m: return playersound_##m; + ALLVOICEMSGS +#undef _VOICEMSG + // exception: + case "teamshoot_auto": return playersound_teamshoot; } GetPlayerSoundSampleField_notFound = 1; return playersound_taunt; @@ -796,15 +789,9 @@ float GetPlayerSoundSampleField_fixed; GetPlayerSoundSampleField_fixed = 0; switch(type) { - case "death": return playersound_death; - case "drown": return playersound_drown; - case "falling": return playersound_falling; - case "gasp": return playersound_gasp; - case "jump": return playersound_jump; - case "pain25": return playersound_pain25; - case "pain50": return playersound_pain50; - case "pain75": return playersound_pain75; - case "pain100": return playersound_pain100; +#define _VOICEMSG(m) case #m: return playersound_##m; + ALLPLAYERSOUNDS +#undef _VOICEMSG } GetPlayerSoundSampleField_notFound = 1; return playersound_taunt; @@ -847,26 +834,10 @@ void PrecachePlayerSounds(string f) void ClearPlayerSounds() { - if(self.playersound_attack ) { strunzone(self.playersound_attack ); self.playersound_attack = string_null; } - if(self.playersound_attackinfive) { strunzone(self.playersound_attackinfive); self.playersound_attackinfive = string_null; } - if(self.playersound_coverme ) { strunzone(self.playersound_coverme ); self.playersound_coverme = string_null; } - if(self.playersound_defend ) { strunzone(self.playersound_defend ); self.playersound_defend = string_null; } - if(self.playersound_freelance ) { strunzone(self.playersound_freelance ); self.playersound_freelance = string_null; } - if(self.playersound_incoming ) { strunzone(self.playersound_incoming ); self.playersound_incoming = string_null; } - if(self.playersound_meet ) { strunzone(self.playersound_meet ); self.playersound_meet = string_null; } - if(self.playersound_needhelp ) { strunzone(self.playersound_needhelp ); self.playersound_needhelp = string_null; } - if(self.playersound_seenflag ) { strunzone(self.playersound_seenflag ); self.playersound_seenflag = string_null; } - if(self.playersound_taunt ) { strunzone(self.playersound_taunt ); self.playersound_taunt = string_null; } - if(self.playersound_teamshoot ) { strunzone(self.playersound_teamshoot ); self.playersound_teamshoot = string_null; } - if(self.playersound_death ) { strunzone(self.playersound_death ); self.playersound_death = string_null; } - if(self.playersound_drown ) { strunzone(self.playersound_drown ); self.playersound_drown = string_null; } - if(self.playersound_falling ) { strunzone(self.playersound_falling ); self.playersound_falling = string_null; } - if(self.playersound_gasp ) { strunzone(self.playersound_gasp ); self.playersound_gasp = string_null; } - if(self.playersound_jump ) { strunzone(self.playersound_jump ); self.playersound_jump = string_null; } - if(self.playersound_pain25 ) { strunzone(self.playersound_pain25 ); self.playersound_pain25 = string_null; } - if(self.playersound_pain50 ) { strunzone(self.playersound_pain50 ); self.playersound_pain50 = string_null; } - if(self.playersound_pain75 ) { strunzone(self.playersound_pain75 ); self.playersound_pain75 = string_null; } - if(self.playersound_pain100 ) { strunzone(self.playersound_pain100 ); self.playersound_pain100 = string_null; } +#define _VOICEMSG(m) if(self.playersound_##m) { strunzone(self.playersound_##m); self.playersound_##m = string_null; } + ALLPLAYERSOUNDS + ALLVOICEMSGS +#undef _VOICEMSG } void LoadPlayerSounds(string f, float first) diff --git a/data/qcsrc/server/defs.qh b/data/qcsrc/server/defs.qh index 6640a46fb..12998a1b0 100644 --- a/data/qcsrc/server/defs.qh +++ b/data/qcsrc/server/defs.qh @@ -437,26 +437,45 @@ float next_pingtime; .float(entity to, float sendflags) SendEntity; // player sounds, voice messages -.string playersound_attack; -.string playersound_attackinfive; -.string playersound_coverme; -.string playersound_defend; -.string playersound_freelance; -.string playersound_incoming; -.string playersound_meet; -.string playersound_needhelp; -.string playersound_seenflag; -.string playersound_taunt; -.string playersound_teamshoot; -.string playersound_death; -.string playersound_drown; -.string playersound_falling; // not yet implemented, FIXME -.string playersound_gasp; -.string playersound_jump; -.string playersound_pain25; -.string playersound_pain50; -.string playersound_pain75; -.string playersound_pain100; +// TODO implemented fall and falling +#define ALLPLAYERSOUNDS \ + _VOICEMSG(death) \ + _VOICEMSG(drown) \ + _VOICEMSG(fall) \ + _VOICEMSG(falling) \ + _VOICEMSG(gasp) \ + _VOICEMSG(jump) \ + _VOICEMSG(pain25) \ + _VOICEMSG(pain50) \ + _VOICEMSG(pain75) \ + _VOICEMSG(pain100) +#define ALLVOICEMSGS \ + _VOICEMSG(attack) \ + _VOICEMSG(attackinfive) \ + _VOICEMSG(coverme) \ + _VOICEMSG(defend) \ + _VOICEMSG(freelance) \ + _VOICEMSG(incoming) \ + _VOICEMSG(meet) \ + _VOICEMSG(needhelp) \ + _VOICEMSG(seenflag) \ + _VOICEMSG(taunt) \ + _VOICEMSG(teamshoot) \ + _VOICEMSG(attacking) \ + _VOICEMSG(defending) \ + _VOICEMSG(roaming) \ + _VOICEMSG(positive) \ + _VOICEMSG(negative) \ + _VOICEMSG(onmyway) \ + _VOICEMSG(seenenemy) \ + _VOICEMSG(getflag) \ + _VOICEMSG(droppedflag) \ + _VOICEMSG(getourflagback) \ + _VOICEMSG(flagcarriertakingdamage) +#define _VOICEMSG(m) .string playersound_##m; +ALLPLAYERSOUNDS +ALLVOICEMSGS +#undef _VOICEMSG string globalsound_fall; string globalsound_metalfall; string globalsound_step; -- 2.39.2