]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/arena_and_ca_fixes
authorterencehill <piuntn@gmail.com>
Wed, 11 Jan 2012 12:34:08 +0000 (13:34 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 11 Jan 2012 12:34:08 +0000 (13:34 +0100)
qcsrc/server/arena.qc
qcsrc/server/cl_client.qc
qcsrc/server/cl_player.qc
qcsrc/server/command/cmd.qc
qcsrc/server/sv_main.qc

index c89c2b2efada451a84b1990255d437641088195b..0262b89b896fa769f541b4e3620bb8cb1fc9e6df 100644 (file)
@@ -9,21 +9,12 @@ entity spawnqueue_first;
 entity spawnqueue_last;
 entity champion;
 float warmup;
-float ca_teams_ok;
 .float caplayer;
 
 void PutObserverInServer();
 void PutClientInServer();
-void(entity e) ReturnFlag;
-void dom_controlpoint_setup();
-void onslaught_generator_reset();
-void onslaught_controlpoint_reset();
-void func_breakable_reset();
-void assault_objective_reset();
-void target_assault_roundend_reset();
 
 float next_round;
-float stopalivecheck;
 float redalive, bluealive, yellowalive, pinkalive;
 float totalalive;
 .float redalive_stat, bluealive_stat, yellowalive_stat, pinkalive_stat;
@@ -196,25 +187,33 @@ void Spawnqueue_Mark(entity e)
  * Blocks the players movement while countdown is active.
  * Unblocks the player once the countdown is over.
  *
- * Called in PlayerPostThink()
+ * Called in StartFrame()
  */
 float roundStartTime_prev; // prevent networkspam
 void Arena_Warmup()
 {
        float f;
-    entity e;
+       entity e;
 
+       if(gameover)
+       {
+               if(champion && g_arena)
+               {
+                       FOR_EACH_REALCLIENT(e)
+                               centerprint(e, strcat("The Champion is ", champion.netname));
+                       champion = world;
+               }
+               return;
+       }
        if((!g_arena && !g_ca && !g_freezetag) || (g_arena && !arena_roundbased) || (time < game_starttime))
                return;
 
        f = ceil(warmup - time);
 
-       allowed_to_spawn = 0;
-
        if(inWarmupStage)
                allowed_to_spawn = 1;
-       if(g_ca && !ca_teams_ok)
-               allowed_to_spawn = 1;
+       else if(!g_ca)
+               allowed_to_spawn = 0;
 
        if(time < warmup && !inWarmupStage)
        {
@@ -222,57 +221,63 @@ void Arena_Warmup()
                        allowed_to_spawn = 1;
                if(champion && g_arena)
                {
-                       FOR_EACH_PLAYER(e)
+                       FOR_EACH_REALCLIENT(e)
                                centerprint(e, strcat("The Champion is ", champion.netname));
                }
 
                if(f != roundStartTime_prev) {
                        roundStartTime_prev = f;
-                       if(f == 5)
-                               Announce("prepareforbattle");
-                       else if(f == 3)
-                               Announce("3");
-                       else if(f == 2)
-                               Announce("2");
-                       else if(f == 1)
-                               Announce("1");
-
-                       FOR_EACH_PLAYER(e)
-                               Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
+                       if(g_ca && !(red_players && blue_players)) {
+                               FOR_EACH_REALCLIENT(self)
+                                       Send_CSQC_Centerprint_Generic(self, CPID_ROUND_STARTING, "^1Need at least 1 player in each team to play CA", 2, 0);
+                               warmup = time + autocvar_g_ca_warmup;
+                       } else {
+                               if(f == 5)
+                                       Announce("prepareforbattle");
+                               else if(f == 3)
+                                       Announce("3");
+                               else if(f == 2)
+                                       Announce("2");
+                               else if(f == 1)
+                                       Announce("1");
+
+                               FOR_EACH_REALCLIENT(e)
+                                       Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "Round will start in %d", 1, f);
+                       }
                }
 
                if (g_arena) {
-                       if(self.spawned && self.classname == "player")
-                               self.movetype = MOVETYPE_NONE;
-
-                       self.velocity = '0 0 0';
-                       self.avelocity = '0 0 0';
-                       self.movement = '0 0 0';
+                       FOR_EACH_CLIENT(e)
+                       {
+                               if(e.spawned && e.classname == "player")
+                                       e.movetype = MOVETYPE_NONE;
+                               e.velocity = '0 0 0';
+                               e.avelocity = '0 0 0';
+                               e.movement = '0 0 0';
+                       }
                }
        }
        else if(f > -1 && f != roundStartTime_prev)
        {
                roundStartTime_prev = f;
-               Announce("begin");
-               FOR_EACH_PLAYER(e)
-                       Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
-
                if(g_ca) {
-                       float start_red_ca_players, start_blue_ca_players;
+                       if(red_players && blue_players)
+                               allowed_to_spawn = 0;
+                       else
+                               reset_map(TRUE);
+               } else {
+                       Announce("begin");
+                       FOR_EACH_REALCLIENT(e)
+                               Send_CSQC_Centerprint_Generic(e, CPID_ROUND_STARTING, "^1Begin!", 1, 0);
+               }
 
-                       FOR_EACH_PLAYER(e) {
-                               if (e.team == COLOR_TEAM1)
-                                       start_red_ca_players += 1;
-                               else if (e.team == COLOR_TEAM2)
-                                       start_blue_ca_players += 1;
+               if(g_arena) {
+                       FOR_EACH_PLAYER(e)
+                       {
+                               if(e.health > 0 && e.movetype == MOVETYPE_NONE)
+                                       e.movetype = MOVETYPE_WALK;
                        }
-                       // teams are ok if there's at least 1 player in each team
-                       ca_teams_ok = (start_red_ca_players && start_blue_ca_players);
                }
-
-        if(self.classname == "player" && self.health > 0 && self.movetype == MOVETYPE_NONE)
-            self.movetype = MOVETYPE_WALK;
-
        }
 
        // clear champion to avoid centerprinting again the champion msg
@@ -372,61 +377,49 @@ void count_alive_players()
  *
  * Gets called in StartFrame()
  */
-float warntime;
 void Spawnqueue_Check()
 {
-       count_players();
-       if(g_ca || g_freezetag) // we want to perform this before the return block below (CA)...
+       if(warmup == 0 && g_ca)
        {
-               count_alive_players();
+               if(red_players || blue_players)
+                       reset_map(TRUE);
+               return;
        }
        if(time < warmup + 1 || inWarmupStage || intermission_running)
                return;
 
        if(g_ca) {
-               if(!ca_teams_ok && (red_players && blue_players)) {
-                       reset_map(TRUE);
-               }
-               else if(!ca_teams_ok) {
-                       if (time > warntime)
-                       {
-                               FOR_EACH_PLAYER(self)
-                                       Send_CSQC_Centerprint_Generic(self, CPID_ROUND_STARTING, "^1Need at least 1 player in each team to play CA", 2, 0);
-                               warntime = time + 1;
-                       }
+               if(allowed_to_spawn) // round is not started yet
                        return;
-               }
-               else if(!next_round) {
-                       if((red_players && !blue_players) || (blue_players && !red_players)) {
-                               next_round = time + 5;
+               if(!next_round) {
+                       if(!(redalive && bluealive)) {
+                               // every player of (at least) one team is dead, round ends here
+                               if(redalive) {
+                                       play2all("ctf/red_capture.wav");
+                                       FOR_EACH_CLIENT(self) centerprint(self, "^1RED ^7team wins the round");
+                                       TeamScore_AddToTeam(COLOR_TEAM1, ST_SCORE, +1);
+                               }
+                               else if(bluealive) {
+                                       play2all("ctf/blue_capture.wav");
+                                       FOR_EACH_CLIENT(self) centerprint(self, "^4BLUE ^7team wins the round");
+                                       TeamScore_AddToTeam(COLOR_TEAM2, ST_SCORE, +1);
+                               }
+                               else
+                                       FOR_EACH_CLIENT(self) centerprint(self, "^7Round tied");
+                               next_round = -1;
                        }
-                       else if((!red_players && !blue_players) || time - warmup > autocvar_g_ca_round_timelimit) {
+                       else if(time - warmup > autocvar_g_ca_round_timelimit) {
                                FOR_EACH_CLIENT(self) centerprint(self, "^7Round tied");
                                next_round = time + 5;
                        }
-
                }
-               if(!stopalivecheck)
-               {
-                       if(redalive && !bluealive)
-                       {
-                               play2all("ctf/red_capture.wav");
-                               FOR_EACH_CLIENT(self) centerprint(self, "^1RED ^7team wins the round");
-                               TeamScore_AddToTeam(COLOR_TEAM1, ST_SCORE, +1);
-                               stopalivecheck = TRUE;
-                       }
-                       else if(bluealive && !redalive)
-                       {
-                               play2all("ctf/blue_capture.wav");
-                               FOR_EACH_CLIENT(self) centerprint(self, "^4BLUE ^7team wins the round");
-                               TeamScore_AddToTeam(COLOR_TEAM2, ST_SCORE, +1);
-                               stopalivecheck = TRUE;
-                       }
+               else if(next_round == -1) {
+                       // wait for killed players to be put as spectators
+                       if(!(red_players && blue_players))
+                               next_round = time + 5;
                }
-
-               if((next_round && next_round < time))
+               else if((next_round > 0 && next_round < time))
                {
-                       stopalivecheck = FALSE;
                        next_round = 0;
                        reset_map(TRUE);
                }
index 298fd47e3c4f7273d3d461d14bf8ba041109bfc2..2ffc3e229eb28b4d509b3f5a5244dc51abb37386 100644 (file)
@@ -649,6 +649,8 @@ void PutClientInServer (void)
        if(clienttype(self) == CLIENTTYPE_BOT)
        {
                self.classname = "player";
+               if(g_ca)
+                       self.caplayer = 1;
        }
        else if(clienttype(self) == CLIENTTYPE_REAL)
        {
@@ -656,7 +658,7 @@ void PutClientInServer (void)
                WriteByte(MSG_ONE, SVC_SETVIEW);
                WriteEntity(MSG_ONE, self);
        }
-       
+
        // reset player keys
        self.itemkeys = 0;
 
@@ -668,8 +670,7 @@ void PutClientInServer (void)
                        self.classname = "observer";
        }
 
-       if(g_arena || (g_ca && !allowed_to_spawn))
-       if(!self.spawned)
+       if((g_arena && !self.spawned) || (g_ca && !allowed_to_spawn))
                self.classname = "observer";
 
        if(gameover)
@@ -828,13 +829,12 @@ void PutClientInServer (void)
                self.lastrocket = world; // stop rocket guiding, no revenge from the grave!
                self.lastteleporttime = time; // prevent insane speeds due to changing origin
         self.hud = HUD_NORMAL;
-        
+
                if(g_arena)
                {
                        Spawnqueue_Remove(self);
                        Spawnqueue_Mark(self);
                }
-
                else if(g_ca)
                        self.caplayer = 1;
 
@@ -918,7 +918,7 @@ void PutClientInServer (void)
                        self.alivetime = time;
 
                antilag_clear(self);
-       } else if(self.classname == "observer" || (g_ca && !allowed_to_spawn)) {
+       } else if(self.classname == "observer") {
                PutObserverInServer ();
        }
 
@@ -2992,8 +2992,6 @@ void PlayerPostThink (void)
        }
        */
 
-       Arena_Warmup();
-
        //pointparticles(particleeffectnum("machinegun_impact"), self.origin + self.view_ofs + '0 0 7', '0 0 0', 1);
 
        if(self.waypointsprite_attachedforcarrier)
index 15173b9ad4bfccb434c1d52980ccee57e3e21d76..bdc30de4c5e14df5ff9ef4486e16e793b76c0c79 100644 (file)
@@ -434,7 +434,7 @@ void PlayerDamage (entity inflictor, entity attacker, float damage, float deatht
        float valid_damage_for_weaponstats;
        float excess;
 
-       if((g_arena && numspawned < 2) || (g_ca && !ca_teams_ok) && !inWarmupStage)
+       if((g_arena && numspawned < 2) || (g_ca && allowed_to_spawn) && !inWarmupStage)
                return;
 
        dh = max(self.health, 0);
index e8a6207314af6c8b23a0152e88b1ab9ae1d9cf93..8be0ad576bc81cff5a25302cf4820f085417dd5f 100644 (file)
@@ -445,7 +445,7 @@ void ClientCommand_spectate(float request)
                                if(self.classname == "player" && autocvar_sv_spectate == 1) 
                                        ClientKill_TeamChange(-2); // observe
                                
-                               // in CA, allow a dead player to move to spectatators (without that, caplayer!=0 will be moved back to the player list)
+                               // in CA, allow a dead player to move to spectators (without that, caplayer!=0 will be moved back to the player list)
                                // note: if arena game mode is ever done properly, this needs to be removed.
                                if(g_ca && self.caplayer && (self.classname == "spectator" || self.classname == "observer"))
                                {
index 73c444afec7b8637e0481ecb18ba133d01f471a1..f8289317d87d9368126b0c985c531b75cb4762cc 100644 (file)
@@ -201,9 +201,12 @@ void StartFrame (void)
 
        skill = autocvar_skill;
 
+       count_players();
+       if(g_ca || g_freezetag)
+               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;