From: z411 Date: Wed, 5 May 2021 01:29:26 +0000 (-0400) Subject: Merged sv_announcer from SMB mod X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7ea478d284f9543a334bdcd0628556be59f59b77;p=xonotic%2Fxonotic-data.pk3dir.git Merged sv_announcer from SMB mod --- 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