X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fscores.qc;h=3f1db42903ddd010c209febba24f608cba1c1840;hb=5474a5152e728066668d1399703cb2fba4fd9124;hp=b25a65f1a7c127f348e897c392d4db2f00fb6734;hpb=05776c4204bf73c8ebc84e615ad088af45ebe5ed;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index b25a65f1a..3f1db4290 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -96,7 +96,7 @@ void TeamScore_Spawn(float t, string name) PlayerStats_GameReport_AddTeam(t); } -float TeamScore_AddToTeam(float t, float scorefield, float score) +float TeamScore_AddToTeam(int t, float scorefield, float score) { entity s; @@ -347,12 +347,34 @@ float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score) if(scores_label(scorefield) != "") s.SendFlags |= (2 ** (scorefield.m_id % 16)); if(!warmup_stage) - PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score); + PlayerStats_GameReport_Event_Player(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score); s.(scores(scorefield)) += score; MUTATOR_CALLHOOK(AddedPlayerScore, scorefield, score, player); return s.(scores(scorefield)); } +float PlayerScore_Set(entity player, PlayerScoreField scorefield, float score) +{ + if(!scores_initialized) return 0; // FIXME remove this when everything uses this system + entity s = CS(player).scorekeeper; + if(!s) + { + if(game_stopped) + return 0; + LOG_WARN("Setting score of unknown player!"); + return 0; + } + + float oldscore = s.(scores(scorefield)); + if(oldscore == score) + return oldscore; + + if(scores_label(scorefield) != "") + s.SendFlags |= (2 ** (scorefield.m_id % 16)); + s.(scores(scorefield)) = score; + return s.(scores(scorefield)); +} + float PlayerTeamScore_Add(entity player, PlayerScoreField pscorefield, float tscorefield, float score) { float r; @@ -908,10 +930,10 @@ void PlayerScore_PlayerStats(entity p) { entity s = CS(p).scorekeeper; FOREACH(Scores, true, { - if(s.(scores(it)) != 0) - if(scores_label(it) != "") - PS_GR_P_ADDVAL(s.owner, strcat(PLAYERSTATS_SCOREBOARD, scores_label(it)), s.(scores(it))); - }); + if(s.(scores(it)) != 0 && scores_label(it) != "") + PlayerStats_GameReport_Event_Player(s.owner, + strcat(PLAYERSTATS_SCOREBOARD, scores_label(it)), s.(scores(it))); + }); } void PlayerScore_TeamStats() @@ -924,9 +946,9 @@ void PlayerScore_TeamStats() if(!sk) continue; for(i = 0; i < MAX_TEAMSCORE; ++i) - if(sk.(teamscores(i)) != 0) - if(teamscores_label(i) != "") - // the +1 is important here! - PS_GR_T_ADDVAL(t+1, strcat(PLAYERSTATS_SCOREBOARD, teamscores_label(i)), sk.(teamscores(i))); + if(sk.(teamscores(i)) != 0 && teamscores_label(i) != "") + // the +1 is important here! + PlayerStats_GameReport_Event_Team(t+1, + strcat(PLAYERSTATS_SCOREBOARD, teamscores_label(i)), sk.(teamscores(i))); } }