From 2d205506bfd3a2bb253db73b121fd147928811ba Mon Sep 17 00:00:00 2001 From: Shauren Date: Wed, 14 Dec 2022 00:24:24 +0100 Subject: Core/Spells: Fixed spell effect value truncation when value is a large integer --- src/server/game/Entities/Object/Object.cpp | 4 +++- src/server/game/Entities/Object/Object.h | 2 +- src/server/game/Entities/Player/Player.cpp | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/server/game/Entities') diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index cca7c5fe890..e833ae78f2c 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2272,7 +2272,7 @@ float WorldObject::GetSpellMinRangeForTarget(Unit const* target, SpellInfo const return spellInfo->GetMinRange(!IsHostileTo(target)); } -float WorldObject::ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, float value) const +double WorldObject::ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, double value) const { if (Player* modOwner = GetSpellModOwner()) { @@ -2294,6 +2294,8 @@ float WorldObject::ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effInd case EFFECT_4: modOwner->ApplySpellMod(spellInfo, SpellModOp::PointsIndex4, value); break; + default: + break; } } return value; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index f409b13c626..6269bc1b975 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -599,7 +599,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation float GetSpellMaxRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; float GetSpellMinRangeForTarget(Unit const* target, SpellInfo const* spellInfo) const; - float ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, float value) const; + double ApplyEffectModifiers(SpellInfo const* spellInfo, uint8 effIndex, double value) const; int32 CalcSpellDuration(SpellInfo const* spellInfo) const; int32 ModSpellDuration(SpellInfo const* spellInfo, WorldObject const* target, int32 duration, bool positive, uint32 effectMask) const; void ModSpellCastTime(SpellInfo const* spellInfo, int32& castTime, Spell* spell = nullptr) const; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index e2cdadfb468..c49dc685bc0 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -21455,6 +21455,7 @@ void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* template TC_GAME_API void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* spell, int32 base, int32* flat, float* pct) const; template TC_GAME_API void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* spell, uint32 base, int32* flat, float* pct) const; template TC_GAME_API void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* spell, float base, int32* flat, float* pct) const; +template TC_GAME_API void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* spell, double base, int32* flat, float* pct) const; template void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, T& basevalue, Spell* spell /*= nullptr*/) const @@ -21464,12 +21465,13 @@ void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, T& baseval GetSpellModValues(spellInfo, op, spell, basevalue, &totalflat, &totalmul); - basevalue = T(float(basevalue + totalflat) * totalmul); + basevalue = T(double(basevalue + totalflat) * totalmul); } template TC_GAME_API void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, int32& basevalue, Spell* spell) const; template TC_GAME_API void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, uint32& basevalue, Spell* spell) const; template TC_GAME_API void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, float& basevalue, Spell* spell) const; +template TC_GAME_API void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, double& basevalue, Spell* spell) const; void Player::AddSpellMod(SpellModifier* mod, bool apply) { -- cgit v1.2.3