]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Remove AvailableTeams(), instead store team number in existing teamplay global
authorbones_was_here <bones_was_here@xonotic.au>
Mon, 26 Sep 2022 05:21:46 +0000 (15:21 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Mon, 26 Sep 2022 05:21:46 +0000 (15:21 +1000)
qcsrc/common/gamemodes/sv_rules.qc
qcsrc/server/bot/default/bot.qc
qcsrc/server/client.qc
qcsrc/server/intermission.qc
qcsrc/server/scores_rules.qc
qcsrc/server/scores_rules.qh
qcsrc/server/teamplay.qc

index 84d89909fe98274f47eb44e51999758f9371dbb6..d7f5006d45886d4677d75a13b80cb1aada70fb11 100644 (file)
@@ -7,7 +7,7 @@ void GameRules_teams(bool value)
 {
     if (value) {
         serverflags |= SERVERFLAG_TEAMPLAY;
-        teamplay = 1;
+        teamplay = 1;  // aka AVAILABLE_TEAMS, updated by ScoreRules_basics() after team ents spawn
         cvar_set("teamplay", "2");  // DP needs this for sending proper getstatus replies.
         Team_InitTeams();
         GameRules_spawning_teams(true);
index 79b3a96924754bf066ef762b7d602c03faa9ca8b..01a66b2c12587764d8bd1f94f1050b46db0ba9f7 100644 (file)
@@ -170,7 +170,7 @@ void bot_setnameandstuff(entity this)
                int smallest_count = -1;
                if (teamplay)
                {
-                       for (int i = 1; i <= AvailableTeams(); ++i)
+                       for (int i = 1; i <= AVAILABLE_TEAMS; ++i)
                        {
                                // NOTE if (autocvar_g_campaign && autocvar_g_campaign_forceteam == i)
                                // TeamBalance_GetNumberOfPlayers(balance, i); returns the number of players + 1
@@ -210,7 +210,7 @@ void bot_setnameandstuff(entity this)
                        });
                        if (!conflict)
                                prio += 1;
-                       if (teamplay && !(autocvar_bot_vs_human && AvailableTeams() == 2))
+                       if (teamplay && !(autocvar_bot_vs_human && AVAILABLE_TEAMS == 2))
                        {
                                int forced_team = stof(argv(5));
                                if (!Team_IsValidIndex(forced_team))
@@ -242,7 +242,7 @@ void bot_setnameandstuff(entity this)
        if(argv(4) != "" && stof(argv(4)) >= 0) bot_pants = argv(4);
        else bot_pants = ftos(floor(random() * 15));
 
-       if (teamplay && !(autocvar_bot_vs_human && AvailableTeams() == 2))
+       if (teamplay && !(autocvar_bot_vs_human && AVAILABLE_TEAMS == 2))
        {
                this.bot_forced_team = stof(argv(5));
                if (!Team_IsValidIndex(this.bot_forced_team))
@@ -611,13 +611,13 @@ bool bot_fixcount(bool multiple_per_frame)
        // But don't remove bots immediately on level change, as the real players
        // usually haven't rejoined yet
        bots_would_leave = false;
-       if (teamplay && autocvar_bot_vs_human && AvailableTeams() == 2)
+       if (autocvar_bot_vs_human && AVAILABLE_TEAMS == 2)
                bots = min(ceil(fabs(autocvar_bot_vs_human) * activerealplayers), maxclients - realplayers);
        else if ((realplayers || autocvar_bot_join_empty || (currentbots > 0 && time < 5)))
        {
                int minplayers = max(0, floor(autocvar_minplayers));
                if (teamplay)
-                       minplayers = max(0, floor(autocvar_minplayers_per_team) * AvailableTeams());
+                       minplayers = max(0, floor(autocvar_minplayers_per_team) * AVAILABLE_TEAMS);
                int minbots = max(0, floor(autocvar_bot_number));
 
                // add bots to reach minplayers if needed
index 5843e02a35349114d6aad6b76d59c22aa943d37d..8c974b28afa84d841bc5f4c6afcab5990da1df0e 100644 (file)
@@ -1150,7 +1150,7 @@ void ClientConnect(entity this)
        if (!autocvar_sv_foginterval && world.fog != "")
                stuffcmd(this, strcat("\nfog ", world.fog, "\nr_fog_exp2 0\nr_drawfog 1\n"));
 
-       if (autocvar_sv_teamnagger && !(autocvar_bot_vs_human && AvailableTeams() == 2))
+       if (autocvar_sv_teamnagger && !(autocvar_bot_vs_human && AVAILABLE_TEAMS == 2))
                if(!MUTATOR_CALLHOOK(HideTeamNagger, this))
                        send_CSQC_teamnagger();
 
index e9c622be48abde7bcfc5049a10660ea6f9e01319..b2652f7d8d9b27cc0da41d128d31bccf88383603 100644 (file)
@@ -54,7 +54,7 @@ bool MapHasRightSize(string map)
 {
        int minplayers = max(0, floor(autocvar_minplayers));
        if (teamplay)
-               minplayers = max(0, floor(autocvar_minplayers_per_team) * AvailableTeams());
+               minplayers = max(0, floor(autocvar_minplayers_per_team) * AVAILABLE_TEAMS);
        if (autocvar_g_maplist_check_waypoints
                && (currentbots || autocvar_bot_number || player_count < minplayers))
        {
index 2749db38e63c081aa3aa9425c0e674c4e10c270e..64dfbb03b20529ceebfd1f7bbf1140fbe71e00b6 100644 (file)
@@ -19,11 +19,6 @@ int NumTeams(int teams)
        return boolean(teams & BIT(0)) + boolean(teams & BIT(1)) + boolean(teams & BIT(2)) + boolean(teams & BIT(3));
 }
 
-int AvailableTeams()
-{
-       return NumTeams(ScoreRules_teams);
-}
-
 // NOTE: ST_constants may not be >= MAX_TEAMSCORE
 // scores that should be in all modes:
 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled)
@@ -35,6 +30,7 @@ void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled
                ScoreInfo_SetLabel_TeamScore(i, "", 0);
 
        ScoreRules_teams = teams;
+       AVAILABLE_TEAMS = NumTeams(teams);
 
        if(score_enabled)
                ScoreInfo_SetLabel_TeamScore(ST_SCORE, "score", stprio);
index 921864d2622bca71412fcff9bcc3cd186ac8a0d6..2978c217ef4d18ccceffdaaf8c846f8f4dc89911 100644 (file)
@@ -2,7 +2,8 @@
 
 bool IsTeamAvailable(int team_num);
 int NumTeams(int teams);
-int AvailableTeams();
 void ScoreRules_basics(int teams, float sprio, float stprio, float score_enabled);
 void ScoreRules_basics_end();
 void ScoreRules_generic();
+
+#define AVAILABLE_TEAMS teamplay
index 0d248ca1382290ab28885e07fa73a0c47ad3eaee..c7c939d74d6e4f3c553f958b611f8008aec2c1a3 100644 (file)
@@ -527,7 +527,7 @@ entity TeamBalance_CheckAllowedTeams(entity for_whom)
        }
 
        // TODO: Balance quantity of bots across > 2 teams when bot_vs_human is set (and remove next line)
-       if (autocvar_bot_vs_human && AvailableTeams() == 2 && for_whom)
+       if (autocvar_bot_vs_human && AVAILABLE_TEAMS == 2 && for_whom)
        {
                if (autocvar_bot_vs_human > 0)
                {