From: terencehill Date: Wed, 24 Jul 2024 09:16:13 +0000 (+0200) Subject: Optimize damage logging when there are multiple hits at the same time by accumulating... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=26e3798c390af53b06108f55bd1e1e54869b6ea1;p=xonotic%2Fxonotic-data.pk3dir.git Optimize damage logging when there are multiple hits at the same time by accumulating damage and logging it only once The hash change is due to meaningless differences in the logged total damage dealt by bots. --- diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 81bb63ba4..f1b9b8086 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,7 +36,7 @@ test_compilation_units: test_sv_game: stage: test script: - - export EXPECT=14b3e3e34253d4b41325080e77317d58 + - export EXPECT=d6d7e42bd894e2996fd58df286d0886b - qcsrc/tools/sv_game-hashtest.sh - exit $? diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index c97f09c77..19a964361 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2693,6 +2693,18 @@ frametime is always set here. void PlayerFrame (entity this) { // formerly PreThink code + + if (this.score_frame_dmg) + { + GameRules_scoring_add(this, DMG, this.score_frame_dmg); + this.score_frame_dmg = 0; + } + if (this.score_frame_dmgtaken) + { + GameRules_scoring_add(this, DMGTAKEN, this.score_frame_dmgtaken); + this.score_frame_dmgtaken = 0; + } + STAT(GUNALIGN, this) = CS_CVAR(this).cvar_cl_gunalign; // TODO STAT(MOVEVARS_CL_TRACK_CANJUMP, this) = CS_CVAR(this).cvar_cl_movement_track_canjump; diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index f251d55b0..da2c48ded 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -431,10 +431,11 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, if ((this != attacker || deathtype == DEATH_KILL.m_id) && realdmg && !STAT(FROZEN, this) && (!(round_handler_IsActive() && !round_handler_IsRoundStarted()) && time >= game_starttime)) { + // accumulate damage, it will be logged later in this frame if (IS_PLAYER(attacker) && DIFF_TEAM(attacker, this) && deathtype != DEATH_KILL.m_id) - GameRules_scoring_add(attacker, DMG, realdmg); + attacker.score_frame_dmg += realdmg; if (IS_PLAYER(this)) - GameRules_scoring_add(this, DMGTAKEN, realdmg); + this.score_frame_dmgtaken += realdmg; } } diff --git a/qcsrc/server/player.qh b/qcsrc/server/player.qh index c22ea8646..34c8fdbdf 100644 --- a/qcsrc/server/player.qh +++ b/qcsrc/server/player.qh @@ -24,6 +24,9 @@ float autocvar_sv_gibhealth; .float death_time; +.float score_frame_dmg; +.float score_frame_dmgtaken; + .float CopyBody_nextthink; .void(entity this) CopyBody_think; void CopyBody_Think(entity this);