]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a return value to the PlayerDamaged mutator hook to forbid logging damage 911/head
authorterencehill <piuntn@gmail.com>
Sun, 30 May 2021 09:01:51 +0000 (11:01 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 30 May 2021 09:01:51 +0000 (11:01 +0200)
qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc
qcsrc/common/gamemodes/gamemode/race/sv_race.qc
qcsrc/server/mutators/events.qh
qcsrc/server/player.qc

index 00066180ffebad2ab8c4e26f6b4e809933e9c4c0..45457d1a4d8adb895ea40b39e4ad89b458d2b495 100644 (file)
@@ -239,7 +239,7 @@ MUTATOR_HOOKFUNCTION(cts, PlayerDamaged)
 {
        int frag_deathtype = M_ARGV(5, int);
        if (frag_deathtype == DEATH_KILL.m_id)
-               M_ARGV(0, bool) = true; // forbid_damage_logging
+               return true; // forbid logging damage
 }
 
 MUTATOR_HOOKFUNCTION(cts, PlayerDies)
index 2709a3cc9311e5f604c8055ca8fe8963919993f6..0ffda17a96407171e9e1cbada4d045894a80ba3b 100644 (file)
@@ -289,7 +289,7 @@ MUTATOR_HOOKFUNCTION(rc, PlayerDamaged)
 {
        int frag_deathtype = M_ARGV(5, int);
        if (frag_deathtype == DEATH_KILL.m_id)
-               M_ARGV(0, bool) = true; // forbid_damage_logging
+               return true; // forbid logging damage
 }
 
 MUTATOR_HOOKFUNCTION(rc, PlayerDies)
index ea42b5da0b7352af582635a71fbbe43c219bc990..c4521e824f3a7a9d57ce58df35494fcf3dbb8fa2 100644 (file)
@@ -449,6 +449,7 @@ MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate);
 
 /**
  * Called when a player is damaged
+ * Returns true if damage shouldn't be logged
  */
 #define EV_PlayerDamaged(i, o) \
     /** attacker  */ i(entity, MUTATOR_ARGV_0_entity) \
@@ -458,7 +459,6 @@ MUTATOR_HOOKABLE(Damage_Calculate, EV_Damage_Calculate);
     /** location  */ i(vector, MUTATOR_ARGV_4_vector) \
     /** deathtype */ i(int,    MUTATOR_ARGV_5_int) \
     /** potential_damage     */ i(float,    MUTATOR_ARGV_6_float) \
-    /** forbid_damage_logging */ o(bool, MUTATOR_ARGV_0_bool) \
     /**/
 MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged);
 
index aedbbae46a69168923d851f64eaf5dd73443a5ba..1d83be8d1b74288a2e2e6b2ee201262d617484c6 100644 (file)
@@ -421,11 +421,9 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage,
                WeaponStats_LogDamage(awep.m_id, abot, this.(weaponentity).m_weapon.m_id, vbot, dh + da);
        }
 
-       bool forbid_damage_logging = false;
-       MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype, damage);
-       forbid_damage_logging = M_ARGV(0, bool);
+       bool forbid_logging_damage = MUTATOR_CALLHOOK(PlayerDamaged, attacker, this, dh, da, hitloc, deathtype, damage);
 
-       if ((dh || da) && !forbid_damage_logging)
+       if ((dh || da) && !forbid_logging_damage)
        {
                float realdmg = damage - excess;
                if ((this != attacker || deathtype == DEATH_KILL.m_id) && realdmg && !STAT(FROZEN, this)