From: TimePath Date: Thu, 17 Mar 2016 05:00:04 +0000 (+1100) Subject: Teams: replace loops X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9219d5655f1cf356dca04410acdd57a26d34a8c0;p=xonotic%2Fxonotic-data.pk3dir.git Teams: replace loops --- 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) {