]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Renamed team conversion functions.
authorLyberta <lyberta@lyberta.net>
Fri, 9 Mar 2018 13:35:00 +0000 (16:35 +0300)
committerLyberta <lyberta@lyberta.net>
Fri, 9 Mar 2018 13:35:00 +0000 (16:35 +0300)
qcsrc/common/effects/all.inc
qcsrc/common/gamemodes/gamemode/nexball/nexball.qc
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/common/teams.qh
qcsrc/server/bot/default/bot.qc
qcsrc/server/command/cmd.qc
qcsrc/server/command/sv_cmd.qc
qcsrc/server/g_world.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/teamplay.qc

index 6439a49bb21ce32c6c64bbc8814f37dbb8f5520d..2114bdd658429aed812160c02b9bff78d9b9912c 100644 (file)
@@ -258,6 +258,6 @@ entity EFFECT_ROCKETMINSTA_LASER(int teamid)
         case NUM_TEAM_4:    e = EFFECT_ROCKETMINSTA_LASER_PINK; break;
         default:            e = EFFECT_ROCKETMINSTA_LASER_NEUTRAL; break;
     }
-    if (particleeffectnum(e) < 0 || Team_TeamToNumber(teamid) == -1) { e = EFFECT_TR_NEXUIZPLASMA; }
+    if (particleeffectnum(e) < 0 || Team_TeamToIndex(teamid) == -1) { e = EFFECT_TR_NEXUIZPLASMA; }
     return e;
 }
index e4b755fc42111e168c351e44340acee6e05008c2..f208c151212f669c9ba8d21b128c9274dbd4d2bc 100644 (file)
@@ -635,7 +635,7 @@ void SpawnGoal(entity this)
 
        EXACTTRIGGER_INIT;
 
-       if(this.team != GOAL_OUT && Team_TeamToNumber(this.team) != -1)
+       if(this.team != GOAL_OUT && Team_IsValidTeam(this.team))
        {
                entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (this.absmin + this.absmax) * 0.5, this, sprite, RADARICON_NONE);
                wp.colormod = ((this.team) ? Team_ColorRGB(this.team) : '1 0.5 0');
index 8fc4d89c4afbfbf74df86f69606c2f660fe73746..2536af659be736c0ed3412870346db986bc42026 100644 (file)
@@ -1929,7 +1929,7 @@ MUTATOR_HOOKFUNCTION(ons, TeamBalance_CheckAllowedTeams)
        {
                if (Team_IsValidTeam(tmp_entity.team))
                {
-                       M_ARGV(0, float) |= BIT(Team_TeamToNumber(tmp_entity.team) - 1);
+                       M_ARGV(0, float) |= Team_TeamToBit(tmp_entity.team);
                }
        }
 
index 1b03540dd7fd008dfe45dda3d461a34ac63cdc02..88666db0e836a1b3592987d969eed7b091cfd940 100644 (file)
@@ -127,12 +127,12 @@ float Team_ColorToTeam(string team_color)
        return -1;
 }
 
-/// \brief Returns whether team is valid.
-/// \param[in] team_ Team to check.
+/// \brief Returns whether team value is valid.
+/// \param[in] team_num Team to check.
 /// \return True if team is valid, false otherwise.
