3 #include <common/mapinfo.qh>
4 #include <common/mutators/base.qh>
5 #include <common/net_linked.qh>
6 #include <common/playerstats.qh>
7 #include <common/scores.qh>
8 #include <common/state.qh>
9 #include <common/stats.qh>
10 #include <common/teams.qh>
11 #include <common/weapons/_all.qh>
12 #include <server/client.qh>
13 #include <server/command/common.qh>
14 #include <server/intermission.qh>
15 #include <server/mutators/_mod.qh>
16 #include <server/round_handler.qh>
17 #include <server/world.qh>
20 entity teamscorekeepers[16];
21 float teamscores_entities_count;
22 var .float scores_primary;
23 var .float teamscores_primary;
24 float scores_flags_primary;
25 float teamscores_flags_primary;
27 vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags, vector previous, bool strict) // returns: cmp value, best prio
29 if(fieldflags & SFL_NOT_SORTABLE) // column does not sort
31 if(!strict && !(fieldflags & SFL_SORT_PRIO_MASK)) // column does not sort
33 if((fieldflags & SFL_SORT_PRIO_MASK) < previous.y)
35 if (t1.(field) == t2.(field))
38 previous.y = fieldflags & SFL_SORT_PRIO_MASK;
40 if(fieldflags & SFL_ZERO_IS_WORST)
47 else if (t2.(field) == 0)
54 if (fieldflags & SFL_LOWER_IS_BETTER)
55 previous.x = (t2.(field) - t1.(field));
57 previous.x = (t1.(field) - t2.(field));
66 bool TeamScore_SendEntity(entity this, entity to, float sendflags)
70 WriteHeader(MSG_ENTITY, ENT_CLIENT_TEAMSCORES);
71 int t = this.team - 1;
72 assert(t, eprint(this));
73 WriteByte(MSG_ENTITY, t);
76 for(i = 0; i < MAX_TEAMSCORE; ++i)
77 if(this.(teamscores(i)) > 127 || this.(teamscores(i)) <= -128)
80 #if MAX_TEAMSCORE <= 8
81 WriteByte(MSG_ENTITY, sendflags);
82 WriteByte(MSG_ENTITY, longflags);
84 WriteShort(MSG_ENTITY, sendflags);
85 WriteShort(MSG_ENTITY, longflags);
87 for(i = 0; i < MAX_TEAMSCORE; ++i)
88 if(sendflags & BIT(i))
90 if(longflags & BIT(i))
91 WriteInt24_t(MSG_ENTITY, this.(teamscores(i)));
93 WriteChar(MSG_ENTITY, this.(teamscores(i)));
99 void TeamScore_Spawn(float t, string name)
101 entity ts = new_pure(csqc_score_team);
102 ts.netname = name; // not used yet, FIXME
104 Net_LinkEntity(ts, false, 0, TeamScore_SendEntity);
105 teamscorekeepers[t - 1] = ts;
106 ++teamscores_entities_count;
107 PlayerStats_GameReport_AddTeam(t);
110 float TeamScore_AddToTeam(int t, float scorefield, float score)
119 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
120 if(t <= 0 || t >= 16)
124 error("Adding score to invalid team!");
126 s = teamscorekeepers[t - 1];
131 error("Adding score to unknown team!");
134 if(teamscores_label(scorefield) != "")
135 s.SendFlags |= BIT(scorefield);
136 return (s.(teamscores(scorefield)) += score);
139 float TeamScore_Add(entity player, float scorefield, float score)
141 return TeamScore_AddToTeam(player.team, scorefield, score);
144 float TeamScore_Compare(entity t1, entity t2, bool strict)
146 if(!t1 || !t2) return (!t2) - !t1;
148 vector result = '0 0 0';
150 for(i = 0; i < MAX_TEAMSCORE; ++i)
154 result = ScoreField_Compare(t1, t2, f, teamscores_flags(i), result, strict);
157 if (result.x == 0 && strict)
158 result.x = t1.team - t2.team;
164 * the scoreinfo entity
167 void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags)
169 scores_label(i) = label;
170 scores_flags(i) = scoreflags;
171 if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
173 scores_primary = scores(i);
174 scores_flags_primary = scoreflags;
178 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
179 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
183 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags)
185 teamscores_label(i) = label;
186 teamscores_flags(i) = scoreflags;
187 if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
189 teamscores_primary = teamscores(i);
190 teamscores_flags_primary = scoreflags;
194 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
195 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
199 bool ScoreInfo_SendEntity(entity this, entity to, int sf)
202 WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES_INFO);
203 WriteRegistered(Gametypes, MSG_ENTITY, MapInfo_LoadedGametype);
204 FOREACH(Scores, true, {
205 WriteString(MSG_ENTITY, scores_label(it));
206 WriteByte(MSG_ENTITY, scores_flags(it));
208 for(i = 0; i < MAX_TEAMSCORE; ++i)
210 WriteString(MSG_ENTITY, teamscores_label(i));
211 WriteByte(MSG_ENTITY, teamscores_flags(i));
213 // prevent sending the welcome message again when score types are sent again because the scoring system has changed
214 // it can happen in some game modes like Race when the qualyfing session ends and the race starts
215 bool welcome_msg_too = (!CS(to) || time < CS(to).jointime + 5);
216 WriteByte(MSG_ENTITY, welcome_msg_too);
217 // welcome message is sent here because it needs to know the gametype
219 SendWelcomemessage_msg_type(to, false, MSG_ENTITY);
223 void ScoreInfo_Init(int teams)
225 if(scores_initialized)
227 scores_initialized.SendFlags |= 1; // force a resend
231 scores_initialized = new_pure(ent_client_scoreinfo);
232 Net_LinkEntity(scores_initialized, false, 0, ScoreInfo_SendEntity);
235 TeamScore_Spawn(NUM_TEAM_1, "Red");
237 TeamScore_Spawn(NUM_TEAM_2, "Blue");
239 TeamScore_Spawn(NUM_TEAM_3, "Yellow");
241 TeamScore_Spawn(NUM_TEAM_4, "Pink");
245 * per-player score entities
248 bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
250 WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES);
251 WriteByte(MSG_ENTITY, etof(this.owner));
254 FOREACH(Scores, true, {
255 int p = 1 << (i % 16);
256 if (this.(scores(it)) > 127 || this.(scores(it)) <= -128)
260 WriteShort(MSG_ENTITY, sendflags);
261 WriteShort(MSG_ENTITY, longflags);
262 FOREACH(Scores, true, {
263 int p = 1 << (i % 16);
267 WriteInt24_t(MSG_ENTITY, this.(scores(it)));
269 WriteChar(MSG_ENTITY, this.(scores(it)));
276 float PlayerScore_Clear(entity player)
280 if(teamscores_entities_count)
283 if(MUTATOR_CALLHOOK(ForbidPlayerScore_Clear)) return 0;
285 sk = CS(player).scorekeeper;
286 FOREACH(Scores, true, {
287 if(sk.(scores(it)) != 0)
288 if(scores_label(it) != "")
289 sk.SendFlags |= BIT(i % 16);
297 void Score_ClearAll()
301 FOREACH_CLIENTSLOT(true, {
302 sk = CS(it).scorekeeper;
304 FOREACH(Scores, true, {
305 if(sk.(scores(it)) != 0)
306 if(scores_label(it) != "")
307 sk.SendFlags |= BIT(i % 16);
312 for(t = 0; t < 16; ++t)
314 sk = teamscorekeepers[t];
317 for(int j = 0; j < MAX_TEAMSCORE; ++j)
319 if(sk.(teamscores(j)) != 0)
320 if(teamscores_label(j) != "")
321 sk.SendFlags |= BIT(j);
322 sk.(teamscores(j)) = 0;
327 void PlayerScore_Attach(entity player)
329 if(CS(player).scorekeeper)
330 error("player already has a scorekeeper");
331 entity sk = new_pure(scorekeeper);
333 Net_LinkEntity(sk, false, 0, PlayerScore_SendEntity);
334 CS(player).scorekeeper = sk;
337 void PlayerScore_Detach(entity player)
339 if(!CS(player).scorekeeper)
340 error("player has no scorekeeper");
341 delete(CS(player).scorekeeper);
342 CS(player).scorekeeper = NULL;
345 float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
347 bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score, player);
348 score = M_ARGV(1, float);
350 if(!mutator_returnvalue && game_stopped)
355 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
356 entity s = CS(player).scorekeeper;
361 LOG_WARN("Adding score to unknown player!");
366 return s.(scores(scorefield));
368 if(scores_label(scorefield) != "")
369 s.SendFlags |= BIT(scorefield.m_id % 16);
371 PlayerStats_GameReport_Event_Player(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score);
372 s.(scores(scorefield)) += score;
373 MUTATOR_CALLHOOK(AddedPlayerScore, scorefield, score, player);
374 return s.(scores(scorefield));
377 float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score)
379 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
380 entity s = CS(player).scorekeeper;
385 LOG_WARN("Setting score of unknown player!");
389 float oldscore = s.(scores(scorefield));
390 if(oldscore == score)
393 if(scores_label(scorefield) != "")
394 s.SendFlags |= BIT(scorefield.m_id % 16);
395 s.(scores(scorefield)) = score;
396 return s.(scores(scorefield));
399 float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score)
402 r = PlayerScore_Add(player, pscorefield, score);
403 if(teamscores_entities_count) // only for teamplay
404 r = TeamScore_Add(player, tscorefield, score);
408 float PlayerScore_Compare(entity t1, entity t2, bool strict)
410 if(!t1 || !t2) return (!t2) - !t1;
412 vector result = '0 0 0';
413 FOREACH(Scores, true, {
414 var .float f = scores(it);
415 result = ScoreField_Compare(t1, t2, f, scores_flags(it), result, strict);
418 if (result.x == 0 && strict)
419 result.x = t1.owner.playerid - t2.owner.playerid;
424 void WinningConditionHelper(entity this)
429 entity winnerscorekeeper;
430 entity secondscorekeeper;
434 // gametype:P<pure>:S<slots>::plabel,plabel:tlabel,tlabel:teamid:tscore,tscore:teamid:tscore,tscore
435 // score labels always start with a symbol or with lower case
436 // so to match pure, match for :P0:
437 // to match full, match for :S0:
439 fullstatus = autocvar_g_full_getstatus_responses;
442 s = strcat(s, ":", autocvar_g_xonoticversion);
443 s = strcat(s, ":P", ftos(cvar_purechanges_count));
444 s = strcat(s, ":S", ftos(nJoinAllowed(this, NULL)));
445 s = strcat(s, ":F", ftos(serverflags));
446 s = strcat(s, ":T", sv_termsofservice_url_escaped);
447 s = strcat(s, ":M", modname);
448 s = strcat(s, "::", GetPlayerScoreString(NULL, (fullstatus ? 1 : 2)));
450 if(teamscores_entities_count)
454 s = strcat(s, ":", GetTeamScoreString(0, 1));
455 for(t = 0; t < 16; ++t)
456 if(teamscorekeepers[t])
457 s = strcat(s, ":", ftos(t+1), ":", GetTeamScoreString(t+1, 1));
459 WinningConditionHelper_winnerteam = -1;
460 WinningConditionHelper_secondteam = -1;
461 winnerscorekeeper = NULL;
462 secondscorekeeper = NULL;
463 for(t = 0; t < 16; ++t)
465 sk = teamscorekeepers[t];
466 c = TeamScore_Compare(winnerscorekeeper, sk, 1);
469 WinningConditionHelper_secondteam = WinningConditionHelper_winnerteam;
470 WinningConditionHelper_winnerteam = t + 1;
471 secondscorekeeper = winnerscorekeeper;
472 winnerscorekeeper = sk;
476 c = TeamScore_Compare(secondscorekeeper, sk, 1);
479 WinningConditionHelper_secondteam = t + 1;
480 secondscorekeeper = sk;
485 WinningConditionHelper_equality = (TeamScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
486 if(WinningConditionHelper_equality)
487 WinningConditionHelper_winnerteam = WinningConditionHelper_secondteam = -1;
489 WinningConditionHelper_topscore = winnerscorekeeper.teamscores_primary;
490 WinningConditionHelper_secondscore = secondscorekeeper.teamscores_primary;
491 WinningConditionHelper_lowerisbetter = (teamscores_flags_primary & SFL_LOWER_IS_BETTER);
492 WinningConditionHelper_zeroisworst = (teamscores_flags_primary & SFL_ZERO_IS_WORST);
494 WinningConditionHelper_winner = NULL; // not supported in teamplay
495 WinningConditionHelper_second = NULL; // not supported in teamplay
499 WinningConditionHelper_winner = NULL;
500 WinningConditionHelper_second = NULL;
501 winnerscorekeeper = NULL;
502 secondscorekeeper = NULL;
503 FOREACH_CLIENT(IS_PLAYER(it), {
504 sk = CS(it).scorekeeper;
505 c = PlayerScore_Compare(winnerscorekeeper, sk, true);
508 WinningConditionHelper_second = WinningConditionHelper_winner;
509 WinningConditionHelper_winner = it;
510 secondscorekeeper = winnerscorekeeper;
511 winnerscorekeeper = sk;
515 c = PlayerScore_Compare(secondscorekeeper, sk, true);
518 WinningConditionHelper_second = it;
519 secondscorekeeper = sk;
524 WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, false) == 0);
525 if(WinningConditionHelper_equality)
526 WinningConditionHelper_winner = WinningConditionHelper_second = NULL;
528 WinningConditionHelper_topscore = winnerscorekeeper.scores_primary;
529 WinningConditionHelper_secondscore = secondscorekeeper.scores_primary;
530 WinningConditionHelper_lowerisbetter = (scores_flags_primary & SFL_LOWER_IS_BETTER);
531 WinningConditionHelper_zeroisworst = (scores_flags_primary & SFL_ZERO_IS_WORST);
533 WinningConditionHelper_winnerteam = -1; // no teamplay
534 WinningConditionHelper_secondteam = -1; // no teamplay
537 if(WinningConditionHelper_topscore == 0)
539 if(scores_flags_primary & SFL_ZERO_IS_WORST)
541 if(WinningConditionHelper_lowerisbetter)
542 WinningConditionHelper_topscore = 999999999;
544 WinningConditionHelper_topscore = -999999999;
546 if(player_count == 0) // special case: empty servers DO end the match at a 0:0 tie
547 WinningConditionHelper_equality = 0;
550 if(WinningConditionHelper_secondscore == 0)
552 if(scores_flags_primary & SFL_ZERO_IS_WORST)
554 if(WinningConditionHelper_lowerisbetter)
555 WinningConditionHelper_secondscore = 999999999;
557 WinningConditionHelper_secondscore = -999999999;
561 strcpy(worldstatus, s);
563 FOREACH_CLIENT(true, {
567 s = GetPlayerScoreString(it, 1);
568 s = strcat(s, IS_REAL_CLIENT(it) ? ":human" : ":bot");
569 if(!(IS_PLAYER(it) || INGAME_JOINED(it)))
570 s = strcat(s, ":spectator");
574 if (IS_PLAYER(it) || INGAME_JOINED(it))
575 s = GetPlayerScoreString(it, 2);
580 strcpy(it.clientstatus, s);
584 string GetScoreLogLabel(string label, float fl)
586 if(fl & SFL_LOWER_IS_BETTER)
587 label = strcat(label, "<");
588 if((fl & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
589 label = strcat(label, "!!");
590 else if((fl & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
591 label = strcat(label, "!");
595 string GetPlayerScoreString(entity pl, float shortString)
606 FOREACH(Scores, true, {
607 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
609 f = scores_flags(it);
610 l = scores_label(it);
611 out = strcat(out, GetScoreLogLabel(l, f), ",");
615 FOREACH(Scores, true, {
616 if((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
618 f = scores_flags(it);
619 l = scores_label(it);
620 out = strcat(out, GetScoreLogLabel(l, f), ",");
624 FOREACH(Scores, true, {
625 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
626 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
628 f = scores_flags(it);
629 l = scores_label(it);
630 out = strcat(out, GetScoreLogLabel(l, f), ",");
633 out = substring(out, 0, strlen(out) - 1);
635 else if((sk = CS(pl).scorekeeper))
637 FOREACH(Scores, true, {
638 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
639 out = strcat(out, ftos(sk.(scores(it))), ",");
642 FOREACH(Scores, true, {
643 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
644 out = strcat(out, ftos(sk.(scores(it))), ",");
647 FOREACH(Scores, true, {
648 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
649 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
650 out = strcat(out, ftos(sk.(scores(it))), ",");
652 out = substring(out, 0, strlen(out) - 1);
657 string GetTeamScoreString(float tm, float shortString)
668 for(i = 0; i < MAX_TEAMSCORE; ++i)
669 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
671 f = teamscores_flags(i);
672 l = teamscores_label(i);
673 out = strcat(out, GetScoreLogLabel(l, f), ",");
676 for(i = 0; i < MAX_TEAMSCORE; ++i)
677 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
679 f = teamscores_flags(i);
680 l = teamscores_label(i);
681 out = strcat(out, GetScoreLogLabel(l, f), ",");
684 for(i = 0; i < MAX_TEAMSCORE; ++i)
685 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
686 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
688 f = teamscores_flags(i);
689 l = teamscores_label(i);
690 out = strcat(out, GetScoreLogLabel(l, f), ",");
692 out = substring(out, 0, strlen(out) - 1);
694 else if((sk = teamscorekeepers[tm - 1]))
696 for(i = 0; i < MAX_TEAMSCORE; ++i)
697 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
698 out = strcat(out, ftos(sk.(teamscores(i))), ",");
700 for(i = 0; i < MAX_TEAMSCORE; ++i)
701 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
702 out = strcat(out, ftos(sk.(teamscores(i))), ",");
704 for(i = 0; i < MAX_TEAMSCORE; ++i)
705 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
706 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
707 out = strcat(out, ftos(sk.(teamscores(i))), ",");
708 out = substring(out, 0, strlen(out) - 1);
713 float PlayerTeamScore_Compare(entity p1, entity p2, float teams, bool strict)
715 if(teams && teamscores_entities_count)
717 if(p1.team != p2.team)
721 t1 = teamscorekeepers[p1.team - 1];
722 t2 = teamscorekeepers[p2.team - 1];
723 r = TeamScore_Compare(t1, t2, ((teams >= 0) ? 1 : strict));
730 return PlayerScore_Compare(CS(p1).scorekeeper, CS(p2).scorekeeper, strict);
733 entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators)
735 entity p, plist, pprev, pbest, pbestprev, pfirst, plast;
740 FOREACH_CLIENT(true, { it.(field) = 0; });
742 FOREACH_CLIENT(CS(it).scorekeeper,
745 if(it.frags == FRAGS_SPECTATOR)
751 // Now plist points to the whole list.
753 pfirst = plast = NULL;
758 pprev = pbestprev = NULL;
760 for(p = plist; (pprev = p), (p = p.chain); )
762 if(PlayerTeamScore_Compare(p, pbest, teams, strict) > 0)
769 // remove pbest out of the chain
770 if(pbestprev == NULL)
773 pbestprev.chain = pbest.chain;
777 if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, strict))
792 float TeamScore_GetCompareValue(float t)
797 if(t <= 0 || t >= 16)
801 error("Reading score of invalid team!");
804 sk = teamscorekeepers[t - 1];
807 s = sk.teamscores_primary;
808 if(teamscores_flags_primary & SFL_ZERO_IS_WORST)
811 if(teamscores_flags_primary & SFL_LOWER_IS_BETTER)
816 const float NAMEWIDTH = 22;
817 const float SCORESWIDTH = 58;
818 // TODO put this somewhere in common?
819 string Score_NicePrint_ItemColor(float vflags)
821 if(vflags & SFL_SORT_PRIO_PRIMARY)
823 else if(vflags & SFL_SORT_PRIO_SECONDARY)
829 void Score_NicePrint_Team(entity to, float t, float w)
837 sk = teamscorekeepers[t - 1];
840 s = strcat(s, Team_ColoredFullName(t));
841 for(i = 0; i < MAX_TEAMSCORE; ++i)
842 if(teamscores_label(i) != "")
844 fl = teamscores_flags(i);
845 sc = sk.(teamscores(i));
846 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), ScoreString(fl, sc));
852 s = strcat(s, strpad(max(0, NAMEWIDTH - strlennocol(s)), ""));
854 FOREACH(Scores, true, {
855 if(scores_label(it) != "")
857 fl = scores_flags(it);
858 s2 = scores_label(it);
859 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, substring(s2, 0, w)));
866 void Score_NicePrint_Player(entity to, entity p, float w)
874 sk = CS(p).scorekeeper;
876 s = strcat(s, playername(p.netname, p.team, false));
879 i = strlennocol(s) - NAMEWIDTH;
881 s = substring(s, 0, strlen(s) - i);
884 s = strcat(s, strpad(i, ""));
889 FOREACH(Scores, true, {
890 if(scores_label(it) != "")
892 fl = scores_flags(it);
893 sc = sk.(scores(it));
894 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, ScoreString(fl, sc)));
901 void Score_NicePrint_Spectators(entity to)
903 print_to(to, "Spectators:");
906 void Score_NicePrint_Spectator(entity to, entity p)
908 print_to(to, strcat(" ", playername(p.netname, p.team, false)));
911 .float score_dummyfield;
912 void Score_NicePrint(entity to)
918 FOREACH(Scores, true, {
919 if(scores_label(it) != "")
922 w = bound(6, floor(SCORESWIDTH / t - 1), 9);
924 p = PlayerScore_Sort(score_dummyfield, 1, true, false);
927 if(!teamscores_entities_count)
928 Score_NicePrint_Team(to, t, w);
931 if(teamscores_entities_count)
933 Score_NicePrint_Team(to, p.team, w);
934 Score_NicePrint_Player(to, p, w);
940 FOREACH_CLIENT(!IS_PLAYER(it), {
942 Score_NicePrint_Spectators(to);
943 Score_NicePrint_Spectator(to, it);
948 void PlayerScore_PlayerStats(entity p)
950 entity s = CS(p).scorekeeper;
951 FOREACH(Scores, true, {
952 if(s.(scores(it)) != 0 && scores_label(it) != "")
953 PlayerStats_GameReport_Event_Player(s.owner,
954 strcat(PLAYERSTATS_SCOREBOARD, scores_label(it)), s.(scores(it)));
958 void PlayerScore_TeamStats()
962 for(t = 0; t < 16; ++t)
964 sk = teamscorekeepers[t];
967 for(i = 0; i < MAX_TEAMSCORE; ++i)
968 if(sk.(teamscores(i)) != 0 && teamscores_label(i) != "")
969 // the +1 is important here!
970 PlayerStats_GameReport_Event_Team(t+1,
971 strcat(PLAYERSTATS_SCOREBOARD, teamscores_label(i)), sk.(teamscores(i)));