From 9219d5655f1cf356dca04410acdd57a26d34a8c0 Mon Sep 17 00:00:00 2001 From: TimePath Date: Thu, 17 Mar 2016 16:00:04 +1100 Subject: [PATCH] Teams: replace loops --- qcsrc/common/teams.qh | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/qcsrc/common/teams.qh b/qcsrc/common/teams.qh index 641acb8c2..9342b4c00 100644 --- a/qcsrc/common/teams.qh +++ b/qcsrc/common/teams.qh @@ -64,34 +64,21 @@ float teamplay; float myteam; #endif -string Team_ColorCode(int teamid) -{ - Team t = TEAM_SPEC; - FOREACH(Teams, it.team == teamid, t = it; break); - return t.m_colorstr; +Team TM(int teamid) { + if (teamid == 0) return NULL; + FOREACH(Teams, it.team == teamid, return it); + LOG_SEVEREF("Unknown team: %d", teamid); + return NULL; } -vector Team_ColorRGB(int teamid) -{ - Team t = TEAM_SPEC; - FOREACH(Teams, it.team == teamid, t = it; break); - return t.m_color; -} +#define Team_ColorCode(this) (TM(this).m_colorstr) -string Team_ColorName(int teamid) -{ - Team t = TEAM_SPEC; - FOREACH(Teams, it.team == teamid, t = it; break); - return t.m_name_nonls; -} +#define Team_ColorRGB(this) (TM(this).m_color) + +#define Team_ColorName(this) (TM(this).m_name_nonls) // used for replacement in filenames or such where the name CANNOT be allowed to be translated -string Static_Team_ColorName(int teamid) -{ - Team t = TEAM_SPEC; - FOREACH(Teams, it.team == teamid, t = it; break); - return t.m_name; -} +#define Static_Team_ColorName(this) (TM(this).m_name) int Team_ColorToTeam(string team_color) { -- 2.39.2