34 if (t1.(field) == t2.(field))
44 else if (t2.(field) == 0)
52 previous = (t2.(field) - t1.(field));
54 previous = (t1.(field) - t2.(field));
68 int t = this.
team - 1;
85 if(sendflags &
BIT(i))
87 if(longflags &
BIT(i))
115 if(t <= 0 || t >= 16)
119 error(
"Adding score to invalid team!");
126 error(
"Adding score to unknown team!");
130 s.SendFlags |=
BIT(scorefield);
131 return (s.(teamscores(scorefield)) += score);
142 if(!t1 || !t2)
return (!t2) - !t1;
146 error(
"MAX_TEAMSCORE > 2 not supported");
152 if (
result == 0 && strict)
157 result = t1.team - t2.team;
224 bool welcome_msg_too = (!
CS(to) ||
time <
CS(to).jointime + 5);
265 if (this.(
scores(it)) > 127 || this.(
scores(it)) <= -128)
295 sk =
CS(player).scorekeeper;
298 sk.SendFlags |=
BIT(i % 16);
299 if(i != SP_SKILL.m_id)
311 sk =
CS(it).scorekeeper;
315 sk.SendFlags |=
BIT(i % 16);
316 if(i != SP_SKILL.m_id)
320 for(t = 0; t < 16; ++t)
328 sk.SendFlags |=
BIT(j);
329 sk.(teamscores(j)) = 0;
337 error(
"player already has a scorekeeper");
341 CS(player).scorekeeper = sk;
347 error(
"player has no scorekeeper");
348 delete(
CS(player).scorekeeper);
349 CS(player).scorekeeper =
NULL;
354 bool mutator_returnvalue =
MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score, player);
368 LOG_WARN(
"Adding score to unknown player!");
373 return s.(scores(scorefield));
376 s.SendFlags |=
BIT(scorefield.m_id % 16);
379 s.(scores(scorefield)) += score;
381 return s.(scores(scorefield));
392 LOG_WARN(
"Setting score of unknown player!");
396 float oldscore = s.(scores(scorefield));
397 if(oldscore == score)
401 s.SendFlags |=
BIT(scorefield.m_id % 16);
402 s.(scores(scorefield)) = score;
403 return s.(scores(scorefield));
417 if(!t1 || !t2)
return (!t2) - !t1;
425 if (
result == 0 && strict)
432 var .float f =
scores(it);
437 result = t1.owner.playerid - t2.owner.playerid;
475 for(t = 0; t < 16; ++t)
481 for(t = 0; t < 16; ++t)
489 secondscorekeeper = winnerscorekeeper;
490 winnerscorekeeper = sk;
498 secondscorekeeper = sk;
520 sk =
CS(it).scorekeeper;
526 secondscorekeeper = winnerscorekeeper;
527 winnerscorekeeper = sk;
535 secondscorekeeper = sk;
587 s =
strcat(s,
":spectator");
597 if (s != it.clientstatus)
598 strcpy(it.clientstatus, s);
605 label =
strcat(label,
"<");
607 label =
strcat(label,
"!!");
609 label =
strcat(label,
"!");
656 out =
strcat(out,
ftos(sk.(scores(it))),
",");
661 out =
strcat(out,
ftos(sk.(scores(it))),
",");
667 out =
strcat(out,
ftos(sk.(scores(it))),
",");
714 out =
strcat(out,
ftos(sk.(teamscores(i))),
",");
718 out =
strcat(out,
ftos(sk.(teamscores(i))),
",");
723 out =
strcat(out,
ftos(sk.(teamscores(i))),
",");
734 if(p1.team != p2.team)
750 entity p, plist, pprev, pbest, pbestprev, pfirst, plast;
767 pfirst = plast =
NULL;
772 pprev = pbestprev =
NULL;
774 for(p = plist; (pprev = p), (p = p.chain); )
784 if(pbestprev ==
NULL)
787 pbestprev.chain = pbest.chain;
810 if(t <= 0 || t >= 16)
814 error(
"Reading score of invalid team!");
820 s = sk.teamscores_primary;
855 float sc = sk.(teamscores(i));
889 s =
strcat(s, strpad(i,
""));
898 float sc = sk.(scores(it));
962 for (
int t = 0; t < 16; ++t)
#define MUTATOR_CALLHOOK(id,...)
#define BIT(n)
Only ever assign into the first 24 bits in QC (so max is BIT(23)).
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define scores_label(this)
const int SFL_LOWER_IS_BETTER
Lower scores are better (e.g.
#define teamscores_flags(i)
#define teamscores_label(i)
#define scores_flags(this)
const int SFL_NOT_SORTABLE
const int SFL_SORT_PRIO_MASK
const int SFL_SORT_PRIO_SECONDARY
Scoring priority (NOTE: PRIMARY is used for fraglimit) NOTE: SFL_SORT_PRIO_SECONDARY value must be lo...
#define SFL_ZERO_IS_WORST
const int SFL_SORT_PRIO_PRIMARY
string playername(string thename, int teamid, bool team_colorize)
string ScoreString(int pFlags, float pValue, int rounds_played)
const int FRAGS_SPECTATOR
#define FOREACH(list, cond, body)
#define WriteHeader(to, id)
void Net_LinkEntity(entity e, bool docull, float dt, bool(entity this, entity to, int sendflags) sendfunc)
#define WriteRegistered(r, to, it)
Gametype MapInfo_LoadedGametype
spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 spree_inf s1 s2 s3loc s2 s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2loc s1 s2 f1points s1 s2
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
#define new_pure(class)
purely logical entities (not linked to the area grid)
void PlayerStats_GameReport_AddTeam(int t)
void PlayerStats_GameReport_AddEvent(string event_id)
#define PlayerStats_GameReport_Event_Team(team, eventid, val)
const string PLAYERSTATS_SCOREBOARD
const string PLAYERSTATS_TOTAL
#define PlayerStats_GameReport_Event_Player(ent, eventid, val)
void Score_NicePrint_Team(entity to, float t, float w)
string Score_NicePrint_ItemColor(int vflags)
int ScoreField_Compare(entity t1, entity t2,.float field, int fieldflags, int previous)
void PlayerScore_Detach(entity player)
Detaches a PlayerScore entity from the player.
entity teamscorekeepers[16]
string GetTeamScoreString(int tm, float shortString)
int scores_flags_secondary
float TeamScore_Add(entity player, float scorefield, float score)
Adds a score to the player's team's scores.
var int teamscores_primary
float TeamScore_GetCompareValue(float t)
Returns a value indicating the team score (and higher is better).
void WinningConditionHelper(entity this)
Sets the following results for the current scores entities.
void ScoreInfo_Init(int teams)
Initialize the scores info for the given number of teams.
string GetScoreLogLabel(string label, float fl)
void Score_ClearAll()
Clear ALL scores (for ready-restart).
void TeamScore_Spawn(float t, string name)
int teamscores_flags_primary
void Score_NicePrint_Spectator(entity to, entity p)
float TeamScore_AddToTeam(int t, float scorefield, float score)
Adds a score to the given team.
int teamscores_entities_count
void ScoreInfo_SetLabel_TeamScore(int i, string label, int scoreflags)
bool ScoreInfo_SendEntity(entity this, entity to, int sf)
float PlayerScore_Compare(entity t1, entity t2, bool strict)
void PlayerScore_PlayerStats(entity p)
float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score)
Adds a score to both the player and the team.
void Score_NicePrint_Player(entity to, entity p, float w)
int PlayerTeamScore_Compare(entity p1, entity p2, float teams, bool strict)
void PlayerScore_Attach(entity player)
Attaches a PlayerScore entity to a player.
void Score_NicePrint(entity to)
Prints the scores to the console of a player.
bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
int TeamScore_Compare(entity t1, entity t2, bool strict)
void Score_NicePrint_Spectators(entity to)
string GetPlayerScoreString(entity pl, float shortString)
Returns score strings for eventlog etc.
entity PlayerScore_Sort(.float field, int teams, bool strict, bool nospectators)
Sorts the players and stores their place in the given field, starting with.
void ScoreInfo_SetLabel_PlayerScore(PlayerScoreField i, string label, int scoreflags)
float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
Adds a score to the player's scores.
bool TeamScore_SendEntity(entity this, entity to, float sendflags)
float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score)
Sets the player's score to the score parameter.
bool PlayerScore_Clear(entity player)
Initialize the score of this player if needed.
void PlayerScore_TeamStats()
void SendWelcomeMessage(entity this, int msg_type)
int nJoinAllowed(entity this)
Determines how many player slots are free.
string autocvar_g_xonoticversion
void print_to(entity to, string input)
float WinningConditionHelper_secondscore
second highest score
entity WinningConditionHelper_second
the second player, or NULL if none
entity scores_initialized
float WinningConditionHelper_winnerteam
the color of the winning team, or -1 if none
entity WinningConditionHelper_winner
the winning player, or NULL if none
float WinningConditionHelper_topscore
highest score
float WinningConditionHelper_equality
we have no winner
bool autocvar_g_full_getstatus_responses
float WinningConditionHelper_lowerisbetter
lower is better, duh
float WinningConditionHelper_zeroisworst
zero is worst, duh
float WinningConditionHelper_secondteam
the color of the second team, or -1 if none
ClientState CS(Client this)
#define INGAME_JOINED(it)
#define Team_ColoredFullName(teamid)
#define IS_REAL_CLIENT(v)
#define FOREACH_CLIENT(cond, body)
#define FOREACH_CLIENTSLOT(cond, body)
string loaded_gametype_custom_string
float cvar_purechanges_count
string sv_termsofservice_url_escaped