aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOvah <dreadkiller@gmx.de>2020-12-27 00:05:37 +0100
committerGitHub <noreply@github.com>2020-12-27 00:05:37 +0100
commit527db2170bd5c7bbef7a769d9a00b55a124ad903 (patch)
tree0b5deae00c8a062d95100e05c6a268e637e4eebd /src
parentb7ba856b63da4fa1b0f916de357ff85624b8b831 (diff)
Core/Units: do not send power update packets when gaining power via energize spell effects to match retail behavior (#25599)
This fixes possible clientside visual issues where power is being added twice until the next update_object packet is being sent
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp28
-rw-r--r--src/server/game/Entities/Unit/Unit.h4
2 files changed, 17 insertions, 15 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index cced18421de..4c662d35a2b 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -6400,10 +6400,9 @@ void Unit::EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers po
void Unit::EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, Powers powerType)
{
- SendEnergizeSpellLog(victim, spellInfo->Id, damage, powerType);
- // needs to be called after sending spell log
- victim->ModifyPower(powerType, damage);
+ victim->ModifyPower(powerType, damage, false);
victim->GetThreatManager().ForwardThreatForAssistingMe(this, float(damage)/2, spellInfo, true);
+ SendEnergizeSpellLog(victim, spellInfo->Id, damage, powerType);
}
uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint8 effIndex, Optional<float> const& donePctTotal, uint32 stack /*= 1*/) const
@@ -8347,7 +8346,7 @@ int32 Unit::GetHealthGain(int32 dVal)
}
// returns negative amount on power reduction
-int32 Unit::ModifyPower(Powers power, int32 dVal)
+int32 Unit::ModifyPower(Powers power, int32 dVal, bool withPowerUpdate /*= true*/)
{
int32 gain = 0;
@@ -8359,7 +8358,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
int32 val = dVal + curPower;
if (val <= 0)
{
- SetPower(power, 0);
+ SetPower(power, 0, withPowerUpdate);
return -curPower;
}
@@ -8367,12 +8366,12 @@ int32 Unit::ModifyPower(Powers power, int32 dVal)
if (val < maxPower)
{
- SetPower(power, val);
+ SetPower(power, val, withPowerUpdate);
gain = val - curPower;
}
else if (curPower != maxPower)
{
- SetPower(power, maxPower);
+ SetPower(power, maxPower, withPowerUpdate);
gain = maxPower - curPower;
}
@@ -9363,7 +9362,7 @@ void Unit::SetMaxHealth(uint32 val)
SetHealth(val);
}
-void Unit::SetPower(Powers power, uint32 val)
+void Unit::SetPower(Powers power, uint32 val, bool withPowerUpdate /*= true*/)
{
if (GetPower(power) == val)
return;
@@ -9374,11 +9373,14 @@ void Unit::SetPower(Powers power, uint32 val)
SetStatInt32Value(UNIT_FIELD_POWER1 + power, val);
- WorldPacket data(SMSG_POWER_UPDATE);
- data << GetPackGUID();
- data << uint8(power);
- data << uint32(val);
- SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER);
+ if (withPowerUpdate)
+ {
+ WorldPacket data(SMSG_POWER_UPDATE, 8 + 1 + 4);
+ data << GetPackGUID();
+ data << uint8(power);
+ data << uint32(val);
+ SendMessageToSet(&data, GetTypeId() == TYPEID_PLAYER);
+ }
// group update
if (Player* player = ToPlayer())
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 854b40e4ff0..dae93115775 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -888,11 +888,11 @@ class TC_GAME_API Unit : public WorldObject
void UpdateDisplayPower();
uint32 GetPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_POWER1 +power); }
uint32 GetMaxPower(Powers power) const { return GetUInt32Value(UNIT_FIELD_MAXPOWER1+power); }
- void SetPower(Powers power, uint32 val);
+ void SetPower(Powers power, uint32 val, bool withPowerUpdate = true);
void SetMaxPower(Powers power, uint32 val);
inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); }
// returns the change in power
- int32 ModifyPower(Powers power, int32 val);
+ int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true);
uint32 GetAttackTime(WeaponAttackType att) const;
void SetAttackTime(WeaponAttackType att, uint32 val) { SetFloatValue(UNIT_FIELD_BASEATTACKTIME+att, val*m_modAttackSpeedPct[att]); }