]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize damage logging when there are multiple hits at the same time by accumulating...
authorterencehill <piuntn@gmail.com>
Wed, 24 Jul 2024 09:16:13 +0000 (11:16 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 24 Jul 2024 09:22:46 +0000 (11:22 +0200)
The hash change is due to meaningless differences in the logged total damage dealt by bots.

.gitlab-ci.yml
qcsrc/server/client.qc
qcsrc/server/player.qc
qcsrc/server/player.qh

index 81bb63ba4e28e5bf3c5c9c9faa8e72c9f76c70fe..f1b9b80860d96931cd02560ed707e63ea75882ac 100644 (file)
@@ -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 $?
 
index c97f09c777424fb198c2c6b4b0501de71e50d672..19a9643616cc0ff5cc3438222be5779e90820d2a 100644 (file)
@@ -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;
 
index f251d55b0be16be0d40d1043db9dbb7c5b9ac52b..da2c48ded9b295bf640f309d0dfe9b6c87f7369e 100644 (file)
@@ -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;
                }
        }
 
index c22ea86463e3b10d46d6727fd83dd53e29d58a9b..34c8fdbdfbd6fa79bd03731780f3284678646cd1 100644 (file)
@@ -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);