]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add proper checks to avoid executing code that other game types don't need
authorterencehill <piuntn@gmail.com>
Fri, 23 Nov 2012 15:37:00 +0000 (16:37 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 23 Nov 2012 15:37:00 +0000 (16:37 +0100)
qcsrc/server/arena.qc
qcsrc/server/sv_main.qc

index ce1af0f1350748963d0938961bfb095464696460..6a22b1c5f0091b036d55909aa014c59e2e064f71 100644 (file)
@@ -49,12 +49,12 @@ void reset_map(float dorespawn)
                if(autocvar_g_freezetag_warmup > 0)
                        warmup += autocvar_g_freezetag_warmup;
        }
+       else if(g_race || g_cts)
+               race_ReadyRestart();
 
        lms_lowest_lives = 999;
        lms_next_place = player_count;
 
-       race_ReadyRestart();
-
        for(self = world; (self = nextent(self)); )
        if(clienttype(self) == CLIENTTYPE_NOTACLIENT)
        {
@@ -220,7 +220,7 @@ void Arena_Warmup()
                }
                return;
        }
-       if((!g_arena && !g_ca && !g_freezetag) || (g_arena && !arena_roundbased) || (time < game_starttime))
+       if(time < game_starttime)
                return;
 
        f = ceil(warmup - time);
@@ -327,19 +327,16 @@ void count_players()
 
 void count_alive_players()
 {
-       if(g_ca)
-       {
-               redalive = bluealive = yellowalive = pinkalive = 0;
-               FOR_EACH_PLAYER(self) {
-                       if (self.team == COLOR_TEAM1 && self.health >= 1)
-                               redalive += 1;
-                       else if (self.team == COLOR_TEAM2 && self.health >= 1)
-                               bluealive += 1;
-               }
-               FOR_EACH_REALCLIENT(self) {
-                       self.redalive_stat = redalive;
-                       self.bluealive_stat = bluealive;
-               }
+       redalive = bluealive = yellowalive = pinkalive = 0;
+       FOR_EACH_PLAYER(self) {
+               if (self.team == COLOR_TEAM1 && self.health >= 1)
+                       redalive += 1;
+               else if (self.team == COLOR_TEAM2 && self.health >= 1)
+                       bluealive += 1;
+       }
+       FOR_EACH_REALCLIENT(self) {
+               self.redalive_stat = redalive;
+               self.bluealive_stat = bluealive;
        }
 }
 
@@ -435,3 +432,22 @@ void Spawnqueue_Check()
                }
        }
 }
+
+void Arena_Main()
+{
+       if(!(g_ca || g_freezetag || g_arena))
+               return;
+
+       if(g_ca || g_freezetag)
+       {
+               count_players();
+               if(g_ca)
+                       count_alive_players();
+               Arena_Warmup();
+       }
+       else if(arena_roundbased)
+               Arena_Warmup();
+
+       Spawnqueue_Check();
+}
+
index 0da9607f2b45c86bfa8495643bab6071833045ea..d2b2d594fedf53a46444cfdcf1390916ae8ab347 100644 (file)
@@ -146,6 +146,7 @@ Called before each frame by the server
 float game_delay;
 float game_delay_last;
 
+void Arena_Main();
 void RuneMatchGivePoints();
 float RedirectionThink();
 entity SelectSpawnPoint (float anypoint);
@@ -203,12 +204,6 @@ void StartFrame (void)
 
        skill = autocvar_skill;
 
-       count_players();
-       if(g_ca)
-               count_alive_players();
-       Arena_Warmup();
-       Spawnqueue_Check();
-
        // detect when the pre-game countdown (if any) has ended and the game has started
        game_delay = (time < game_starttime) ? TRUE : FALSE;
 
@@ -228,6 +223,8 @@ void StartFrame (void)
                return;
        }
 
+       Arena_Main();
+
        CreatureFrame ();
        CheckRules_World ();