From: terencehill Date: Fri, 23 Nov 2012 15:37:00 +0000 (+0100) Subject: Add proper checks to avoid executing code that other game types don't need X-Git-Tag: xonotic-v0.7.0~61^2~112 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5a0629fd4de6d96dbd9cc59b368c1c27fb99def7;p=xonotic%2Fxonotic-data.pk3dir.git Add proper checks to avoid executing code that other game types don't need --- diff --git a/qcsrc/server/arena.qc b/qcsrc/server/arena.qc index ce1af0f13..6a22b1c5f 100644 --- a/qcsrc/server/arena.qc +++ b/qcsrc/server/arena.qc @@ -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(); +} + diff --git a/qcsrc/server/sv_main.qc b/qcsrc/server/sv_main.qc index 0da9607f2..d2b2d594f 100644 --- a/qcsrc/server/sv_main.qc +++ b/qcsrc/server/sv_main.qc @@ -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 ();