-bool Team_IsValidTeam(int team_)
+bool Team_IsValidTeam(int team_num)
 {
-       switch (team_)
+       switch (team_num)
        {
                case NUM_TEAM_1:
                case NUM_TEAM_2:
@@ -163,32 +163,48 @@ bool Team_IsValidIndex(int index)
        return false;
 }
 
-float Team_NumberToTeam(float number)
+/// \brief Converts team index into team value.
+/// \param[in] index Team index to convert.
+/// \return Team value.
+int Team_IndexToTeam(int index)
 {
-       switch(number)
+       switch (index)
        {
                case 1: return NUM_TEAM_1;
                case 2: return NUM_TEAM_2;
                case 3: return NUM_TEAM_3;
                case 4: return NUM_TEAM_4;
        }
-
        return -1;
 }
 
-float Team_TeamToNumber(float teamid)
+/// \brief Converts team value into team index.
+/// \param[in] team_ Team value to convert.
+/// \return Team index.
+int Team_TeamToIndex(int team_)
 {
-       switch(teamid)
+       switch (team_)
        {
                case NUM_TEAM_1: return 1;
                case NUM_TEAM_2: return 2;
                case NUM_TEAM_3: return 3;
                case NUM_TEAM_4: return 4;
        }
-
        return -1;
 }
 
+/// \brief Converts team value into bit value that is used in team bitmasks.
+/// \param[in] team_num Team value to convert.
+/// \return Team bit.
+int Team_TeamToBit(int team_num)
+{
+       if (!Team_IsValidTeam(team_num))
+       {
+               return 0;
+       }
+       return BIT(Team_TeamToIndex(team_num) - 1);
+}
+
 /// \brief Converts team index into bit value that is used in team bitmasks.
 /// \param[in] index Team index to convert.
 /// \return Team bit.
@@ -199,8 +215,8 @@ int Team_IndexToBit(int index)
 
 
 // legacy aliases for shitty code
-#define TeamByColor(teamid) (Team_TeamToNumber(teamid) - 1)
-#define ColorByTeam(number) Team_NumberToTeam(number + 1)
+#define TeamByColor(teamid) (Team_TeamToIndex(teamid) - 1)
+#define ColorByTeam(number) Team_IndexToTeam(number + 1)
 
 // useful aliases
 #define Team_ColorName_Lower(teamid) strtolower(Team_ColorName(teamid))
@@ -213,8 +229,8 @@ int Team_IndexToBit(int index)
 #define Team_FullName(teamid) strcat(Team_ColorName(teamid), " ", NAME_TEAM, "^7")
 #define Team_ColoredFullName(teamid) strcat(Team_ColorCode(teamid), Team_ColorName(teamid), " ", NAME_TEAM, "^7")
 
-#define Team_NumberToFullName(number) Team_FullName(Team_NumberToTeam(number))
-#define Team_NumberToColoredFullName(number) Team_ColoredFullName(Team_NumberToTeam(number))
+#define Team_IndexToFullName(index) Team_FullName(Team_IndexToTeam(index))
+#define Team_IndexToColoredFullName(index) Team_ColoredFullName(Team_IndexToTeam(index))
 
 // replace these flags in a string with the strings provided
 #define TCR(input,type,team) strreplace("^TC", COL_TEAM_##team, strreplace("^TT", strtoupper(type##_TEAM_##team), input))
index 3ce03694cd4ca9b8c223bc47f4560726509d8949..667fb2b3d577514ac80daf232ec468032516dbec 100644 (file)
@@ -468,7 +468,7 @@ void bot_removefromlargestteam()
                if (Team_IsValidTeam(it.team))
                {
                        thiscount = TeamBalance_GetNumberOfPlayers(balance,
-                               Team_TeamToNumber(it.team));
+                               Team_TeamToIndex(it.team));
                }
 
                if(thiscount > bestcount)
