]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cache the result of the find for testplayerstart to reduce load a tiny bit
authorMario <mario@smbclan.net>
Wed, 20 Jun 2018 08:02:45 +0000 (18:02 +1000)
committerMario <mario@smbclan.net>
Wed, 20 Jun 2018 08:02:45 +0000 (18:02 +1000)
qcsrc/server/spawnpoints.qc

index dcf6016c5e326b902e8c59f06519ab86215ee707..a57c9e4350d587afd19e232848d167f6b68b8840 100644 (file)
@@ -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)