chore(Core/Misc): update floor and ceil to std (#19837)

This commit is contained in:
Kitzunu
2024-09-03 13:01:00 +02:00
committed by GitHub
parent de2bcbdabf
commit 9af86553c5
10 changed files with 28 additions and 20 deletions

View File

@@ -21,6 +21,7 @@
#include "Log.h"
#include "ObjectMgr.h"
#include "Util.h"
#include <cmath>
#include <functional>
#include <vector>
@@ -105,7 +106,7 @@ uint32 GetItemEnchantMod(int32 entry)
}
//we could get here only if sum of all enchantment chances is lower than 100%
dRoll = (irand(0, (int)floor(fCount * 100) + 1)) / 100;
dRoll = (irand(0, (int)std::floor(fCount * 100) + 1)) / 100;
fCount = 0;
for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)

View File

@@ -83,6 +83,7 @@
#include "World.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include <cmath>
/// @todo: this import is not necessary for compilation and marked as unused by the IDE
// however, for some reasons removing it would cause a damn linking issue
@@ -10804,7 +10805,7 @@ bool Player::BuyItemFromVendorSlot(ObjectGuid vendorguid, uint32 vendorslot, uin
price = pProto->BuyPrice * count; //it should not exceed MAX_MONEY_AMOUNT
// reputation discount
price = uint32(floor(price * GetReputationPriceDiscount(creature)));
price = uint32(std::floor(price * GetReputationPriceDiscount(creature)));
if (!HasEnoughMoney(price))
{

View File

@@ -69,7 +69,7 @@
#include "Vehicle.h"
#include "World.h"
#include "WorldPacket.h"
#include <math.h>
#include <cmath>
float baseMoveSpeed[MAX_MOVE_TYPE] =
{
@@ -2013,14 +2013,14 @@ uint32 Unit::CalcArmorReducedDamage(Unit const* attacker, Unit const* victim, co
{
if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL
&& (*j)->IsAffectedOnSpell(spellInfo))
armor = floor(AddPct(armor, -(*j)->GetAmount()));
armor = std::floor(AddPct(armor, -(*j)->GetAmount()));
}
AuraEffectList const& ResIgnoreAuras = attacker->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j)
{
if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
armor = floor(AddPct(armor, -(*j)->GetAmount()));
armor = std::floor(AddPct(armor, -(*j)->GetAmount()));
}
// Apply Player CR_ARMOR_PENETRATION rating and buffs from stances\specializations etc.
@@ -10980,7 +10980,7 @@ Unit* Unit::GetMagicHitRedirectTarget(Unit* victim, SpellInfo const* spellInfo)
float dist = GetDistance(magnet->GetPositionX(), magnet->GetPositionY(), magnet->GetPositionZ());
if (dist < 5.0f)
dist = 5.0f;
queueTime = magnet->m_Events.CalculateTime((uint64)floor(dist / spellInfo->Speed * 1000.0f));
queueTime = magnet->m_Events.CalculateTime((uint64)std::floor(dist / spellInfo->Speed * 1000.0f));
}
magnet->m_Events.AddEvent(new KillMagnetEvent(*magnet), queueTime);
@@ -13397,7 +13397,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spe
if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_PROC_PER_MINUTE, PPM);
return floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
return std::floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
}
void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)

View File

@@ -28,6 +28,7 @@
#include "UpdateData.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include <cmath>
void WorldSession::HandleSplitItemOpcode(WorldPacket& recvData)
{
@@ -1111,7 +1112,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry)
}
// reputation discount
int32 price = item->IsGoldRequired(itemTemplate) ? uint32(floor(itemTemplate->BuyPrice * discountMod)) : 0;
int32 price = item->IsGoldRequired(itemTemplate) ? uint32(std::floor(itemTemplate->BuyPrice * discountMod)) : 0;
data << uint32(slot + 1); // client expects counting to start at 1
data << uint32(item->item);

View File

