]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/teamplay.qc
Resolve conflicts 1: Merge commit 'c58baab5' into bones_was_here/q3compat
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / teamplay.qc
index ff6de57bc465ef5dcc1a81c5f9ebdf5c0dde156c..c26a0b16550ac51062a40c742468d5f93f214076 100644 (file)
@@ -44,11 +44,13 @@ string autocvar_g_forced_team_pink;
 
 entity g_team_entities[NUM_TEAMS]; ///< Holds global team entities.
 
-STATIC_INIT(g_team_entities)
+void Team_InitTeams()
 {
+       if (g_team_entities[0])
+               return;
        for (int i = 0; i < NUM_TEAMS; ++i)
        {
-               g_team_entities[i] = new_pure();
+               g_team_entities[i] = new_pure(team_entity);
        }
 }
 
@@ -205,38 +207,39 @@ bool Player_SetTeamIndex(entity player, int index)
 bool SetPlayerTeam(entity player, int team_index, int type)
 {
        int old_team_index = Entity_GetTeamIndex(player);
+
        if (!Player_SetTeamIndex(player, team_index))
-       {
                return false;
-       }
+
        LogTeamChange(player.playerid, player.team, type);
+
        if (team_index != old_team_index)
        {
-               PlayerScore_Clear(player);
-               if (team_index != -1)
-               {
-                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(
-                               player.team, INFO_JOIN_PLAY_TEAM), player.netname);
-               }
-               else
-               {
-                       if (!CS(player).just_joined)
-                       {
-                               Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE,
-                                       player.netname);
-                       }
-               }
                KillPlayerForTeamChange(player);
+               PlayerScore_Clear(player);
+               CS(player).parm_idlesince = time;
+
                if (!IS_BOT_CLIENT(player))
-               {
                        TeamBalance_AutoBalanceBots();
-               }
+
+               if (team_index != -1)
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(player.team, INFO_JOIN_PLAY_TEAM), player.netname);
        }
-       else if (team_index == -1)
+
+       if (team_index == -1)
        {
-               if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR)
+               if (autocvar_sv_maxidle_playertospectator > 0 && CS(player).idlekick_lasttimeleft)
+               {
+                       // this done here so it happens even when manually speccing during the countdown
+                       Kill_Notification(NOTIF_ONE_ONLY, player, MSG_CENTER, CPID_IDLING);
+                       CS(player).idlekick_lasttimeleft = 0;
+               }
+               else if (!CS(player).just_joined && player.frags != FRAGS_SPECTATOR)
+               {
                        Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_QUIT_SPECTATE, player.netname);
+               }
        }
+
        return true;
 }