From: Mario Date: Tue, 26 Dec 2017 13:40:12 +0000 (+1000) Subject: Reduce potential lag by only looping through a limited number of items (may increase... X-Git-Tag: xonotic-v0.8.5~2405 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=32c7f0d0047b1d919b83b754bb6fc733065ef85b;p=xonotic%2Fxonotic-data.pk3dir.git Reduce potential lag by only looping through a limited number of items (may increase the number of tries later if needed) --- diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index ef69905bd..8b4204b12 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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)