index af228f729333bccaac7823ec8fb113fb219d0ab0..3be9fe0ddee779fcbc652f5a1d3bf563bee52836 100644 (file)
@@ -396,7 +396,7 @@ void ClientCommand_selectteam(entity caller, float request, float argc)
                        {
                                entity balance = TeamBalance_CheckAllowedTeams(caller);
                                TeamBalance_GetTeamCounts(balance, caller);
-                               if ((Team_IndexToBit(Team_TeamToNumber(selection)) &
+                               if ((Team_IndexToBit(Team_TeamToIndex(selection)) &
                                        TeamBalance_FindBestTeams(balance, caller, false)) == 0)
                                {
                                        Send_Notification(NOTIF_ONE, caller, MSG_INFO, INFO_TEAMCHANGE_LARGERTEAM);
index 9d8c901dbbde5634925c72ef4242ae14458e9563..aac3210398ca96b6593269756dae58ea41d71e3c 100644 (file)
@@ -1074,7 +1074,7 @@ void GameCommand_moveplayer(float request, float argc)
                                                                else if (team_id == 0)  // auto team
                                                                {
                                                                        balance = TeamBalance_CheckAllowedTeams(client);
-                                                                       team_id = Team_NumberToTeam(TeamBalance_FindBestTeam(balance, client, false));
+                                                                       team_id = Team_IndexToTeam(TeamBalance_FindBestTeam(balance, client, false));
                                                                }
                                                                else
                                                                {
@@ -1421,7 +1421,7 @@ void GameCommand_shuffleteams(float request)
 
                        int team_index = 0;
                        FOREACH_CLIENT_RANDOM(IS_PLAYER(it) || it.caplayer, {
-                               int target_team_number = Team_NumberToTeam(team_index + 1);
+                               int target_team_number = Team_IndexToTeam(team_index + 1);
                                if (it.team != target_team_number) MoveToTeam(it, target_team_number, 6);
                                team_index = (team_index + 1) % number_of_teams;
                        });
index 4777524f0bd82e174b6f76c2cf6696d78425d762..b0a033391aea124ebc226e35d284d6dc952e1aac 100644 (file)
@@ -1693,7 +1693,7 @@ float WinningCondition_Scores(float limit, float leadlimit)
                for (int i = 1; i < 5; ++i)
                {
                        Team_SetTeamScore(Team_GetTeamFromIndex(i),
-                               TeamScore_GetCompareValue(Team_NumberToTeam(i)));
+                               TeamScore_GetCompareValue(Team_IndexToTeam(i)));
                }
        }
 
@@ -1819,7 +1819,7 @@ float WinningCondition_RanOutOfSpawns()
                                {
                                        continue;
                                }
-                               TeamScore_AddToTeam(Team_NumberToTeam(j), i, -1000);
+                               TeamScore_AddToTeam(Team_IndexToTeam(j), i, -1000);
                        }
                }
 
index dec8ac5a91301a05e7ae43bcd5e17cc266520f1b..7febaed8a75551be9a17cd4f6f42d194d4f4b990 100644 (file)
@@ -428,7 +428,7 @@ MUTATOR_HOOKFUNCTION(dom, TeamBalance_CheckAllowedTeams)
                {
                        if (Team_IsValidTeam(head.team))
                        {
-                               M_ARGV(0, float) |= BIT(Team_TeamToNumber(head.team) - 1);
+                               M_ARGV(0, float) |= Team_TeamToBit(head.team);
                        }
                }
 
index 3b31565596ebfd3459c3eb754d5faab483e18eee..d239ec32dd1173e91b7bf49cc1cdbb0bfa7e1396 100644 (file)
@@ -62,7 +62,7 @@ entity Team_GetTeam(int team_num)
        {
                LOG_FATALF("Team_GetTeam: Value is invalid: %f", team_num);
        }
-       return g_team_entities[Team_TeamToNumber(team_num) - 1];
+       return g_team_entities[Team_TeamToIndex(team_num) - 1];
 }
 
 float Team_GetTeamScore(entity team_)
@@ -263,8 +263,8 @@ bool SetPlayerTeamSimple(entity player, int team_num)
                SetPlayerColors(player, team_num - 1);
                return true;
        }
