From a8c333c584388ac09bcac28d98690b0d41d34729 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 18 May 2025 20:17:03 +0200 Subject: [PATCH] Exclude time before the match starts (countdown) in the alive time sent to Xonstat --- qcsrc/common/playerstats.qc | 6 +++--- qcsrc/server/client.qc | 10 +++++----- qcsrc/server/client.qh | 2 +- qcsrc/server/command/vote.qc | 2 +- qcsrc/server/player.qc | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/qcsrc/common/playerstats.qc b/qcsrc/common/playerstats.qc index c90d4577cf..925c860227 100644 --- a/qcsrc/common/playerstats.qc +++ b/qcsrc/common/playerstats.qc @@ -184,10 +184,10 @@ void PlayerStats_GameReport_FinalizePlayer(entity p) if((p.playerstats_id == "") || PS_GR_OUT_DB < 0) { return; } // add global info! - if(p.alivetime) + if(p.alivetime_start) { - PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_ALIVETIME, time - p.alivetime); - p.alivetime = 0; + PlayerStats_GameReport_Event_Player(p, PLAYERSTATS_ALIVETIME, max(0, time - p.alivetime_start)); + p.alivetime_start = 0; } db_put(PS_GR_OUT_DB, sprintf("%s:_playerid", p.playerstats_id), ftos(p.playerid)); diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index fe4b3e0810..e89b4de32f 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -313,11 +313,11 @@ void PutObserverInServer(entity this, bool is_forced, bool use_spawnpoint) Portal_ClearAll(this); SetSpectatee(this, NULL); - if (this.alivetime) + if (this.alivetime_start) { if (!warmup_stage) - PlayerStats_GameReport_Event_Player(this, PLAYERSTATS_ALIVETIME, time - this.alivetime); - this.alivetime = 0; + PlayerStats_GameReport_Event_Player(this, PLAYERSTATS_ALIVETIME, max(0, time - this.alivetime_start)); + this.alivetime_start = 0; } if (this.vehicle) vehicles_exit(this.vehicle, VHEF_RELEASE); @@ -835,8 +835,8 @@ void PutPlayerInServer(entity this) W_WeaponFrame(this, weaponentity); } - if (!warmup_stage && !this.alivetime) - this.alivetime = time; + if (!warmup_stage && !this.alivetime_start) + this.alivetime_start = max(time, game_starttime); antilag_clear(this, CS(this)); diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index 6cbda43e5e..8e0bbf2642 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -65,7 +65,7 @@ float autocvar_sv_player_scale; .float jointime; // time of connecting .float startplaytime; // time of switching from spectator to player -.float alivetime; // time of being alive +.float alivetime_start; // start time of being alive .float death_time; .bool wasplayer; diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index e9153e5479..6efa4141bd 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -461,7 +461,7 @@ void ReadyRestart_force(bool is_fake_round_start) // clear player attributes FOREACH_CLIENT(IS_PLAYER(it), { - it.alivetime = 0; + it.alivetime_start = 0; CS(it).killcount = 0; }); diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index e2793e92a1..a838259ce1 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -447,10 +447,10 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, { bool defer_ClientKill_Now_TeamChange = false; - if(this.alivetime) + if(this.alivetime_start) { - PlayerStats_GameReport_Event_Player(this, PLAYERSTATS_ALIVETIME, time - this.alivetime); - this.alivetime = 0; + PlayerStats_GameReport_Event_Player(this, PLAYERSTATS_ALIVETIME, max(0, time - this.alivetime_start)); + this.alivetime_start = 0; } if(valid_damage_for_weaponstats) -- 2.39.5