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

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