-       if (MUTATOR_CALLHOOK(Player_ChangeTeam, player, Team_TeamToNumber(
-               player.team), Team_TeamToNumber(team_num)) == true)
+       if (MUTATOR_CALLHOOK(Player_ChangeTeam, player, Team_TeamToIndex(
+               player.team), Team_TeamToIndex(team_num)) == true)
        {
                // Mutator has blocked team change.
                return false;
@@ -278,7 +278,7 @@ bool SetPlayerTeamSimple(entity player, int team_num)
 bool SetPlayerTeam(entity player, int destination_team_index,
        int source_team_index, bool no_print)
 {
-       int team_num = Team_NumberToTeam(destination_team_index);
+       int team_num = Team_IndexToTeam(destination_team_index);
        if (!SetPlayerTeamSimple(player, team_num))
        {
                return false;
@@ -289,8 +289,8 @@ bool SetPlayerTeam(entity player, int destination_team_index,
                return true;
        }
        bprint(playername(player, false), "^7 has changed from ",
-               Team_NumberToColoredFullName(source_team_index), "^7 to ",
-               Team_NumberToColoredFullName(destination_team_index), "\n");
+               Team_IndexToColoredFullName(source_team_index), "^7 to ",
+               Team_IndexToColoredFullName(destination_team_index), "\n");
        return true;
 }
 
@@ -424,7 +424,7 @@ entity TeamBalance_CheckAllowedTeams(entity for_whom)
        // if player has a forced team, ONLY allow that one
        for (int i = 1; i <= NUM_TEAMS; ++i)
        {
-               if (for_whom.team_forced == Team_NumberToTeam(i) &&
+               if (for_whom.team_forced == Team_IndexToTeam(i) &&
                        TeamBalance_IsTeamAllowedInternal(balance, i))
                {
                        TeamBalance_BanTeamsExcept(balance, i);
@@ -508,7 +508,7 @@ void TeamBalance_GetTeamCounts(entity balance, entity ignore)
                        entity team_ = TeamBalance_GetTeamFromIndex(balance, i);
                        if (TeamBalanceTeam_IsAllowed(team_))
                        {
-                               MUTATOR_CALLHOOK(TeamBalance_GetTeamCount, Team_NumberToTeam(i),
+                               MUTATOR_CALLHOOK(TeamBalance_GetTeamCount, Team_IndexToTeam(i),
                                        ignore, team_.m_num_players, team_.m_num_bots,
                                        team_.m_lowest_human, team_.m_lowest_bot);
                                team_.m_num_players = M_ARGV(2, float);
@@ -719,7 +719,7 @@ void TeamBalance_JoinBestTeam(entity this, bool force_best_team)
                for (int i = 1; i <= NUM_TEAMS; ++i)
                {
                        if (TeamBalance_IsTeamAllowedInternal(balance, i) && (this.team ==
-                               Team_NumberToTeam(i)))
+                               Team_IndexToTeam(i)))
                        {
                                selected_team_num = this.team;
                                break;
@@ -741,8 +741,8 @@ void TeamBalance_JoinBestTeam(entity this, bool force_best_team)
                return;
        }
        int best_team_index = TeamBalance_FindBestTeam(balance, this, true);
-       int best_team_num = Team_NumberToTeam(best_team_index);
-       int old_team_index = Team_TeamToNumber(this.team);
+       int best_team_num = Team_IndexToTeam(best_team_index);
+       int old_team_index = Team_TeamToIndex(this.team);
        TeamchangeFrags(this);
        SetPlayerTeamSimple(this, best_team_num);
        LogTeamchange(this.playerid, this.team, 2); // log auto join
@@ -828,7 +828,7 @@ void TeamBalance_AutoBalanceBots(entity balance, int source_team_index,
                return;
        }
        SetPlayerTeamSimple(destination_team.m_lowest_bot,
-               Team_NumberToTeam(source_team_index));
+               Team_IndexToTeam(source_team_index));
        KillPlayerForTeamChange(destination_team.m_lowest_bot);
 }
 
@@ -860,7 +860,7 @@ entity TeamBalance_GetTeamFromIndex(entity balance, int index)
 
 entity TeamBalance_GetTeam(entity balance, int team_num)
 {
-       return TeamBalance_GetTeamFromIndex(balance, Team_TeamToNumber(team_num));
+       return TeamBalance_GetTeamFromIndex(balance, Team_TeamToIndex(team_num));
 }
 
 bool TeamBalanceTeam_IsAllowed(entity team_)
@@ -952,8 +952,8 @@ void SV_ChangeTeam(entity this, float _color)
        source_color = this.clientcolors & 0x0F;
        destination_color = _color & 0x0F;
 
-       source_team_index = Team_TeamToNumber(source_color + 1);
-       destination_team_index = Team_TeamToNumber(destination_color + 1);
+       source_team_index = Team_TeamToIndex(source_color + 1);
+       destination_team_index = Team_TeamToIndex(destination_color + 1);
 
        if (destination_team_index == -1)
        {