]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Avoid wasting a WarpZone_crosshair_trace call in every chat message if there is no...
authorterencehill <piuntn@gmail.com>
Sun, 22 Jul 2018 13:32:21 +0000 (15:32 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 22 Jul 2018 13:32:21 +0000 (15:32 +0200)
qcsrc/server/miscfunctions.qc

index e4e3abace5d370008b45e64b7b1256bc5287170f..a9d50e7ba9b51c7be0f5b90a10a23f45cd79a7fb 100644 (file)
@@ -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);