]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Reduce potential lag by only looping through a limited number of items (may increase...
authorMario <mario@smbclan.net>
Tue, 26 Dec 2017 13:40:12 +0000 (23:40 +1000)
committerMario <mario@smbclan.net>
Tue, 26 Dec 2017 13:40:12 +0000 (23:40 +1000)
qcsrc/server/miscfunctions.qc

index ef69905bdcfbdcbc561ad7e782acb06923b2574e..8b4204b126dfa1d1b44306a0abc51222391bc837 100644 (file)
@@ -1244,6 +1244,7 @@ float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundma
     });
        if(!sp)
        {
+               int items_checked = 0;
                IL_EACH(g_items, checkpvs(mstart, it),
                {
                        if((traceline(mstart, it.origin + (it.mins + it.maxs) * 0.5, MOVE_NORMAL, e), trace_fraction) >= 1)
@@ -1251,6 +1252,10 @@ float MoveToRandomLocationWithinBounds(entity e, vector boundmin, vector boundma
                                sp = it;
                                break;
                        }
+
+                       ++items_checked;
+                       if(items_checked >= attempts)
+                               break; // sanity
                });
 
                if(!sp)