+
+ teamlines = 0;
+ if (Sbar_IsTeammatch ())
+ {
+ // now sort players by teams.
+ for (i=0 ; i<scoreboardlines ; i++)
+ {
+ for (j=0 ; j<scoreboardlines-1-i ; j++)
+ {
+ if (cl.scores[fragsort[j]].colors < cl.scores[fragsort[j+1]].colors)
+ {
+ k = fragsort[j];
+ fragsort[j] = fragsort[j+1];
+ fragsort[j+1] = k;
+ }
+ }
+ }
+
+ // calculate team scores
+ int color = -1;
+ for (i=0 ; i<scoreboardlines ; i++)
+ {
+ if (color != cl.scores[fragsort[i]].colors)
+ {
+ color = cl.scores[fragsort[i]].colors;
+ teamlines++;
+ strcpy(teams[teamlines-1].name, "Total Team Score");
+ teams[teamlines-1].frags = 0;
+ teams[teamlines-1].colors = cl.scores[fragsort[i]].colors;
+ }
+
+ if (cl.scores[fragsort[i]].frags != -666)
+ {
+ // do not add spedcators
+ // (ugly hack for nexuiz)
+ teams[teamlines-1].frags += cl.scores[fragsort[i]].frags;
+ }
+ }
+
+ // now sort teams by scores.
+ for (i=0 ; i<teamlines ; i++)
+ teamsort[i] = i;
+ for (i=0 ; i<teamlines ; i++)
+ {
+ for (j=0 ; j<teamlines-1-i ; j++)
+ {
+ if (teams[teamsort[j]].frags < teams[teamsort[j+1]].frags)
+ {
+ k = teamsort[j];
+ teamsort[j] = teamsort[j+1];
+ teamsort[j+1] = k;
+ }
+ }
+ }
+ }