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;
}
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');
{
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);
}
}
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:
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.
// 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))
#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))
if (Team_IsValidTeam(it.team))
{
thiscount = TeamBalance_GetNumberOfPlayers(balance,
- Team_TeamToNumber(it.team));
+ Team_TeamToIndex(it.team));
}
if(thiscount > bestcount)
{
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);
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
{
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;
});
for (int i = 1; i < 5; ++i)
{
Team_SetTeamScore(Team_GetTeamFromIndex(i),
- TeamScore_GetCompareValue(Team_NumberToTeam(i)));
+ TeamScore_GetCompareValue(Team_IndexToTeam(i)));
}
}
{
continue;
}
- TeamScore_AddToTeam(Team_NumberToTeam(j), i, -1000);
+ TeamScore_AddToTeam(Team_IndexToTeam(j), i, -1000);
}
}
{
if (Team_IsValidTeam(head.team))
{
- M_ARGV(0, float) |= BIT(Team_TeamToNumber(head.team) - 1);
+ M_ARGV(0, float) |= Team_TeamToBit(head.team);
}
}
{
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_)
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;
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;
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;
}
// 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);
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);
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;
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
return;
}
SetPlayerTeamSimple(destination_team.m_lowest_bot,
- Team_NumberToTeam(source_team_index));
+ Team_IndexToTeam(source_team_index));
KillPlayerForTeamChange(destination_team.m_lowest_bot);
}
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_)
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)
{