Core/Random: Changed random functions returning doubles to return floats

* They were all cast to float at use anyway
* Improves roll_chance_f performance (rand32() is now called internally by uniform_real_distribution once instead of twice)
This commit is contained in:
Shauren authored and Ovahlord committed 2023-10-31 22:00:52 +01:00
1 parent 56dc3bddd5
commit 7d57ef7299
13 files changed
+26 -26

No files matched your search

+4 -4
View File
@@ -1485,7 +1485,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
float maxDist = m_spellInfo->GetMaxRange(true);
float dist = frand(minDist, maxDist);
float x, y, z;
float angle = float(rand_norm()) * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
float angle = rand_norm() * static_cast<float>(M_PI * 35.0f / 180.0f) - static_cast<float>(M_PI * 17.5f / 180.0f);
m_caster->GetClosePoint(x, y, z, DEFAULT_PLAYER_BOUNDING_RADIUS, dist, angle);
float ground = m_caster->GetMapHeight(x, y, z);
@@ -1573,7 +1573,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
{
case TARGET_DEST_CASTER_RANDOM:
if (dist > objSize)
dist = objSize + (dist - objSize) * float(rand_norm());
dist = objSize + (dist - objSize) * rand_norm();
break;
case TARGET_DEST_CASTER_FRONT_LEFT:
case TARGET_DEST_CASTER_BACK_LEFT:
@@ -1621,7 +1621,7 @@ void Spell::SelectImplicitTargetDestTargets(SpellEffIndex effIndex, SpellImplici
float angle = targetType.CalcDirectionAngle(m_spellInfo->Effects[effIndex]);
float dist = m_spellInfo->Effects[effIndex].CalcRadius(nullptr, targetIndex);
if (targetType.GetTarget() == TARGET_DEST_TARGET_RANDOM)
dist *= float(rand_norm());
dist *= rand_norm();
Position pos = dest._position;
target->MovePositionToFirstCollision(pos, dist, angle);
@@ -1657,7 +1657,7 @@ void Spell::SelectImplicitDestDestTargets(SpellEffIndex effIndex, SpellImplicitT
float angle = targetType.CalcDirectionAngle(m_spellInfo->Effects[effIndex]);
float dist = m_spellInfo->Effects[effIndex].CalcRadius(m_caster, targetIndex);
if (targetType.GetTarget() == TARGET_DEST_DEST_RANDOM)
dist *= float(rand_norm());
dist *= rand_norm();
Position pos = dest._position;
m_caster->MovePositionToFirstCollision(pos, dist, angle);