From 3068527d9b5e3d425c0aa6262b2b20c54b8eb69a Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 20 Jun 2018 18:02:45 +1000 Subject: [PATCH] Cache the result of the find for testplayerstart to reduce load a tiny bit --- qcsrc/server/spawnpoints.qc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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) -- 2.39.2