]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Teams: replace loops
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 17 Mar 2016 05:00:04 +0000 (16:00 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 17 Mar 2016 05:00:04 +0000 (16:00 +1100)
qcsrc/common/teams.qh

index 641acb8c2c56582b9e07ee68ab4831ef84de8d8c..9342b4c00f4949de2f4e50befe8baf1cc99f7e85 100644 (file)
@@ -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)
 {