From 121af8b6a3d5802b95132cb7c9381192f261ed1d Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 23 Oct 2017 18:41:48 +0200 Subject: [PATCH] Rename 2 macros --- qcsrc/common/playerstats.qc | 21 +++++++++++---------- qcsrc/common/playerstats.qh | 4 ++-- qcsrc/server/anticheat.qc | 5 +++-- qcsrc/server/client.qc | 2 +- qcsrc/server/command/vote.qc | 3 ++- qcsrc/server/g_damage.qc | 10 +++++----- qcsrc/server/player.qc | 2 +- qcsrc/server/scores.qc | 18 +++++++++--------- 8 files changed, 34 insertions(+), 31 deletions(-) diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index d8af62962..0fcd70dfc 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -93,7 +93,6 @@ void PlayerStats_GameReport_AddEvent(string event_id) } } -// referred to by PS_GR_P_ADDVAL and PS_GR_T_ADDVAL float PlayerStats_GameReport_Event(string prefix, string event_id, float value) { if((prefix == "") || PS_GR_OUT_DB < 0) { return 0; } @@ -108,7 +107,8 @@ float PlayerStats_GameReport_Event(string prefix, string event_id, float value) void PlayerStats_GameReport_Accuracy(entity p) { #define ACCMAC(suffix, field) \ - PS_GR_P_ADDVAL(p, sprintf("acc-%s-%s", it.netname, suffix), CS(p).accuracy.(field[i-1])); + PlayerStats_GameReport_Event_Player(p, \ + sprintf("acc-%s-%s", it.netname, suffix), CS(p).accuracy.(field[i-1])); FOREACH(Weapons, it != WEP_Null, { ACCMAC("hit", accuracy_hit) ACCMAC("fired", accuracy_fired) @@ -126,7 +126,7 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) // add global info! if(p.alivetime) { - PS_GR_P_ADDVAL(p, PLAYERSTATS_ALIVETIME, time - p.alivetime); + PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_ALIVETIME, time - p.alivetime); p.alivetime = 0; } @@ -139,7 +139,7 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) db_put(PS_GR_OUT_DB, sprintf("%s:_team", p.playerstats_id), ftos(p.team)); if(stof(db_get(PS_GR_OUT_DB, sprintf("%s:%s", p.playerstats_id, PLAYERSTATS_ALIVETIME))) > 0) - PS_GR_P_ADDVAL(p, PLAYERSTATS_JOINS, 1); + PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_JOINS, 1); PlayerStats_GameReport_Accuracy(p); anticheat_report_to_playerstats(p); @@ -149,7 +149,8 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) if(CS(p).latency_cnt) { float latency = (CS(p).latency_sum / CS(p).latency_cnt); - if(latency) { PS_GR_P_ADDVAL(p, PLAYERSTATS_AVGLATENCY, latency); } + if(latency) + PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_AVGLATENCY, latency); } } @@ -167,16 +168,16 @@ void PlayerStats_GameReport(float finished) FOREACH_CLIENT(true, { // add personal score rank - PS_GR_P_ADDVAL(it, PLAYERSTATS_RANK, it.score_dummyfield); + PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_RANK, it.score_dummyfield); // scoreboard data if(it.scoreboard_pos) { // scoreboard is valid! - PS_GR_P_ADDVAL(it, PLAYERSTATS_SCOREBOARD_VALID, 1); + PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_SCOREBOARD_VALID, 1); // add scoreboard position - PS_GR_P_ADDVAL(it, PLAYERSTATS_SCOREBOARD_POS, it.scoreboard_pos); + PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_SCOREBOARD_POS, it.scoreboard_pos); // add scoreboard data PlayerScore_PlayerStats(it); @@ -184,8 +185,8 @@ void PlayerStats_GameReport(float finished) // if the match ended normally, add winning info if(finished) { - PS_GR_P_ADDVAL(it, PLAYERSTATS_WINS, it.winning); - PS_GR_P_ADDVAL(it, PLAYERSTATS_MATCHES, 1); + PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_WINS, it.winning); + PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_MATCHES, 1); } } diff --git a/qcsrc/common/playerstats.qh b/qcsrc/common/playerstats.qh index 1fafb1397..28f985e27 100644 --- a/qcsrc/common/playerstats.qh +++ b/qcsrc/common/playerstats.qh @@ -69,8 +69,8 @@ void PlayerStats_GameReport_AddTeam(float t); void PlayerStats_GameReport_AddEvent(string event_id); // call on each event to track, or at player disconnect OR match end for "global stuff" -#define PS_GR_P_ADDVAL(ent,eventid,val) PlayerStats_GameReport_Event(ent.playerstats_id, eventid, val) -#define PS_GR_T_ADDVAL(team,eventid,val) PlayerStats_GameReport_Event(sprintf("team#%d", team), eventid, val) +#define PlayerStats_GameReport_Event_Player(ent, eventid, val) PlayerStats_GameReport_Event(ent.playerstats_id, eventid, val) +#define PlayerStats_GameReport_Event_Team(team, eventid, val) PlayerStats_GameReport_Event(sprintf("team#%d", team), eventid, val) float PlayerStats_GameReport_Event(string prefix, string event_id, float value); void PlayerStats_GameReport_Accuracy(entity p); diff --git a/qcsrc/server/anticheat.qc b/qcsrc/server/anticheat.qc index 7173ae597..9327a2034 100644 --- a/qcsrc/server/anticheat.qc +++ b/qcsrc/server/anticheat.qc @@ -202,9 +202,10 @@ void anticheat_report_to_eventlog(entity this) { } void anticheat_report_to_playerstats(entity this) { - PS_GR_P_ADDVAL(this, strcat(PLAYERSTATS_ANTICHEAT, "_time"), servertime - CS(this).anticheat_jointime); + PlayerStats_GameReport_Event_Player(this, + strcat(PLAYERSTATS_ANTICHEAT, "_time"), servertime - CS(this).anticheat_jointime); #define ANTICHEAT_REPORT_ONE(name, f, tmin, mi, ma) \ - PS_GR_P_ADDVAL(this, strcat(PLAYERSTATS_ANTICHEAT, name), f) + PlayerStats_GameReport_Event_Player(this, strcat(PLAYERSTATS_ANTICHEAT, name), f) ANTICHEATS(ANTICHEAT_REPORT_ONE); #undef ANTICHEAT_REPORT_ONE } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index 45e71d559..4f7dd14a5 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -270,7 +270,7 @@ void PutObserverInServer(entity this) if (this.alivetime) { if (!warmup_stage) - PS_GR_P_ADDVAL(this, PLAYERSTATS_ALIVETIME, time - this.alivetime); + PlayerStats_GameReport_Event_Player(this, PLAYERSTATS_ALIVETIME, time - this.alivetime); this.alivetime = 0; } diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 1ed78ad7c..1a826c6f1 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -430,7 +430,8 @@ void ReadyRestart_force() FOREACH_CLIENT(IS_PLAYER(it), { it.alivetime = 0; CS(it).killcount = 0; - PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, -PS_GR_P_ADDVAL(it, PLAYERSTATS_ALIVETIME, 0)); + float val = PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_ALIVETIME, 0); + PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_ALIVETIME, -val); }); restart_mapalreadyrestarted = false; // reset this var, needed when cvar sv_ready_restart_repeatable is in use diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 027046296..c48eb20cd 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -55,7 +55,7 @@ void GiveFrags (entity attacker, entity targ, float f, int deathtype) // regular frag GameRules_scoring_add(attacker, KILLS, 1); if(targ.playerid) - PS_GR_P_ADDVAL(attacker, sprintf("kills-%d", targ.playerid), 1); + PlayerStats_GameReport_Event_Player(attacker, sprintf("kills-%d", targ.playerid), 1); } GameRules_scoring_add(targ, DEATHS, 1); @@ -383,7 +383,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) case counta: \ { \ Send_Notification(NOTIF_ONE, attacker, MSG_ANNCE, ANNCE_KILLSTREAK_##countb); \ - PS_GR_P_ADDVAL(attacker, PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_##counta, 1); \ + PlayerStats_GameReport_Event_Player(attacker, PLAYERSTATS_ACHIEVEMENT_KILL_SPREE_##counta, 1); \ break; \ } switch(CS(attacker).killcount) @@ -397,8 +397,8 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) { checkrules_firstblood = true; notif_firstblood = true; // modify the current messages so that they too show firstblood information - PS_GR_P_ADDVAL(attacker, PLAYERSTATS_ACHIEVEMENT_FIRSTBLOOD, 1); - PS_GR_P_ADDVAL(targ, PLAYERSTATS_ACHIEVEMENT_FIRSTVICTIM, 1); + PlayerStats_GameReport_Event_Player(attacker, PLAYERSTATS_ACHIEVEMENT_FIRSTBLOOD, 1); + PlayerStats_GameReport_Event_Player(targ, PLAYERSTATS_ACHIEVEMENT_FIRSTVICTIM, 1); // tell spree_inf and spree_cen that this is a first-blood and first-victim event kill_count_to_attacker = -1; @@ -513,7 +513,7 @@ void Obituary(entity attacker, entity inflictor, entity targ, int deathtype) if(GameRules_scoring_add(targ, SCORE, 0) == -5) { Send_Notification(NOTIF_ONE, targ, MSG_ANNCE, ANNCE_ACHIEVEMENT_BOTLIKE); - PS_GR_P_ADDVAL(attacker, PLAYERSTATS_ACHIEVEMENT_BOTLIKE, 1); + PlayerStats_GameReport_Event_Player(attacker, PLAYERSTATS_ACHIEVEMENT_BOTLIKE, 1); } } diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index d9226f343..ac2dcb1ed 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -517,7 +517,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, if(this.alivetime) { - PS_GR_P_ADDVAL(this, PLAYERSTATS_ALIVETIME, time - this.alivetime); + PlayerStats_GameReport_Event_Player(this, PLAYERSTATS_ALIVETIME, time - this.alivetime); this.alivetime = 0; } diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index b25a65f1a..32fe3c6aa 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -347,7 +347,7 @@ 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)); @@ -908,10 +908,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 +924,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))); } } -- 2.39.2