@@ -32,6 +32,7 @@
#include "UpdateMask.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include <cmath>
enum StableResultCode
{
@@ -164,7 +165,7 @@ void WorldSession::SendTrainerList(ObjectGuid guid, const std::string& strTitle)
data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case)
data << uint8(state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state);
data << uint32(floor(tSpell->spellCost * fDiscountMod));
data << uint32(std::floor(tSpell->spellCost * fDiscountMod));
data << uint32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0);
// primary prof. learn confirmation dialog
@@ -247,7 +248,7 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvData)
return;
// apply reputation discount
uint32 nSpellCost = uint32(floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
uint32 nSpellCost = uint32(std::floor(trainer_spell->spellCost * _player->GetReputationPriceDiscount(unit)));
// check money requirement
if (!_player->HasEnoughMoney(nSpellCost))

View File

@@ -55,6 +55,7 @@
#include "Vehicle.h"
#include "World.h"
#include "WorldPacket.h"
#include <cmath>
/// @todo: this import is not necessary for compilation and marked as unused by the IDE
// however, for some reasons removing it would cause a damn linking issue
@@ -900,7 +901,7 @@ uint64 Spell::CalculateDelayMomentForDst() const
{
float speed = m_targets.GetSpeedXY();
if (speed > 0.0f)
return (uint64)floor(m_targets.GetDist2d() / speed * 1000.0f);
return (uint64)std::floor(m_targets.GetDist2d() / speed * 1000.0f);
}
else if (m_spellInfo->Speed > 0.0f)
{
@@ -1441,7 +1442,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
bool inwater = false;
bool wcol = false;
const float step = 2.0f;
const uint8 numChecks = ceil(fabs(distance / step));
const uint8 numChecks = std::ceil(std::fabs(distance / step));
const float DELTA_X = (destx - pos.GetPositionX()) / numChecks;
const float DELTA_Y = (desty - pos.GetPositionY()) / numChecks;
int j = 1;
@@ -2462,7 +2463,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
if (dist < 5.0f)
dist = 5.0f;
targetInfo.timeDelay = (uint64) floor(dist / m_spellInfo->Speed * 1000.0f);
targetInfo.timeDelay = (uint64) std::floor(dist / m_spellInfo->Speed * 1000.0f);
// Calculate minimum incoming time
if (m_delayMoment == 0 || m_delayMoment > targetInfo.timeDelay)
@@ -2561,7 +2562,7 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask)
float dist = m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ());
if (dist < 5.0f)
dist = 5.0f;
target.timeDelay = uint64(floor(dist / m_spellInfo->Speed * 1000.0f));
target.timeDelay = uint64(std::floor(dist / m_spellInfo->Speed * 1000.0f));
if (m_delayMoment == 0 || m_delayMoment > target.timeDelay)
m_delayMoment = target.timeDelay;
}

View File

@@ -20,6 +20,7 @@
#include "Log.h"
#include "Timer.h"
#include <algorithm>
#include <cmath>
#include <iterator>
// create instance
@@ -87,12 +88,12 @@ uint32 UpdateTime::GetPercentile(uint8 p)
double index = (double(p) / 100.0) * (GetDatasetSize() - 1);
// If the index is an integer, return the value at that index
if (index == floor(index))
if (index == std::floor(index))
return _orderedUpdateTimeDataTable[index];
// Otherwise, perform linear interpolation
int lowerIndex = floor(index);
int upperIndex = ceil(index);
int lowerIndex = std::floor(index);
int upperIndex = std::ceil(index);
double fraction = index - lowerIndex;
return _orderedUpdateTimeDataTable[lowerIndex] * (1 - fraction) + _orderedUpdateTimeDataTable[upperIndex] * fraction;

View File

@@ -234,7 +234,7 @@ public:
me->SetInFront(me->GetVictim());
}
/*if (float dist = me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f) dist = 5.0f;
SDisruptAOEVisual_Timer = 1000 + floor(dist / 30 * 1000.0f);*/
SDisruptAOEVisual_Timer = 1000 + std::floor(dist / 30 * 1000.0f);*/
events.ScheduleEvent(EVENT_STATIC_DISRUPTION, urand(10000, 18000));
break;
}

View File

@@ -34,6 +34,7 @@
#include "SpellScriptLoader.h"
#include "Vehicle.h"
#include "World.h"
#include <cmath>
enum eWGqueuenpctext
{
@@ -1089,7 +1090,7 @@ class spell_wg_reduce_damage_by_distance : public SpellScript
float maxDistance = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster()); // Xinef: always stored in EFFECT_0
float distance = std::min<float>(GetHitUnit()->GetDistance(*GetExplTargetDest()), maxDistance);
int32 damage = std::max<int32>(0, int32(GetHitDamage() - floor(GetHitDamage() * (distance / maxDistance))));
int32 damage = std::max<int32>(0, int32(GetHitDamage() - std::floor(GetHitDamage() * (distance / maxDistance))));
SetHitDamage(damage);
}

View File

@@ -35,6 +35,7 @@
#include "Unit.h"
#include "Vehicle.h"
#include <array>
#include <cmath>
/*
* Scripts for spells with SPELLFAMILY_GENERIC which cannot be included in AI script file
* of creature using it or can't be bound to any player class.
@@ -4255,7 +4256,7 @@ class spell_gen_gift_of_naaru : public AuraScript
break;
}
int32 healTick = floor(heal / aurEff->GetTotalTicks());
int32 healTick = std::floor(heal / aurEff->GetTotalTicks());
amount += int32(std::max(healTick, 0));
}