From 7ea478d284f9543a334bdcd0628556be59f59b77 Mon Sep 17 00:00:00 2001 From: z411 Date: Tue, 4 May 2021 21:29:26 -0400 Subject: [PATCH] Merged sv_announcer from SMB mod --- qcsrc/common/_all.inc | 2 ++ qcsrc/common/announcer.qc | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 qcsrc/common/announcer.qc diff --git a/qcsrc/common/_all.inc b/qcsrc/common/_all.inc index fa80064c9..bb090b99c 100644 --- a/qcsrc/common/_all.inc +++ b/qcsrc/common/_all.inc @@ -1,5 +1,7 @@ noref float autocvar_net_connecttimeout = 30; +#include "announcer.qc" + #ifdef GAMEQC #include "anim.qc" #include "animdecide.qc" diff --git a/qcsrc/common/announcer.qc b/qcsrc/common/announcer.qc new file mode 100644 index 000000000..02583c36f --- /dev/null +++ b/qcsrc/common/announcer.qc @@ -0,0 +1,45 @@ +//FEATURE: Custom default announcers on the server side, that clients can override if desired + +#ifdef GAMEQC +REGISTER_MUTATOR(announcer, true); +#endif + +#ifdef SVQC + +AUTOCVAR(sv_announcer, string, "", "Force client announcer to this"); + +MUTATOR_HOOKFUNCTION(announcer, Ent_Init, CBC_ORDER_FIRST) +{ + WriteString(MSG_ONE, autocvar_sv_announcer); +} + +#elif defined(CSQC) + +string sv_announcer; + +AUTOCVAR_SAVE(cl_announcer_force, bool, false, "Don't allow server to override default announcer"); + +void Announcer_Precache() +{ + FOREACH(Notifications, it.nent_type == MSG_ANNCE, { + if(it.nent_enabled) + precache_sound(sprintf("announcer/%s/%s.wav", AnnouncerOption(), it.nent_snd)); + }); +} + +MUTATOR_HOOKFUNCTION(announcer, AnnouncerOption) +{ + if(autocvar_cl_announcer_force || sv_announcer == "" || !sv_announcer || autocvar_cl_announcer != "default") + return false; + + M_ARGV(0, string) = sv_announcer; +} + +MUTATOR_HOOKFUNCTION(announcer, Ent_Init, CBC_ORDER_FIRST) +{ + sv_announcer = strzone(ReadString()); + + if(sv_announcer != "" && sv_announcer) { Announcer_Precache(); } +} + +#endif -- 2.39.2