From: Mario Date: Wed, 20 Jun 2018 08:02:45 +0000 (+1000) Subject: Cache the result of the find for testplayerstart to reduce load a tiny bit X-Git-Tag: xonotic-v0.8.5~2000 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3068527d9b5e3d425c0aa6262b2b20c54b8eb69a;p=xonotic%2Fxonotic-data.pk3dir.git Cache the result of the find for testplayerstart to reduce load a tiny bit --- diff --git a/qcsrc/server/spawnpoints.qc b/qcsrc/server/spawnpoints.qc index dcf6016c5..a57c9e435 100644 --- a/qcsrc/server/spawnpoints.qc +++ b/qcsrc/server/spawnpoints.qc @@ -327,14 +327,21 @@ SelectSpawnPoint Finds a point to respawn ============= */ +bool testspawn_checked; +entity testspawn_point; entity SelectSpawnPoint(entity this, bool anypoint) { float teamcheck; - entity spot, firstspot; + entity spot = NULL; - spot = find(NULL, classname, "testplayerstart"); - if (spot) - return spot; + if(!testspawn_checked) + { + testspawn_point = find(NULL, classname, "testplayerstart"); + testspawn_checked = true; + } + + if(testspawn_point) + return testspawn_point; if(this.spawnpoint_targ) return this.spawnpoint_targ; @@ -365,7 +372,7 @@ entity SelectSpawnPoint(entity this, bool anypoint) // get the entire list of spots - firstspot = findchain(classname, "info_player_deathmatch"); + entity firstspot = findchain(classname, "info_player_deathmatch"); // filter out the bad ones // (note this returns the original list if none survived) if(anypoint)