#include "scores.qh"
#include "command/common.qh"
-#include "mutators/all.qh"
+#include "mutators/_mod.qh"
+#include <common/net_linked.qh>
#include "../common/playerstats.qh"
#include "../common/teams.qh"
longflags = 0;
for(i = 0, p = 1; i < MAX_TEAMSCORE; ++i, p *= 2)
- if(self.(teamscores(i)) > 127 || self.(teamscores(i)) <= -128)
+ if(this.(teamscores(i)) > 127 || this.(teamscores(i)) <= -128)
longflags |= p;
#if MAX_TEAMSCORE <= 8
if(sendflags & p)
{
if(longflags & p)
- WriteInt24_t(MSG_ENTITY, self.(teamscores(i)));
+ WriteInt24_t(MSG_ENTITY, this.(teamscores(i)));
else
- WriteChar(MSG_ENTITY, self.(teamscores(i)));
+ WriteChar(MSG_ENTITY, this.(teamscores(i)));
}
return true;
{
entity s;
- if(gameover)
+ if(game_stopped)
score = 0;
if(!scores_initialized) return 0; // FIXME remove this when everything uses this system
if(t <= 0 || t >= 16)
{
- if(gameover)
+ if(game_stopped)
return 0;
error("Adding score to invalid team!");
}
s = teamscorekeepers[t - 1];
if(!s)
{
- if(gameover)
+ if(game_stopped)
return 0;
error("Adding score to unknown team!");
}
if(score)
if(teamscores_label(scorefield) != "")
- s.SendFlags |= pow(2, scorefield);
+ s.SendFlags |= (2 ** scorefield);
return (s.(teamscores(scorefield)) += score);
}
{
float i;
WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES_INFO);
- WriteInt24_t(MSG_ENTITY, MapInfo_LoadedGametype);
+ WriteRegistered(Gametypes, MSG_ENTITY, MapInfo_LoadedGametype);
FOREACH(Scores, true, {
WriteString(MSG_ENTITY, scores_label(it));
WriteByte(MSG_ENTITY, scores_flags(it));
return true;
}
-void ScoreInfo_Init(float teams)
+void ScoreInfo_Init(int teams)
{
if(scores_initialized)
{
scores_initialized = new_pure(ent_client_scoreinfo);
Net_LinkEntity(scores_initialized, false, 0, ScoreInfo_SendEntity);
}
- if(teams >= 1)
+ if(teams & BIT(0))
TeamScore_Spawn(NUM_TEAM_1, "Red");
- if(teams >= 2)
+ if(teams & BIT(1))
TeamScore_Spawn(NUM_TEAM_2, "Blue");
- if(teams >= 3)
+ if(teams & BIT(2))
TeamScore_Spawn(NUM_TEAM_3, "Yellow");
- if(teams >= 4)
+ if(teams & BIT(3))
TeamScore_Spawn(NUM_TEAM_4, "Pink");
}
bool PlayerScore_SendEntity(entity this, entity to, float sendflags)
{
WriteHeader(MSG_ENTITY, ENT_CLIENT_SCORES);
- WriteByte(MSG_ENTITY, etof(self.owner));
+ WriteByte(MSG_ENTITY, etof(this.owner));
int longflags = 0;
FOREACH(Scores, true, {
int p = 1 << (i % 16);
- if (self.(scores(it)) > 127 || self.(scores(it)) <= -128)
+ if (this.(scores(it)) > 127 || this.(scores(it)) <= -128)
longflags |= p;
});
if (sendflags & p)
{
if(longflags & p)
- WriteInt24_t(MSG_ENTITY, self.(scores(it)));
+ WriteInt24_t(MSG_ENTITY, this.(scores(it)));
else
- WriteChar(MSG_ENTITY, self.(scores(it)));
+ WriteChar(MSG_ENTITY, this.(scores(it)));
}
});
FOREACH(Scores, true, {
if(sk.(scores(it)) != 0)
if(scores_label(it) != "")
- sk.SendFlags |= pow(2, i % 16);
+ sk.SendFlags |= (2 ** (i % 16));
sk.(scores(it)) = 0;
});
FOREACH(Scores, true, {
if(sk.(scores(it)) != 0)
if(scores_label(it) != "")
- sk.SendFlags |= pow(2, i % 16);
+ sk.SendFlags |= (2 ** (i % 16));
sk.(scores(it)) = 0;
});
});
{
if(sk.(teamscores(j)) != 0)
if(teamscores_label(j) != "")
- sk.SendFlags |= pow(2, j);
+ sk.SendFlags |= (2 ** j);
sk.(teamscores(j)) = 0;
}
}
{
if(!player.scorekeeper)
error("player has no scorekeeper");
- remove(player.scorekeeper);
- player.scorekeeper = world;
+ delete(player.scorekeeper);
+ player.scorekeeper = NULL;
}
float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
{
- bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score);
- score = ret_float;
+ bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score, player);
+ score = M_ARGV(1, float);
- if(gameover)
+ if(game_stopped)
if(!mutator_returnvalue)
score = 0;
entity s = player.scorekeeper;
if(!s)
{
- if(gameover)
+ if(game_stopped)
return 0;
- LOG_WARNING("Adding score to unknown player!");
+ LOG_WARN("Adding score to unknown player!");
return 0;
}
if(score)
if(scores_label(scorefield) != "")
- s.SendFlags |= pow(2, scorefield.m_id % 16);
+ s.SendFlags |= (2 ** (scorefield.m_id % 16));
if(!warmup_stage)
PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score);
return (s.(scores(scorefield)) += score);
return result.x;
}
-void WinningConditionHelper()
+void WinningConditionHelper(entity this)
{
- SELFPARAM();
float c;
string s;
float fullstatus;
s = GetGametype();
s = strcat(s, ":", autocvar_g_xonoticversion);
s = strcat(s, ":P", ftos(cvar_purechanges_count));
- s = strcat(s, ":S", ftos(nJoinAllowed(self, world)));
+ s = strcat(s, ":S", ftos(nJoinAllowed(this, NULL)));
s = strcat(s, ":F", ftos(serverflags));
s = strcat(s, ":M", modname);
- s = strcat(s, "::", GetPlayerScoreString(world, (fullstatus ? 1 : 2)));
+ s = strcat(s, "::", GetPlayerScoreString(NULL, (fullstatus ? 1 : 2)));
if(teamscores_entities_count)
{
WinningConditionHelper_winnerteam = -1;
WinningConditionHelper_secondteam = -1;
- winnerscorekeeper = world;
- secondscorekeeper = world;
+ winnerscorekeeper = NULL;
+ secondscorekeeper = NULL;
for(t = 0; t < 16; ++t)
{
sk = teamscorekeepers[t];
WinningConditionHelper_lowerisbetter = (teamscores_flags_primary & SFL_LOWER_IS_BETTER);
WinningConditionHelper_zeroisworst = (teamscores_flags_primary & SFL_ZERO_IS_WORST);
- WinningConditionHelper_winner = world; // not supported in teamplay
- WinningConditionHelper_second = world; // not supported in teamplay
+ WinningConditionHelper_winner = NULL; // not supported in teamplay
+ WinningConditionHelper_second = NULL; // not supported in teamplay
}
else
{
- WinningConditionHelper_winner = world;
- WinningConditionHelper_second = world;
- winnerscorekeeper = world;
- secondscorekeeper = world;
+ WinningConditionHelper_winner = NULL;
+ WinningConditionHelper_second = NULL;
+ winnerscorekeeper = NULL;
+ secondscorekeeper = NULL;
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
sk = it.scorekeeper;
c = PlayerScore_Compare(winnerscorekeeper, sk, 1);
WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, 0) == 0);
if(WinningConditionHelper_equality)
- WinningConditionHelper_winner = WinningConditionHelper_second = world;
+ WinningConditionHelper_winner = WinningConditionHelper_second = NULL;
WinningConditionHelper_topscore = winnerscorekeeper.scores_primary;
WinningConditionHelper_secondscore = secondscorekeeper.scores_primary;
{
s = GetPlayerScoreString(it, 1);
s = strcat(s, IS_REAL_CLIENT(it) ? ":human" : ":bot");
- ret_string = string_null;
- if(!IS_PLAYER(it) && !MUTATOR_CALLHOOK(GetPlayerStatus, it, s))
+ if(!IS_PLAYER(it) && !MUTATOR_CALLHOOK(GetPlayerStatus, it))
s = strcat(s, ":spectator");
- if (ret_string) s = strcat(s, ret_string);
}
else
{
- ret_string = string_null;
- if (IS_PLAYER(it) || MUTATOR_CALLHOOK(GetPlayerStatus, it, s))
+ if (IS_PLAYER(it) || MUTATOR_CALLHOOK(GetPlayerStatus, it))
s = GetPlayerScoreString(it, 2);
else
s = "-666";
- if (ret_string) s = strcat(s, ret_string);
}
if(it.clientstatus)
entity p, plist, pprev, pbest, pbestprev, pfirst, plast;
float i, j;
- plist = world;
+ plist = NULL;
FOREACH_CLIENT(true, LAMBDA(it.(field) = 0));
});
// Now plist points to the whole list.
- pfirst = plast = world;
+ pfirst = plast = NULL;
i = j = 0;
while(plist)
{
- pprev = pbestprev = world;
+ pprev = pbestprev = NULL;
pbest = plist;
for(p = plist; (pprev = p), (p = p.chain); )
{
}
// remove pbest out of the chain
- if(pbestprev == world)
+ if(pbestprev == NULL)
plist = pbest.chain;
else
pbestprev.chain = pbest.chain;
- pbest.chain = world;
+ pbest.chain = NULL;
++i;
if(!plast || PlayerTeamScore_Compare(plast, pbest, teams, 0))
if(t <= 0 || t >= 16)
{
- if(gameover)
+ if(game_stopped)
return 0;
error("Reading score of invalid team!");
}
sk = p.scorekeeper;
- s = strcat(s, p.netname);
+ s = strcat(s, playername(p, false));
for (;;)
{
i = strlennocol(s) - NAMEWIDTH;
void Score_NicePrint_Spectator(entity to, entity p)
{
- print_to(to, strcat(" ", p.netname));
+ print_to(to, strcat(" ", playername(p, false)));
}
.float score_dummyfield;