3 #include "command/common.qh"
5 #include <server/g_world.qh>
6 #include <server/miscfunctions.qh>
7 #include <server/mutators/_mod.qh>
8 #include <common/net_linked.qh>
9 #include "../common/playerstats.qh"
10 #include "../common/teams.qh"
11 #include <common/mapinfo.qh>
12 #include <common/mutators/base.qh>
13 #include <common/scores.qh>
14 #include <common/state.qh>
15 #include <common/stats.qh>
18 entity teamscorekeepers[16];
19 float teamscores_entities_count;
20 var .float scores_primary;
21 var .float teamscores_primary;
22 float scores_flags_primary;
23 float teamscores_flags_primary;
25 vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags, vector previous, float strict) // returns: cmp value, best prio
27 if(!strict && !(fieldflags & SFL_SORT_PRIO_MASK)) // column does not sort
29 if((fieldflags & SFL_SORT_PRIO_MASK) < previous.y)
31 if (t1.(field) == t2.(field))
34 previous.y = fieldflags & SFL_SORT_PRIO_MASK;
36 if(fieldflags & SFL_ZERO_IS_WORST)
43 else if (t2.(field) == 0)
50 if (fieldflags & SFL_LOWER_IS_BETTER)
51 previous.x = (t2.(field) - t1.(field));
53 previous.x = (t1.(field) - t2.(field));
62 bool TeamScore_SendEntity(entity this, entity to, float sendflags)
66 WriteHeader(MSG_ENTITY, ENT_CLIENT_TEAMSCORES);
67 int t = this.team - 1;
68 assert(t, eprint(this));
69 WriteByte(MSG_ENTITY, t);
72 for(i = 0; i < MAX_TEAMSCORE; ++i)
73 if(this.(teamscores(i)) > 127 || this.(teamscores(i)) <= -128)
76 #if MAX_TEAMSCORE <= 8
77 WriteByte(MSG_ENTITY, sendflags);
78 WriteByte(MSG_ENTITY, longflags);
80 WriteShort(MSG_ENTITY, sendflags);
81 WriteShort(MSG_ENTITY, longflags);
83 for(i = 0; i < MAX_TEAMSCORE; ++i)
84 if(sendflags & BIT(i))
86 if(longflags & BIT(i))
87 WriteInt24_t(MSG_ENTITY, this.(teamscores(i)));
89 WriteChar(MSG_ENTITY, this.(teamscores(i)));
95 void TeamScore_Spawn(float t, string name)
97 entity ts = new_pure(csqc_score_team);
98 ts.netname = name; // not used yet, FIXME
100 Net_LinkEntity(ts, false, 0, TeamScore_SendEntity);
101 teamscorekeepers[t - 1] = ts;
102 ++teamscores_entities_count;
103 PlayerStats_GameReport_AddTeam(t);
106 float TeamScore_AddToTeam(int t, float scorefield, float score)
113 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
114 if(t <= 0 || t >= 16)
118 error("Adding score to invalid team!");
120 s = teamscorekeepers[t - 1];
125 error("Adding score to unknown team!");
128 if(teamscores_label(scorefield) != "")
129 s.SendFlags |= (2 ** scorefield);
130 return (s.(teamscores(scorefield)) += score);
133 float TeamScore_Add(entity player, float scorefield, float score)
135 return TeamScore_AddToTeam(player.team, scorefield, score);
138 float TeamScore_Compare(entity t1, entity t2, float strict)
140 if(!t1 || !t2) return (!t2) - !t1;
142 vector result = '0 0 0';
144 for(i = 0; i < MAX_TEAMSCORE; ++i)
148 result = ScoreField_Compare(t1, t2, f, teamscores_flags(i), result, strict);
151 if (result.x == 0 && strict)
152 result.x = t1.team - t2.team;
158 * the scoreinfo entity
161 void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags)
163 scores_label(i) = label;
164 scores_flags(i) = scoreflags;
165 if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
167 scores_primary = scores(i);
168 scores_flags_primary = scoreflags;
172 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
173 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
177 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags)
179 teamscores_label(i) = label;
180 teamscores_flags(i) = scoreflags;
181 if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
183 teamscores_primary = teamscores(i);
184 teamscores_flags_primary = scoreflags;
188 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
189 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
193 bool ScoreInfo_SendEntity(entity this, entity to, int sf)
196 WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES_INFO);
197 WriteRegistered(Gametypes, MSG_ENTITY, MapInfo_LoadedGametype);
198 FOREACH(Scores, true, {
199 WriteString(MSG_ENTITY, scores_label(it));
200 WriteByte(MSG_ENTITY, scores_flags(it));
202 for(i = 0; i < MAX_TEAMSCORE; ++i)
204 WriteString(MSG_ENTITY, teamscores_label(i));
205 WriteByte(MSG_ENTITY, teamscores_flags(i));
210 void ScoreInfo_Init(int teams)
212 if(scores_initialized)
214 scores_initialized.SendFlags |= 1; // force a resend
218 scores_initialized = new_pure(ent_client_scoreinfo);
219 Net_LinkEntity(scores_initialized, false, 0, ScoreInfo_SendEntity);
222 TeamScore_Spawn(NUM_TEAM_1, "Red");
224 TeamScore_Spawn(NUM_TEAM_2, "Blue");
226 TeamScore_Spawn(NUM_TEAM_3, "Yellow");
228 TeamScore_Spawn(NUM_TEAM_4, "Pink");
232 * per-player score entities
235 bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
237 WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES);
238 WriteByte(MSG_ENTITY, etof(this.owner));
241 FOREACH(Scores, true, {
242 int p = 1 << (i % 16);
243 if (this.(scores(it)) > 127 || this.(scores(it)) <= -128)
247 WriteShort(MSG_ENTITY, sendflags);
248 WriteShort(MSG_ENTITY, longflags);
249 FOREACH(Scores, true, {
250 int p = 1 << (i % 16);
254 WriteInt24_t(MSG_ENTITY, this.(scores(it)));
256 WriteChar(MSG_ENTITY, this.(scores(it)));
263 float PlayerScore_Clear(entity player)
267 if(teamscores_entities_count)
270 if(MUTATOR_CALLHOOK(ForbidPlayerScore_Clear)) return 0;
272 sk = CS(player).scorekeeper;
273 FOREACH(Scores, true, {
274 if(sk.(scores(it)) != 0)
275 if(scores_label(it) != "")
276 sk.SendFlags |= (2 ** (i % 16));
284 void Score_ClearAll()
288 FOREACH_CLIENTSLOT(true, {
289 sk = CS(it).scorekeeper;
291 FOREACH(Scores, true, {
292 if(sk.(scores(it)) != 0)
293 if(scores_label(it) != "")
294 sk.SendFlags |= (2 ** (i % 16));
299 for(t = 0; t < 16; ++t)
301 sk = teamscorekeepers[t];
304 for(int j = 0; j < MAX_TEAMSCORE; ++j)
306 if(sk.(teamscores(j)) != 0)
307 if(teamscores_label(j) != "")
308 sk.SendFlags |= (2 ** j);
309 sk.(teamscores(j)) = 0;
314 void PlayerScore_Attach(entity player)
316 if(CS(player).scorekeeper)
317 error("player already has a scorekeeper");
318 entity sk = new_pure(scorekeeper);
320 Net_LinkEntity(sk, false, 0, PlayerScore_SendEntity);
321 CS(player).scorekeeper = sk;
324 void PlayerScore_Detach(entity player)
326 if(!CS(player).scorekeeper)
327 error("player has no scorekeeper");
328 delete(CS(player).scorekeeper);
329 CS(player).scorekeeper = NULL;
332 float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
334 bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score, player);
335 score = M_ARGV(1, float);
338 if(!mutator_returnvalue)
341 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
342 entity s = CS(player).scorekeeper;
347 LOG_WARN("Adding score to unknown player!");
352 return s.(scores(scorefield));
354 if(scores_label(scorefield) != "")
355 s.SendFlags |= (2 ** (scorefield.m_id % 16));
357 PlayerStats_GameReport_Event_Player(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score);
358 s.(scores(scorefield)) += score;
359 MUTATOR_CALLHOOK(AddedPlayerScore, scorefield, score, player);
360 return s.(scores(scorefield));
363 float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score)
365 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
366 entity s = CS(player).scorekeeper;
371 LOG_WARN("Setting score of unknown player!");
375 float oldscore = s.(scores(scorefield));
376 if(oldscore == score)
379 if(scores_label(scorefield) != "")
380 s.SendFlags |= (2 ** (scorefield.m_id % 16));
381 s.(scores(scorefield)) = score;
382 return s.(scores(scorefield));
385 float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score)
388 r = PlayerScore_Add(player, pscorefield, score);
389 if(teamscores_entities_count) // only for teamplay
390 r = TeamScore_Add(player, tscorefield, score);
394 float PlayerScore_Compare(entity t1, entity t2, float strict)
396 if(!t1 || !t2) return (!t2) - !t1;
398 vector result = '0 0 0';
399 FOREACH(Scores, true, {
400 var .float f = scores(it);
401 result = ScoreField_Compare(t1, t2, f, scores_flags(it), result, strict);
404 if (result.x == 0 && strict)
405 result.x = t1.owner.playerid - t2.owner.playerid;
410 void WinningConditionHelper(entity this)
415 entity winnerscorekeeper;
416 entity secondscorekeeper;
420 // gametype:P<pure>:S<slots>::plabel,plabel:tlabel,tlabel:teamid:tscore,tscore:teamid:tscore,tscore
421 // score labels always start with a symbol or with lower case
422 // so to match pure, match for :P0:
423 // to match full, match for :S0:
425 fullstatus = autocvar_g_full_getstatus_responses;
428 s = strcat(s, ":", autocvar_g_xonoticversion);
429 s = strcat(s, ":P", ftos(cvar_purechanges_count));
430 s = strcat(s, ":S", ftos(nJoinAllowed(this, NULL)));
431 s = strcat(s, ":F", ftos(serverflags));
432 s = strcat(s, ":M", modname);
433 s = strcat(s, "::", GetPlayerScoreString(NULL, (fullstatus ? 1 : 2)));
435 if(teamscores_entities_count)
439 s = strcat(s, ":", GetTeamScoreString(0, 1));
440 for(t = 0; t < 16; ++t)
441 if(teamscorekeepers[t])
442 s = strcat(s, ":", ftos(t+1), ":", GetTeamScoreString(t+1, 1));
444 WinningConditionHelper_winnerteam = -1;
445 WinningConditionHelper_secondteam = -1;
446 winnerscorekeeper = NULL;
447 secondscorekeeper = NULL;
448 for(t = 0; t < 16; ++t)
450 sk = teamscorekeepers[t];
451 c = TeamScore_Compare(winnerscorekeeper, sk, 1);
454 WinningConditionHelper_secondteam = WinningConditionHelper_winnerteam;
455 WinningConditionHelper_winnerteam = t + 1;
456 secondscorekeeper = winnerscorekeeper;
457 winnerscorekeeper = sk;
461 c = TeamScore_Compare(secondscorekeeper, sk, 1);
464 WinningConditionHelper_secondteam = t + 1;
465 secondscorekeeper = sk;
470 WinningConditionHelper_equality = (TeamScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
471 if(WinningConditionHelper_equality)
472 WinningConditionHelper_winnerteam = WinningConditionHelper_secondteam = -1;
474 WinningConditionHelper_topscore = winnerscorekeeper.teamscores_primary;
475 WinningConditionHelper_secondscore = secondscorekeeper.teamscores_primary;
476 WinningConditionHelper_lowerisbetter = (teamscores_flags_primary & SFL_LOWER_IS_BETTER);
477 WinningConditionHelper_zeroisworst = (teamscores_flags_primary & SFL_ZERO_IS_WORST);
479 WinningConditionHelper_winner = NULL; // not supported in teamplay
480 WinningConditionHelper_second = NULL; // not supported in teamplay
484 WinningConditionHelper_winner = NULL;
485 WinningConditionHelper_second = NULL;
486 winnerscorekeeper = NULL;
487 secondscorekeeper = NULL;
488 FOREACH_CLIENT(IS_PLAYER(it), {
489 sk = CS(it).scorekeeper;
490 c = PlayerScore_Compare(winnerscorekeeper, sk, 1);
493 WinningConditionHelper_second = WinningConditionHelper_winner;
494 WinningConditionHelper_winner = it;
495 secondscorekeeper = winnerscorekeeper;
496 winnerscorekeeper = sk;
500 c = PlayerScore_Compare(secondscorekeeper, sk, 1);
503 WinningConditionHelper_second = it;
504 secondscorekeeper = sk;
509 WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
510 if(WinningConditionHelper_equality)
511 WinningConditionHelper_winner = WinningConditionHelper_second = NULL;
513 WinningConditionHelper_topscore = winnerscorekeeper.scores_primary;
514 WinningConditionHelper_secondscore = secondscorekeeper.scores_primary;
515 WinningConditionHelper_lowerisbetter = (scores_flags_primary & SFL_LOWER_IS_BETTER);
516 WinningConditionHelper_zeroisworst = (scores_flags_primary & SFL_ZERO_IS_WORST);
518 WinningConditionHelper_winnerteam = -1; // no teamplay
519 WinningConditionHelper_secondteam = -1; // no teamplay
522 if(WinningConditionHelper_topscore == 0)
524 if(scores_flags_primary & SFL_ZERO_IS_WORST)
526 if(WinningConditionHelper_lowerisbetter)
527 WinningConditionHelper_topscore = 999999999;
529 WinningConditionHelper_topscore = -999999999;
531 WinningConditionHelper_equality = 0;
534 if(WinningConditionHelper_secondscore == 0)
536 if(scores_flags_primary & SFL_ZERO_IS_WORST)
538 if(WinningConditionHelper_lowerisbetter)
539 WinningConditionHelper_secondscore = 999999999;
541 WinningConditionHelper_secondscore = -999999999;
545 strcpy(worldstatus, s);
547 FOREACH_CLIENT(true, {
551 s = GetPlayerScoreString(it, 1);
552 s = strcat(s, IS_REAL_CLIENT(it) ? ":human" : ":bot");
553 if(!IS_PLAYER(it) && !MUTATOR_CALLHOOK(GetPlayerStatus, it))
554 s = strcat(s, ":spectator");
558 if (IS_PLAYER(it) || MUTATOR_CALLHOOK(GetPlayerStatus, it))
559 s = GetPlayerScoreString(it, 2);
564 strcpy(it.clientstatus, s);
568 string GetScoreLogLabel(string label, float fl)
570 if(fl & SFL_LOWER_IS_BETTER)
571 label = strcat(label, "<");
572 if((fl & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
573 label = strcat(label, "!!");
574 else if((fl & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
575 label = strcat(label, "!");
579 string GetPlayerScoreString(entity pl, float shortString)
590 FOREACH(Scores, true, {
591 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
593 f = scores_flags(it);
594 l = scores_label(it);
595 out = strcat(out, GetScoreLogLabel(l, f), ",");
599 FOREACH(Scores, true, {
600 if((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
602 f = scores_flags(it);
603 l = scores_label(it);
604 out = strcat(out, GetScoreLogLabel(l, f), ",");
608 FOREACH(Scores, true, {
609 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
610 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
612 f = scores_flags(it);
613 l = scores_label(it);
614 out = strcat(out, GetScoreLogLabel(l, f), ",");
617 out = substring(out, 0, strlen(out) - 1);
619 else if((sk = CS(pl).scorekeeper))
621 FOREACH(Scores, true, {
622 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
623 out = strcat(out, ftos(sk.(scores(it))), ",");
626 FOREACH(Scores, true, {
627 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
628 out = strcat(out, ftos(sk.(scores(it))), ",");
631 FOREACH(Scores, true, {
632 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
633 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
634 out = strcat(out, ftos(sk.(scores(it))), ",");
636 out = substring(out, 0, strlen(out) - 1);
641 string GetTeamScoreString(float tm, float shortString)
652 for(i = 0; i < MAX_TEAMSCORE; ++i)
653 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
655 f = teamscores_flags(i);
656 l = teamscores_label(i);
657 out = strcat(out, GetScoreLogLabel(l, f), ",");
660 for(i = 0; i < MAX_TEAMSCORE; ++i)
661 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
663 f = teamscores_flags(i);
664 l = teamscores_label(i);
665 out = strcat(out, GetScoreLogLabel(l, f), ",");
668 for(i = 0; i < MAX_TEAMSCORE; ++i)
669 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
670 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
672 f = teamscores_flags(i);
673 l = teamscores_label(i);
674 out = strcat(out, GetScoreLogLabel(l, f), ",");
676 out = substring(out, 0, strlen(out) - 1);
678 else if((sk = teamscorekeepers[tm - 1]))
680 for(i = 0; i < MAX_TEAMSCORE; ++i)
681 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
682 out = strcat(out, ftos(sk.(teamscores(i))), ",");
684 for(i = 0; i < MAX_TEAMSCORE; ++i)
685 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
686 out = strcat(out, ftos(sk.(teamscores(i))), ",");
688 for(i = 0; i < MAX_TEAMSCORE; ++i)
689 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
690 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
691 out = strcat(out, ftos(sk.(teamscores(i))), ",");
692 out = substring(out, 0, strlen(out) - 1);
697 float PlayerTeamScore_Compare(entity p1, entity p2, float teams, float strict)
699 if(teams && teamscores_entities_count)
701 if(p1.team != p2.team)
705 t1 = teamscorekeepers[p1.team - 1];
706 t2 = teamscorekeepers[p2.team - 1];
707 r = TeamScore_Compare(t1, t2, ((teams >= 0) ? 1 : strict));
714 return PlayerScore_Compare(CS(p1).scorekeeper, CS(p2).scorekeeper, strict);
717 entity PlayerScore_Sort(.float field, float teams, float strict, float nospectators)
719 entity p, plist, pprev, pbest, pbestprev, pfirst, plast;
724 FOREACH_CLIENT(true, { it.(field) = 0; });
726 FOREACH_CLIENT(CS(it).scorekeeper,
729 if(it.frags == FRAGS_SPECTATOR)
735 // Now plist points to the whole list.
737 pfirst = plast = NULL;
742 pprev = pbestprev = NULL;
744 for(p = plist; (pprev = p), (p = p.chain); )
746 if(PlayerTeamScore_Compare(p, pbest, teams, strict) > 0)
753 // remove pbest out of the chain
754 if(pbestprev == NULL)
757 pbestprev.chain = pbest.chain;
761 if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, 0))
776 float TeamScore_GetCompareValue(float t)
781 if(t <= 0 || t >= 16)
785 error("Reading score of invalid team!");
788 sk = teamscorekeepers[t - 1];
791 s = sk.teamscores_primary;
792 if(teamscores_flags_primary & SFL_ZERO_IS_WORST)
795 if(teamscores_flags_primary & SFL_LOWER_IS_BETTER)
800 const float NAMEWIDTH = 22;
801 const float SCORESWIDTH = 58;
802 // TODO put this somewhere in common?
803 string Score_NicePrint_ItemColor(float vflags)
805 if(vflags & SFL_SORT_PRIO_PRIMARY)
807 else if(vflags & SFL_SORT_PRIO_SECONDARY)
813 void Score_NicePrint_Team(entity to, float t, float w)
821 sk = teamscorekeepers[t - 1];
824 s = strcat(s, Team_ColoredFullName(t));
825 for(i = 0; i < MAX_TEAMSCORE; ++i)
826 if(teamscores_label(i) != "")
828 fl = teamscores_flags(i);
829 sc = sk.(teamscores(i));
830 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), ScoreString(fl, sc));
836 s = strcat(s, strpad(max(0, NAMEWIDTH - strlennocol(s)), ""));
838 FOREACH(Scores, true, {
839 if(scores_label(it) != "")
841 fl = scores_flags(it);
842 s2 = scores_label(it);
843 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, substring(s2, 0, w)));
850 void Score_NicePrint_Player(entity to, entity p, float w)
858 sk = CS(p).scorekeeper;
860 s = strcat(s, playername(p, false));
863 i = strlennocol(s) - NAMEWIDTH;
865 s = substring(s, 0, strlen(s) - i);
868 s = strcat(s, strpad(i, ""));
873 FOREACH(Scores, true, {
874 if(scores_label(it) != "")
876 fl = scores_flags(it);
877 sc = sk.(scores(it));
878 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, ScoreString(fl, sc)));
885 void Score_NicePrint_Spectators(entity to)
887 print_to(to, "Spectators:");
890 void Score_NicePrint_Spectator(entity to, entity p)
892 print_to(to, strcat(" ", playername(p, false)));
895 .float score_dummyfield;
896 void Score_NicePrint(entity to)
902 FOREACH(Scores, true, {
903 if(scores_label(it) != "")
906 w = bound(6, floor(SCORESWIDTH / t - 1), 9);
908 p = PlayerScore_Sort(score_dummyfield, 1, 1, 0);
911 if(!teamscores_entities_count)
912 Score_NicePrint_Team(to, t, w);
915 if(teamscores_entities_count)
917 Score_NicePrint_Team(to, p.team, w);
918 Score_NicePrint_Player(to, p, w);
924 FOREACH_CLIENT(!IS_PLAYER(it), {
926 Score_NicePrint_Spectators(to);
927 Score_NicePrint_Spectator(to, it);
932 void PlayerScore_PlayerStats(entity p)
934 entity s = CS(p).scorekeeper;
935 FOREACH(Scores, true, {
936 if(s.(scores(it)) != 0 && scores_label(it) != "")
937 PlayerStats_GameReport_Event_Player(s.owner,
938 strcat(PLAYERSTATS_SCOREBOARD, scores_label(it)), s.(scores(it)));
942 void PlayerScore_TeamStats()
946 for(t = 0; t < 16; ++t)
948 sk = teamscorekeepers[t];
951 for(i = 0; i < MAX_TEAMSCORE; ++i)
952 if(sk.(teamscores(i)) != 0 && teamscores_label(i) != "")
953 // the +1 is important here!
954 PlayerStats_GameReport_Event_Team(t+1,
955 strcat(PLAYERSTATS_SCOREBOARD, teamscores_label(i)), sk.(teamscores(i)));