From: Mario Date: Tue, 29 Nov 2016 04:32:13 +0000 (+1000) Subject: Add a hook to handle the message before anything has been replaced X-Git-Tag: xonotic-v0.8.2~406 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=ffb677bba14c81963045d979714dd5cce8053d20;p=xonotic%2Fxonotic-data.pk3dir.git Add a hook to handle the message before anything has been replaced --- diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index e90dbeb96..7f4899f12 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -238,6 +238,9 @@ string formatmessage(entity this, string msg) cursor = trace_endpos; cursor_ent = trace_ent; + MUTATOR_CALLHOOK(PreFormatMessage, this, msg); + msg = M_ARGV(1, string); + while (1) { if (n < 1) break; // too many replacements diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 21c8ef9a5..b6e8c7f4b 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -134,6 +134,14 @@ MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy); /**/ MUTATOR_HOOKABLE(FormatMessage, EV_FormatMessage); +/** called before any formatting is applied, handy for tweaking the message before scripts get ahold of it */ +#define EV_PreFormatMessage(i, o) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** message */ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(string, MUTATOR_ARGV_1_string) \ + /**/ +MUTATOR_HOOKABLE(PreFormatMessage, EV_PreFormatMessage); + /** returns true if throwing the current weapon shall not be allowed */ #define EV_ForbidThrowCurrentWeapon(i, o) \ /** player */ i(entity, MUTATOR_ARGV_0_entity) \