From: terencehill Date: Sun, 30 May 2021 09:01:51 +0000 (+0200) Subject: Add a return value to the PlayerDamaged mutator hook to forbid logging damage X-Git-Tag: xonotic-v0.8.5~405^2~22^2 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=c54fc38822d3642085daf5300dedfbb7b15e7e02;p=xonotic%2Fxonotic-data.pk3dir.git Add a return value to the PlayerDamaged mutator hook to forbid logging damage --- diff --git a/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc index 00066180f..45457d1a4 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc +++ b/qcsrc/common/gamemodes/gamemode/cts/sv_cts.qc @@ -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) diff --git a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc index 2709a3cc9..0ffda17a9 100644 --- a/qcsrc/common/gamemodes/gamemode/race/sv_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/sv_race.qc @@ -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) diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index ea42b5da0..c4521e824 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -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); diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index aedbbae46..1d83be8d1 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -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)