From be3b95bfd7c263177a31d1015f7cf7d02e54c52f Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 10 Dec 2021 16:39:28 +0100 Subject: [PATCH] Reset weapon accuracy on readyrestart --- qcsrc/server/command/vote.qc | 5 ++++- qcsrc/server/weapons/accuracy.qc | 15 +++++++++++++++ qcsrc/server/weapons/accuracy.qh | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index ffc81c468..71fb0902b 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -441,7 +441,10 @@ void ReadyRestart_force() game_starttime = time + RESTART_COUNTDOWN; // clear player attributes - FOREACH_CLIENT(IS_PLAYER(it), { + FOREACH_CLIENT(true, { + accuracy_reset(it); + if (!IS_PLAYER(it)) + continue; it.alivetime = 0; CS(it).killcount = 0; float val = PlayerStats_GameReport_Event_Player(it, PLAYERSTATS_ALIVETIME, 0); diff --git a/qcsrc/server/weapons/accuracy.qc b/qcsrc/server/weapons/accuracy.qc index 2fe010f64..337ae54a9 100644 --- a/qcsrc/server/weapons/accuracy.qc +++ b/qcsrc/server/weapons/accuracy.qc @@ -55,6 +55,21 @@ void accuracy_free(entity e) delete(CS(e).accuracy); } +void accuracy_reset(entity e) +{ + entity a = CS(e).accuracy; + if (!a) return; + + for (int i = 0; i < REGISTRY_MAX(Weapons); i++) + { + a.accuracy_frags[i] = 0; + a.accuracy_hit[i] = 0; + a.accuracy_fired[i] = 0; + a.accuracy_cnt_hit[i] = 0; + a.accuracy_cnt_fired[i] = 0; + } +} + // force a resend of a player's accuracy stats void accuracy_resend(entity e) { diff --git a/qcsrc/server/weapons/accuracy.qh b/qcsrc/server/weapons/accuracy.qh index fcdf7c481..81d2b1763 100644 --- a/qcsrc/server/weapons/accuracy.qh +++ b/qcsrc/server/weapons/accuracy.qh @@ -38,6 +38,8 @@ REPLICATE(cvar_cl_accuracy_data_receive, bool, "cl_accuracy_data_receive"); void accuracy_init(entity e); void accuracy_free(entity e); +void accuracy_reset(entity e); + // force a resend of a player's accuracy stats void accuracy_resend(entity e); -- 2.39.2