X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fscores.qc;h=512f61ad231ae5d4255ec197a7b4d0667416220a;hp=12175bb764f036435c1f745c0ac2ddc12fe74777;hb=bba2475e3a8b84e359ffae9b530d651f4d63e99a;hpb=f7673c11a5261668cc3e3896391fafd546168994 diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index 12175bb764..512f61ad23 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -1,19 +1,20 @@ #include "scores.qh" -#include "command/common.qh" -#include "defs.qh" -#include -#include -#include -#include -#include -#include "../common/playerstats.qh" -#include "../common/teams.qh" #include #include +#include +#include #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include .entity scorekeeper; entity teamscorekeepers[16]; @@ -23,7 +24,7 @@ var .float teamscores_primary; float scores_flags_primary; float teamscores_flags_primary; -vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags, vector previous, float strict) // returns: cmp value, best prio +vector ScoreField_Compare(entity t1, entity t2, .float field, float fieldflags, vector previous, bool strict) // returns: cmp value, best prio { if(!strict && !(fieldflags & SFL_SORT_PRIO_MASK)) // column does not sort return previous; @@ -129,7 +130,7 @@ float TeamScore_AddToTeam(int t, float scorefield, float score) } if(score) if(teamscores_label(scorefield) != "") - s.SendFlags |= (2 ** scorefield); + s.SendFlags |= BIT(scorefield); return (s.(teamscores(scorefield)) += score); } @@ -138,7 +139,7 @@ float TeamScore_Add(entity player, float scorefield, float score) return TeamScore_AddToTeam(player.team, scorefield, score); } -float TeamScore_Compare(entity t1, entity t2, float strict) +float TeamScore_Compare(entity t1, entity t2, bool strict) { if(!t1 || !t2) return (!t2) - !t1; @@ -207,6 +208,13 @@ bool ScoreInfo_SendEntity(entity this, entity to, int sf) WriteString(MSG_ENTITY, teamscores_label(i)); WriteByte(MSG_ENTITY, teamscores_flags(i)); } + // prevent sending the welcome message again when score types are sent again because the scoring system has changed + // it can happen in some game modes like Race when the qualyfing session ends and the race starts + bool welcome_msg_too = (!CS(to) || time < CS(to).jointime + 5); + WriteByte(MSG_ENTITY, welcome_msg_too); + // welcome message is sent here because it needs to know the gametype + if (welcome_msg_too) + SendWelcomeMessage(to, MSG_ENTITY); return true; } @@ -276,7 +284,7 @@ float PlayerScore_Clear(entity player) FOREACH(Scores, true, { if(sk.(scores(it)) != 0) if(scores_label(it) != "") - sk.SendFlags |= (2 ** (i % 16)); + sk.SendFlags |= BIT(i % 16); if(i != SP_ELO.m_id) sk.(scores(it)) = 0; }); @@ -294,7 +302,7 @@ void Score_ClearAll() FOREACH(Scores, true, { if(sk.(scores(it)) != 0) if(scores_label(it) != "") - sk.SendFlags |= (2 ** (i % 16)); + sk.SendFlags |= BIT(i % 16); if(i != SP_ELO.m_id) sk.(scores(it)) = 0; }); @@ -308,7 +316,7 @@ void Score_ClearAll() { if(sk.(teamscores(j)) != 0) if(teamscores_label(j) != "") - sk.SendFlags |= (2 ** j); + sk.SendFlags |= BIT(j); sk.(teamscores(j)) = 0; } } @@ -356,7 +364,7 @@ float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score) return s.(scores(scorefield)); } if(scores_label(scorefield) != "") - s.SendFlags |= (2 ** (scorefield.m_id % 16)); + s.SendFlags |= BIT(scorefield.m_id % 16); if(!warmup_stage) PlayerStats_GameReport_Event_Player(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score); s.(scores(scorefield)) += score; @@ -381,7 +389,7 @@ float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score) return oldscore; if(scores_label(scorefield) != "") - s.SendFlags |= (2 ** (scorefield.m_id % 16)); + s.SendFlags |= BIT(scorefield.m_id % 16); s.(scores(scorefield)) = score; return s.(scores(scorefield)); } @@ -395,7 +403,7 @@ float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tsc return r; } -float PlayerScore_Compare(entity t1, entity t2, float strict) +float PlayerScore_Compare(entity t1, entity t2, bool strict) { if(!t1 || !t2) return (!t2) - !t1; @@ -433,6 +441,7 @@ void WinningConditionHelper(entity this) s = strcat(s, ":P", ftos(cvar_purechanges_count)); s = strcat(s, ":S", ftos(nJoinAllowed(this, NULL))); s = strcat(s, ":F", ftos(serverflags)); + s = strcat(s, ":T", sv_termsofservice_url_escaped); s = strcat(s, ":M", modname); s = strcat(s, "::", GetPlayerScoreString(NULL, (fullstatus ? 1 : 2))); @@ -491,7 +500,7 @@ void WinningConditionHelper(entity this) secondscorekeeper = NULL; FOREACH_CLIENT(IS_PLAYER(it), { sk = CS(it).scorekeeper; - c = PlayerScore_Compare(winnerscorekeeper, sk, 1); + c = PlayerScore_Compare(winnerscorekeeper, sk, true); if(c < 0) { WinningConditionHelper_second = WinningConditionHelper_winner; @@ -501,7 +510,7 @@ void WinningConditionHelper(entity this) } else { - c = PlayerScore_Compare(secondscorekeeper, sk, 1); + c = PlayerScore_Compare(secondscorekeeper, sk, true); if(c < 0) { WinningConditionHelper_second = it; @@ -510,7 +519,7 @@ void WinningConditionHelper(entity this) } }); - WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0); + WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, false) == 0); if(WinningConditionHelper_equality) WinningConditionHelper_winner = WinningConditionHelper_second = NULL; @@ -532,7 +541,8 @@ void WinningConditionHelper(entity this) else WinningConditionHelper_topscore = -999999999; } - WinningConditionHelper_equality = 0; + if(player_count == 0) // special case: empty servers DO end the match at a 0:0 tie + WinningConditionHelper_equality = 0; } if(WinningConditionHelper_secondscore == 0) @@ -554,12 +564,12 @@ void WinningConditionHelper(entity this) { s = GetPlayerScoreString(it, 1); s = strcat(s, IS_REAL_CLIENT(it) ? ":human" : ":bot"); - if(!IS_PLAYER(it) && !MUTATOR_CALLHOOK(GetPlayerStatus, it)) + if(!(IS_PLAYER(it) || INGAME_JOINED(it))) s = strcat(s, ":spectator"); } else { - if (IS_PLAYER(it) || MUTATOR_CALLHOOK(GetPlayerStatus, it)) + if (IS_PLAYER(it) || INGAME_JOINED(it)) s = GetPlayerScoreString(it, 2); else s = "-666"; @@ -698,7 +708,7 @@ string GetTeamScoreString(float tm, float shortString) return out; } -float PlayerTeamScore_Compare(entity p1, entity p2, float teams, float strict) +float PlayerTeamScore_Compare(entity p1, entity p2, float teams, bool strict) { if(teams && teamscores_entities_count) { @@ -718,7 +728,7 @@ float PlayerTeamScore_Compare(entity p1, entity p2, float teams, float strict) return PlayerScore_Compare(CS(p1).scorekeeper, CS(p2).scorekeeper, strict); } -entity PlayerScore_Sort(.float field, float teams, float strict, float nospectators) +entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators) { entity p, plist, pprev, pbest, pbestprev, pfirst, plast; float i, j; @@ -762,7 +772,7 @@ entity PlayerScore_Sort(.float field, float teams, float strict, float nospectat pbest.chain = NULL; ++i; - if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, 0)) + if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, strict)) j = i; pbest.(field) = j; @@ -861,7 +871,7 @@ void Score_NicePrint_Player(entity to, entity p, float w) sk = CS(p).scorekeeper; - s = strcat(s, playername(p, false)); + s = strcat(s, playername(p.netname, p.team, false)); for (;;) { i = strlennocol(s) - NAMEWIDTH; @@ -893,7 +903,7 @@ void Score_NicePrint_Spectators(entity to) void Score_NicePrint_Spectator(entity to, entity p) { - print_to(to, strcat(" ", playername(p, false))); + print_to(to, strcat(" ", playername(p.netname, p.team, false))); } .float score_dummyfield; @@ -909,7 +919,7 @@ void Score_NicePrint(entity to) }); w = bound(6, floor(SCORESWIDTH / t - 1), 9); - p = PlayerScore_Sort(score_dummyfield, 1, 1, 0); + p = PlayerScore_Sort(score_dummyfield, 1, true, false); t = -1; if(!teamscores_entities_count)