Core/Spells: Fixed spell effect value truncation when value is a large integer

This commit is contained in:
Shauren
2022-12-14 00:24:24 +01:00
parent e98e1283ea
commit 2d205506bf
4 changed files with 12 additions and 8 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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 <class T>
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)
{

View File

@@ -479,11 +479,11 @@ bool SpellEffectInfo::IsUnitOwnedAuraEffect() const
int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32 const* bp /*= nullptr*/, Unit const* target /*= nullptr*/, float* variance /*= nullptr*/, uint32 castItemId /*= 0*/, int32 itemLevel /*= -1*/) const
{
float basePointsPerLevel = RealPointsPerLevel;
double basePointsPerLevel = RealPointsPerLevel;
// TODO: this needs to be a float, not rounded
int32 basePoints = CalcBaseValue(caster, target, castItemId, itemLevel);
float value = bp ? *bp : basePoints;
float comboDamage = PointsPerResource;
double value = bp ? *bp : basePoints;
double comboDamage = PointsPerResource;
Unit const* casterUnit = nullptr;
if (caster)
@@ -492,8 +492,8 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
if (Scaling.Variance)
{
float delta = fabs(Scaling.Variance * 0.5f);
float valueVariance = frand(-delta, delta);
value += basePoints * valueVariance;
double valueVariance = frand(-delta, delta);
value += double(basePoints) * valueVariance;
if (variance)
*variance = valueVariance;