From: terencehill Date: Sun, 22 Jul 2018 13:32:21 +0000 (+0200) Subject: Avoid wasting a WarpZone_crosshair_trace call in every chat message if there is no... X-Git-Tag: xonotic-v0.8.5~1930^2~3 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f2decf529cf30bb417b09c24cf6e7db5619135c6;p=xonotic%2Fxonotic-data.pk3dir.git Avoid wasting a WarpZone_crosshair_trace call in every chat message if there is no placeholder --- diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index e4e3abace..a9d50e7ba 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -224,25 +224,13 @@ string formatmessage(entity this, string msg) { float p, p1, p2; float n; - vector cursor; - entity cursor_ent; + vector cursor = '0 0 0'; + entity cursor_ent = NULL; string escape; string replacement; p = 0; n = 7; - - IL_EACH(g_items, true, - { - it.old_solid = it.solid; - it.solid = SOLID_BSP; - }); - WarpZone_crosshair_trace(this); - IL_EACH(g_items, true, - { - it.solid = it.old_solid; - }); - cursor = trace_endpos; - cursor_ent = trace_ent; + bool traced = false; MUTATOR_CALLHOOK(PreFormatMessage, this, msg); msg = M_ARGV(1, string); @@ -265,6 +253,23 @@ string formatmessage(entity this, string msg) if (p < 0) break; + + if(!traced) + { + IL_EACH(g_items, true, + { + it.old_solid = it.solid; + it.solid = SOLID_BSP; + }); + WarpZone_crosshair_trace(this); + IL_EACH(g_items, true, + { + it.solid = it.old_solid; + }); + cursor = trace_endpos; + cursor_ent = trace_ent; + traced = true; + } replacement = substring(msg, p, 2); escape = substring(msg, p + 1, 1);