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(!strict && !(fieldflags & SFL_SORT_PRIO_MASK)) // column does not sort
31 if((fieldflags & SFL_SORT_PRIO_MASK) < previous.y)
33 if (t1.(field) == t2.(field))
36 previous.y = fieldflags & SFL_SORT_PRIO_MASK;
38 if(fieldflags & SFL_ZERO_IS_WORST)
45 else if (t2.(field) == 0)
52 if (fieldflags & SFL_LOWER_IS_BETTER)
53 previous.x = (t2.(field) - t1.(field));
55 previous.x = (t1.(field) - t2.(field));
64 bool TeamScore_SendEntity(entity this, entity to, float sendflags)
68 WriteHeader(MSG_ENTITY, ENT_CLIENT_TEAMSCORES);
69 int t = this.team - 1;
70 assert(t, eprint(this));
71 WriteByte(MSG_ENTITY, t);
74 for(i = 0; i < MAX_TEAMSCORE; ++i)
75 if(this.(teamscores(i)) > 127 || this.(teamscores(i)) <= -128)
78 #if MAX_TEAMSCORE <= 8
79 WriteByte(MSG_ENTITY, sendflags);
80 WriteByte(MSG_ENTITY, longflags);
82 WriteShort(MSG_ENTITY, sendflags);
83 WriteShort(MSG_ENTITY, longflags);
85 for(i = 0; i < MAX_TEAMSCORE; ++i)
86 if(sendflags & BIT(i))
88 if(longflags & BIT(i))
89 WriteInt24_t(MSG_ENTITY, this.(teamscores(i)));
91 WriteChar(MSG_ENTITY, this.(teamscores(i)));
97 void TeamScore_Spawn(float t, string name)
99 entity ts = new_pure(csqc_score_team);
100 ts.netname = name; // not used yet, FIXME
102 Net_LinkEntity(ts, false, 0, TeamScore_SendEntity);
103 teamscorekeepers[t - 1] = ts;
104 ++teamscores_entities_count;
105 PlayerStats_GameReport_AddTeam(t);
108 float TeamScore_AddToTeam(int t, float scorefield, float score)
117 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
118 if(t <= 0 || t >= 16)
122 error("Adding score to invalid team!");
124 s = teamscorekeepers[t - 1];
129 error("Adding score to unknown team!");
132 if(teamscores_label(scorefield) != "")
133 s.SendFlags |= BIT(scorefield);
134 return (s.(teamscores(scorefield)) += score);
137 float TeamScore_Add(entity player, float scorefield, float score)
139 return TeamScore_AddToTeam(player.team, scorefield, score);
142 float TeamScore_Compare(entity t1, entity t2, bool strict)
144 if(!t1 || !t2) return (!t2) - !t1;
146 vector result = '0 0 0';
148 for(i = 0; i < MAX_TEAMSCORE; ++i)
152 result = ScoreField_Compare(t1, t2, f, teamscores_flags(i), result, strict);
155 if (result.x == 0 && strict)
156 result.x = t1.team - t2.team;
162 * the scoreinfo entity
165 void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, float scoreflags)
167 scores_label(i) = label;
168 scores_flags(i) = scoreflags;
169 if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
171 scores_primary = scores(i);
172 scores_flags_primary = scoreflags;
176 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
177 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
181 void ScoreInfo_SetLabel_TeamScore(float i, string label, float scoreflags)
183 teamscores_label(i) = label;
184 teamscores_flags(i) = scoreflags;
185 if((scoreflags & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
187 teamscores_primary = teamscores(i);
188 teamscores_flags_primary = scoreflags;
192 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_TOTAL, label));
193 PlayerStats_GameReport_AddEvent(strcat(PLAYERSTATS_SCOREBOARD, label));
197 int Welcomemessage_too = 1;
198 bool ScoreInfo_SendEntity(entity this, entity to, int sf)
201 WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES_INFO);
202 WriteRegistered(Gametypes, MSG_ENTITY, MapInfo_LoadedGametype);
203 FOREACH(Scores, true, {
204 WriteString(MSG_ENTITY, scores_label(it));
205 WriteByte(MSG_ENTITY, scores_flags(it));
207 for(i = 0; i < MAX_TEAMSCORE; ++i)
209 WriteString(MSG_ENTITY, teamscores_label(i));
210 WriteByte(MSG_ENTITY, teamscores_flags(i));
212 WriteByte(MSG_ENTITY, Welcomemessage_too);
213 // for some reason ScoreInfo_SendEntity is called twice on client connection
214 // send the welcome message only once
215 if (Welcomemessage_too)
217 // welcome message is sent here because it needs to know the gametype
218 SendWelcomemessage_msg_type(this, false, MSG_ENTITY);
219 Welcomemessage_too = 0;
224 void ScoreInfo_Init(int teams)
226 if(scores_initialized)
228 scores_initialized.SendFlags |= 1; // force a resend
232 scores_initialized = new_pure(ent_client_scoreinfo);
233 Net_LinkEntity(scores_initialized, false, 0, ScoreInfo_SendEntity);
236 TeamScore_Spawn(NUM_TEAM_1, "Red");
238 TeamScore_Spawn(NUM_TEAM_2, "Blue");
240 TeamScore_Spawn(NUM_TEAM_3, "Yellow");
242 TeamScore_Spawn(NUM_TEAM_4, "Pink");
246 * per-player score entities
249 bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
251 WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES);
252 WriteByte(MSG_ENTITY, etof(this.owner));
255 FOREACH(Scores, true, {
256 int p = 1 << (i % 16);
257 if (this.(scores(it)) > 127 || this.(scores(it)) <= -128)
261 WriteShort(MSG_ENTITY, sendflags);
262 WriteShort(MSG_ENTITY, longflags);
263 FOREACH(Scores, true, {
264 int p = 1 << (i % 16);
268 WriteInt24_t(MSG_ENTITY, this.(scores(it)));
270 WriteChar(MSG_ENTITY, this.(scores(it)));
277 float PlayerScore_Clear(entity player)
281 if(teamscores_entities_count)
284 if(MUTATOR_CALLHOOK(ForbidPlayerScore_Clear)) return 0;
286 sk = CS(player).scorekeeper;
287 FOREACH(Scores, true, {
288 if(sk.(scores(it)) != 0)
289 if(scores_label(it) != "")
290 sk.SendFlags |= BIT(i % 16);
298 void Score_ClearAll()
302 FOREACH_CLIENTSLOT(true, {
303 sk = CS(it).scorekeeper;
305 FOREACH(Scores, true, {
306 if(sk.(scores(it)) != 0)
307 if(scores_label(it) != "")
308 sk.SendFlags |= BIT(i % 16);
313 for(t = 0; t < 16; ++t)
315 sk = teamscorekeepers[t];
318 for(int j = 0; j < MAX_TEAMSCORE; ++j)
320 if(sk.(teamscores(j)) != 0)
321 if(teamscores_label(j) != "")
322 sk.SendFlags |= BIT(j);
323 sk.(teamscores(j)) = 0;
328 void PlayerScore_Attach(entity player)
330 if(CS(player).scorekeeper)
331 error("player already has a scorekeeper");
332 entity sk = new_pure(scorekeeper);
334 Net_LinkEntity(sk, false, 0, PlayerScore_SendEntity);
335 CS(player).scorekeeper = sk;
338 void PlayerScore_Detach(entity player)
340 if(!CS(player).scorekeeper)
341 error("player has no scorekeeper");
342 delete(CS(player).scorekeeper);
343 CS(player).scorekeeper = NULL;
346 float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
348 bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score, player);
349 score = M_ARGV(1, float);
351 if(!mutator_returnvalue && game_stopped)
356 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
357 entity s = CS(player).scorekeeper;
362 LOG_WARN("Adding score to unknown player!");
367 return s.(scores(scorefield));
369 if(scores_label(scorefield) != "")
370 s.SendFlags |= BIT(scorefield.m_id % 16);
372 PlayerStats_GameReport_Event_Player(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score);
373 s.(scores(scorefield)) += score;
374 MUTATOR_CALLHOOK(AddedPlayerScore, scorefield, score, player);
375 return s.(scores(scorefield));
378 float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score)
380 if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
381 entity s = CS(player).scorekeeper;
386 LOG_WARN("Setting score of unknown player!");
390 float oldscore = s.(scores(scorefield));
391 if(oldscore == score)
394 if(scores_label(scorefield) != "")
395 s.SendFlags |= BIT(scorefield.m_id % 16);
396 s.(scores(scorefield)) = score;
397 return s.(scores(scorefield));
400 float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score)
403 r = PlayerScore_Add(player, pscorefield, score);
404 if(teamscores_entities_count) // only for teamplay
405 r = TeamScore_Add(player, tscorefield, score);
409 float PlayerScore_Compare(entity t1, entity t2, bool strict)
411 if(!t1 || !t2) return (!t2) - !t1;
413 vector result = '0 0 0';
414 FOREACH(Scores, true, {
415 var .float f = scores(it);
416 result = ScoreField_Compare(t1, t2, f, scores_flags(it), result, strict);
419 if (result.x == 0 && strict)
420 result.x = t1.owner.playerid - t2.owner.playerid;
425 void WinningConditionHelper(entity this)
430 entity winnerscorekeeper;
431 entity secondscorekeeper;
435 // gametype:P<pure>:S<slots>::plabel,plabel:tlabel,tlabel:teamid:tscore,tscore:teamid:tscore,tscore
436 // score labels always start with a symbol or with lower case
437 // so to match pure, match for :P0:
438 // to match full, match for :S0:
440 fullstatus = autocvar_g_full_getstatus_responses;
443 s = strcat(s, ":", autocvar_g_xonoticversion);
444 s = strcat(s, ":P", ftos(cvar_purechanges_count));
445 s = strcat(s, ":S", ftos(nJoinAllowed(this, NULL)));
446 s = strcat(s, ":F", ftos(serverflags));
447 s = strcat(s, ":T", sv_termsofservice_url_escaped);
448 s = strcat(s, ":M", modname);
449 s = strcat(s, "::", GetPlayerScoreString(NULL, (fullstatus ? 1 : 2)));
451 if(teamscores_entities_count)
455 s = strcat(s, ":", GetTeamScoreString(0, 1));
456 for(t = 0; t < 16; ++t)
457 if(teamscorekeepers[t])
458 s = strcat(s, ":", ftos(t+1), ":", GetTeamScoreString(t+1, 1));
460 WinningConditionHelper_winnerteam = -1;
461 WinningConditionHelper_secondteam = -1;
462 winnerscorekeeper = NULL;
463 secondscorekeeper = NULL;
464 for(t = 0; t < 16; ++t)
466 sk = teamscorekeepers[t];
467 c = TeamScore_Compare(winnerscorekeeper, sk, 1);
470 WinningConditionHelper_secondteam = WinningConditionHelper_winnerteam;
471 WinningConditionHelper_winnerteam = t + 1;
472 secondscorekeeper = winnerscorekeeper;
473 winnerscorekeeper = sk;
477 c = TeamScore_Compare(secondscorekeeper, sk, 1);
480 WinningConditionHelper_secondteam = t + 1;
481 secondscorekeeper = sk;
486 WinningConditionHelper_equality = (TeamScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
487 if(WinningConditionHelper_equality)
488 WinningConditionHelper_winnerteam = WinningConditionHelper_secondteam = -1;
490 WinningConditionHelper_topscore = winnerscorekeeper.teamscores_primary;
491 WinningConditionHelper_secondscore = secondscorekeeper.teamscores_primary;
492 WinningConditionHelper_lowerisbetter = (teamscores_flags_primary & SFL_LOWER_IS_BETTER);
493 WinningConditionHelper_zeroisworst = (teamscores_flags_primary & SFL_ZERO_IS_WORST);
495 WinningConditionHelper_winner = NULL; // not supported in teamplay
496 WinningConditionHelper_second = NULL; // not supported in teamplay
500 WinningConditionHelper_winner = NULL;
501 WinningConditionHelper_second = NULL;
502 winnerscorekeeper = NULL;
503 secondscorekeeper = NULL;
504 FOREACH_CLIENT(IS_PLAYER(it), {
505 sk = CS(it).scorekeeper;
506 c = PlayerScore_Compare(winnerscorekeeper, sk, true);
509 WinningConditionHelper_second = WinningConditionHelper_winner;
510 WinningConditionHelper_winner = it;
511 secondscorekeeper = winnerscorekeeper;
512 winnerscorekeeper = sk;
516 c = PlayerScore_Compare(secondscorekeeper, sk, true);
519 WinningConditionHelper_second = it;
520 secondscorekeeper = sk;
525 WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, false) == 0);
526 if(WinningConditionHelper_equality)
527 WinningConditionHelper_winner = WinningConditionHelper_second = NULL;
529 WinningConditionHelper_topscore = winnerscorekeeper.scores_primary;
530 WinningConditionHelper_secondscore = secondscorekeeper.scores_primary;
531 WinningConditionHelper_lowerisbetter = (scores_flags_primary & SFL_LOWER_IS_BETTER);
532 WinningConditionHelper_zeroisworst = (scores_flags_primary & SFL_ZERO_IS_WORST);
534 WinningConditionHelper_winnerteam = -1; // no teamplay
535 WinningConditionHelper_secondteam = -1; // no teamplay
538 if(WinningConditionHelper_topscore == 0)
540 if(scores_flags_primary & SFL_ZERO_IS_WORST)
542 if(WinningConditionHelper_lowerisbetter)
543 WinningConditionHelper_topscore = 999999999;
545 WinningConditionHelper_topscore = -999999999;
547 if(player_count == 0) // special case: empty servers DO end the match at a 0:0 tie
548 WinningConditionHelper_equality = 0;
551 if(WinningConditionHelper_secondscore == 0)
553 if(scores_flags_primary & SFL_ZERO_IS_WORST)
555 if(WinningConditionHelper_lowerisbetter)
556 WinningConditionHelper_secondscore = 999999999;
558 WinningConditionHelper_secondscore = -999999999;
562 strcpy(worldstatus, s);
564 FOREACH_CLIENT(true, {
568 s = GetPlayerScoreString(it, 1);
569 s = strcat(s, IS_REAL_CLIENT(it) ? ":human" : ":bot");
570 if(!(IS_PLAYER(it) || INGAME_JOINED(it)))
571 s = strcat(s, ":spectator");
575 if (IS_PLAYER(it) || INGAME_JOINED(it))
576 s = GetPlayerScoreString(it, 2);
581 strcpy(it.clientstatus, s);
585 string GetScoreLogLabel(string label, float fl)
587 if(fl & SFL_LOWER_IS_BETTER)
588 label = strcat(label, "<");
589 if((fl & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
590 label = strcat(label, "!!");
591 else if((fl & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
592 label = strcat(label, "!");
596 string GetPlayerScoreString(entity pl, float shortString)
607 FOREACH(Scores, true, {
608 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
610 f = scores_flags(it);
611 l = scores_label(it);
612 out = strcat(out, GetScoreLogLabel(l, f), ",");
616 FOREACH(Scores, true, {
617 if((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
619 f = scores_flags(it);
620 l = scores_label(it);
621 out = strcat(out, GetScoreLogLabel(l, f), ",");
625 FOREACH(Scores, true, {
626 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
627 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
629 f = scores_flags(it);
630 l = scores_label(it);
631 out = strcat(out, GetScoreLogLabel(l, f), ",");
634 out = substring(out, 0, strlen(out) - 1);
636 else if((sk = CS(pl).scorekeeper))
638 FOREACH(Scores, true, {
639 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
640 out = strcat(out, ftos(sk.(scores(it))), ",");
643 FOREACH(Scores, true, {
644 if ((scores_flags(it) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
645 out = strcat(out, ftos(sk.(scores(it))), ",");
648 FOREACH(Scores, true, {
649 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
650 if((scores_flags(it) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
651 out = strcat(out, ftos(sk.(scores(it))), ",");
653 out = substring(out, 0, strlen(out) - 1);
658 string GetTeamScoreString(float tm, float shortString)
669 for(i = 0; i < MAX_TEAMSCORE; ++i)
670 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
672 f = teamscores_flags(i);
673 l = teamscores_label(i);
674 out = strcat(out, GetScoreLogLabel(l, f), ",");
677 for(i = 0; i < MAX_TEAMSCORE; ++i)
678 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
680 f = teamscores_flags(i);
681 l = teamscores_label(i);
682 out = strcat(out, GetScoreLogLabel(l, f), ",");
685 for(i = 0; i < MAX_TEAMSCORE; ++i)
686 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
687 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
689 f = teamscores_flags(i);
690 l = teamscores_label(i);
691 out = strcat(out, GetScoreLogLabel(l, f), ",");
693 out = substring(out, 0, strlen(out) - 1);
695 else if((sk = teamscorekeepers[tm - 1]))
697 for(i = 0; i < MAX_TEAMSCORE; ++i)
698 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_PRIMARY)
699 out = strcat(out, ftos(sk.(teamscores(i))), ",");
701 for(i = 0; i < MAX_TEAMSCORE; ++i)
702 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) == SFL_SORT_PRIO_SECONDARY)
703 out = strcat(out, ftos(sk.(teamscores(i))), ",");
705 for(i = 0; i < MAX_TEAMSCORE; ++i)
706 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_PRIMARY)
707 if((teamscores_flags(i) & SFL_SORT_PRIO_MASK) != SFL_SORT_PRIO_SECONDARY)
708 out = strcat(out, ftos(sk.(teamscores(i))), ",");
709 out = substring(out, 0, strlen(out) - 1);
714 float PlayerTeamScore_Compare(entity p1, entity p2, float teams, bool strict)
716 if(teams && teamscores_entities_count)
718 if(p1.team != p2.team)
722 t1 = teamscorekeepers[p1.team - 1];
723 t2 = teamscorekeepers[p2.team - 1];
724 r = TeamScore_Compare(t1, t2, ((teams >= 0) ? 1 : strict));
731 return PlayerScore_Compare(CS(p1).scorekeeper, CS(p2).scorekeeper, strict);
734 entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators)
736 entity p, plist, pprev, pbest, pbestprev, pfirst, plast;
741 FOREACH_CLIENT(true, { it.(field) = 0; });
743 FOREACH_CLIENT(CS(it).scorekeeper,
746 if(it.frags == FRAGS_SPECTATOR)
752 // Now plist points to the whole list.
754 pfirst = plast = NULL;
759 pprev = pbestprev = NULL;
761 for(p = plist; (pprev = p), (p = p.chain); )
763 if(PlayerTeamScore_Compare(p, pbest, teams, strict) > 0)
770 // remove pbest out of the chain
771 if(pbestprev == NULL)
774 pbestprev.chain = pbest.chain;
778 if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, strict))
793 float TeamScore_GetCompareValue(float t)
798 if(t <= 0 || t >= 16)
802 error("Reading score of invalid team!");
805 sk = teamscorekeepers[t - 1];
808 s = sk.teamscores_primary;
809 if(teamscores_flags_primary & SFL_ZERO_IS_WORST)
812 if(teamscores_flags_primary & SFL_LOWER_IS_BETTER)
817 const float NAMEWIDTH = 22;
818 const float SCORESWIDTH = 58;
819 // TODO put this somewhere in common?
820 string Score_NicePrint_ItemColor(float vflags)
822 if(vflags & SFL_SORT_PRIO_PRIMARY)
824 else if(vflags & SFL_SORT_PRIO_SECONDARY)
830 void Score_NicePrint_Team(entity to, float t, float w)
838 sk = teamscorekeepers[t - 1];
841 s = strcat(s, Team_ColoredFullName(t));
842 for(i = 0; i < MAX_TEAMSCORE; ++i)
843 if(teamscores_label(i) != "")
845 fl = teamscores_flags(i);
846 sc = sk.(teamscores(i));
847 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), ScoreString(fl, sc));
853 s = strcat(s, strpad(max(0, NAMEWIDTH - strlennocol(s)), ""));
855 FOREACH(Scores, true, {
856 if(scores_label(it) != "")
858 fl = scores_flags(it);
859 s2 = scores_label(it);
860 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, substring(s2, 0, w)));
867 void Score_NicePrint_Player(entity to, entity p, float w)
875 sk = CS(p).scorekeeper;
877 s = strcat(s, playername(p.netname, p.team, false));
880 i = strlennocol(s) - NAMEWIDTH;
882 s = substring(s, 0, strlen(s) - i);
885 s = strcat(s, strpad(i, ""));
890 FOREACH(Scores, true, {
891 if(scores_label(it) != "")
893 fl = scores_flags(it);
894 sc = sk.(scores(it));
895 s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, ScoreString(fl, sc)));
902 void Score_NicePrint_Spectators(entity to)
904 print_to(to, "Spectators:");
907 void Score_NicePrint_Spectator(entity to, entity p)
909 print_to(to, strcat(" ", playername(p.netname, p.team, false)));
912 .float score_dummyfield;
913 void Score_NicePrint(entity to)
919 FOREACH(Scores, true, {
920 if(scores_label(it) != "")
923 w = bound(6, floor(SCORESWIDTH / t - 1), 9);
925 p = PlayerScore_Sort(score_dummyfield, 1, true, false);
928 if(!teamscores_entities_count)
929 Score_NicePrint_Team(to, t, w);
932 if(teamscores_entities_count)
934 Score_NicePrint_Team(to, p.team, w);
935 Score_NicePrint_Player(to, p, w);
941 FOREACH_CLIENT(!IS_PLAYER(it), {
943 Score_NicePrint_Spectators(to);
944 Score_NicePrint_Spectator(to, it);
949 void PlayerScore_PlayerStats(entity p)
951 entity s = CS(p).scorekeeper;
952 FOREACH(Scores, true, {
953 if(s.(scores(it)) != 0 && scores_label(it) != "")
954 PlayerStats_GameReport_Event_Player(s.owner,
955 strcat(PLAYERSTATS_SCOREBOARD, scores_label(it)), s.(scores(it)));
959 void PlayerScore_TeamStats()
963 for(t = 0; t < 16; ++t)
965 sk = teamscorekeepers[t];
968 for(i = 0; i < MAX_TEAMSCORE; ++i)
969 if(sk.(teamscores(i)) != 0 && teamscores_label(i) != "")
970 // the +1 is important here!
971 PlayerStats_GameReport_Event_Team(t+1,
972 strcat(PLAYERSTATS_SCOREBOARD, teamscores_label(i)), sk.(teamscores(i)));