]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merged sv_announcer from SMB mod
authorz411 <z411@omaera.org>
Wed, 5 May 2021 01:29:26 +0000 (21:29 -0400)
committerz411 <z411@omaera.org>
Wed, 5 May 2021 01:29:26 +0000 (21:29 -0400)
qcsrc/common/_all.inc
qcsrc/common/announcer.qc [new file with mode: 0644]

index fa80064c9aeeaf86ca9227c377e8b0be0980b82a..bb090b99c40e527d0b09b2e47cce7ee3521f8a79 100644 (file)
@@ -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 (file)
index 0000000..02583c3
--- /dev/null
@@ -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