chore(Core/Misc): update floor and ceil to std (#19837)
This commit is contained in:
@@ -21,6 +21,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "ObjectMgr.h"
|
#include "ObjectMgr.h"
|
||||||
#include "Util.h"
|
#include "Util.h"
|
||||||
|
#include <cmath>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <vector>
|
#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%
|
//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;
|
fCount = 0;
|
||||||
|
|
||||||
for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
|
for (EnchStoreList::const_iterator ench_iter = tab->second.begin(); ench_iter != tab->second.end(); ++ench_iter)
|
||||||
|
|||||||
@@ -83,6 +83,7 @@
|
|||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
/// @todo: this import is not necessary for compilation and marked as unused by the IDE
|
/// @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
|
// 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
|
price = pProto->BuyPrice * count; //it should not exceed MAX_MONEY_AMOUNT
|
||||||
|
|
||||||
// reputation discount
|
// reputation discount
|
||||||
price = uint32(floor(price * GetReputationPriceDiscount(creature)));
|
price = uint32(std::floor(price * GetReputationPriceDiscount(creature)));
|
||||||
|
|
||||||
if (!HasEnoughMoney(price))
|
if (!HasEnoughMoney(price))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include <math.h>
|
#include <cmath>
|
||||||
|
|
||||||
float baseMoveSpeed[MAX_MOVE_TYPE] =
|
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
|
if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL
|
||||||
&& (*j)->IsAffectedOnSpell(spellInfo))
|
&& (*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);
|
AuraEffectList const& ResIgnoreAuras = attacker->GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST);
|
||||||
for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j)
|
for (AuraEffectList::const_iterator j = ResIgnoreAuras.begin(); j != ResIgnoreAuras.end(); ++j)
|
||||||
{
|
{
|
||||||
if ((*j)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
|
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.
|
// 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());
|
float dist = GetDistance(magnet->GetPositionX(), magnet->GetPositionY(), magnet->GetPositionZ());
|
||||||
if (dist < 5.0f)
|
if (dist < 5.0f)
|
||||||
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);
|
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())
|
if (Player* modOwner = GetSpellModOwner())
|
||||||
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_PROC_PER_MINUTE, PPM);
|
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)
|
void Unit::Mount(uint32 mount, uint32 VehicleId, uint32 creatureEntry)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
#include "UpdateData.h"
|
#include "UpdateData.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
void WorldSession::HandleSplitItemOpcode(WorldPacket& recvData)
|
void WorldSession::HandleSplitItemOpcode(WorldPacket& recvData)
|
||||||
{
|
{
|
||||||
@@ -1111,7 +1112,7 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// reputation discount
|
// 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(slot + 1); // client expects counting to start at 1
|
||||||
data << uint32(item->item);
|
data << uint32(item->item);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@
|
|||||||
#include "UpdateMask.h"
|
#include "UpdateMask.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
#include "WorldSession.h"
|
#include "WorldSession.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
enum StableResultCode
|
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 << uint32(tSpell->spell); // learned spell (or cast-spell in profession case)
|
||||||
data << uint8(state == TRAINER_SPELL_GREEN_DISABLED ? TRAINER_SPELL_GREEN : state);
|
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);
|
data << uint32(primary_prof_first_rank && can_learn_primary_prof ? 1 : 0);
|
||||||
// primary prof. learn confirmation dialog
|
// primary prof. learn confirmation dialog
|
||||||
@@ -247,7 +248,7 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvData)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// apply reputation discount
|
// 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
|
// check money requirement
|
||||||
if (!_player->HasEnoughMoney(nSpellCost))
|
if (!_player->HasEnoughMoney(nSpellCost))
|
||||||
|
|||||||
@@ -55,6 +55,7 @@
|
|||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "WorldPacket.h"
|
#include "WorldPacket.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
/// @todo: this import is not necessary for compilation and marked as unused by the IDE
|
/// @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
|
// 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();
|
float speed = m_targets.GetSpeedXY();
|
||||||
if (speed > 0.0f)
|
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)
|
else if (m_spellInfo->Speed > 0.0f)
|
||||||
{
|
{
|
||||||
@@ -1441,7 +1442,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
|
|||||||
bool inwater = false;
|
bool inwater = false;
|
||||||
bool wcol = false;
|
bool wcol = false;
|
||||||
const float step = 2.0f;
|
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_X = (destx - pos.GetPositionX()) / numChecks;
|
||||||
const float DELTA_Y = (desty - pos.GetPositionY()) / numChecks;
|
const float DELTA_Y = (desty - pos.GetPositionY()) / numChecks;
|
||||||
int j = 1;
|
int j = 1;
|
||||||
@@ -2462,7 +2463,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
|
|||||||
|
|
||||||
if (dist < 5.0f)
|
if (dist < 5.0f)
|
||||||
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
|
// Calculate minimum incoming time
|
||||||
if (m_delayMoment == 0 || m_delayMoment > targetInfo.timeDelay)
|
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());
|
float dist = m_caster->GetDistance(go->GetPositionX(), go->GetPositionY(), go->GetPositionZ());
|
||||||
if (dist < 5.0f)
|
if (dist < 5.0f)
|
||||||
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)
|
if (m_delayMoment == 0 || m_delayMoment > target.timeDelay)
|
||||||
m_delayMoment = target.timeDelay;
|
m_delayMoment = target.timeDelay;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "Log.h"
|
#include "Log.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <cmath>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
// create instance
|
// create instance
|
||||||
@@ -87,12 +88,12 @@ uint32 UpdateTime::GetPercentile(uint8 p)
|
|||||||
double index = (double(p) / 100.0) * (GetDatasetSize() - 1);
|
double index = (double(p) / 100.0) * (GetDatasetSize() - 1);
|
||||||
|
|
||||||
// If the index is an integer, return the value at that index
|
// If the index is an integer, return the value at that index
|
||||||
if (index == floor(index))
|
if (index == std::floor(index))
|
||||||
return _orderedUpdateTimeDataTable[index];
|
return _orderedUpdateTimeDataTable[index];
|
||||||
|
|
||||||
// Otherwise, perform linear interpolation
|
// Otherwise, perform linear interpolation
|
||||||
int lowerIndex = floor(index);
|
int lowerIndex = std::floor(index);
|
||||||
int upperIndex = ceil(index);
|
int upperIndex = std::ceil(index);
|
||||||
double fraction = index - lowerIndex;
|
double fraction = index - lowerIndex;
|
||||||
|
|
||||||
return _orderedUpdateTimeDataTable[lowerIndex] * (1 - fraction) + _orderedUpdateTimeDataTable[upperIndex] * fraction;
|
return _orderedUpdateTimeDataTable[lowerIndex] * (1 - fraction) + _orderedUpdateTimeDataTable[upperIndex] * fraction;
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ public:
|
|||||||
me->SetInFront(me->GetVictim());
|
me->SetInFront(me->GetVictim());
|
||||||
}
|
}
|
||||||
/*if (float dist = me->IsWithinDist3d(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 5.0f) dist = 5.0f;
|
/*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));
|
events.ScheduleEvent(EVENT_STATIC_DISRUPTION, urand(10000, 18000));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
#include "SpellScriptLoader.h"
|
#include "SpellScriptLoader.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
enum eWGqueuenpctext
|
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 maxDistance = GetSpellInfo()->Effects[EFFECT_0].CalcRadius(GetCaster()); // Xinef: always stored in EFFECT_0
|
||||||
float distance = std::min<float>(GetHitUnit()->GetDistance(*GetExplTargetDest()), maxDistance);
|
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);
|
SetHitDamage(damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include "Unit.h"
|
#include "Unit.h"
|
||||||
#include "Vehicle.h"
|
#include "Vehicle.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
#include <cmath>
|
||||||
/*
|
/*
|
||||||
* Scripts for spells with SPELLFAMILY_GENERIC which cannot be included in AI script file
|
* 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.
|
* 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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 healTick = floor(heal / aurEff->GetTotalTicks());
|
int32 healTick = std::floor(heal / aurEff->GetTotalTicks());
|
||||||
amount += int32(std::max(healTick, 0));
|
amount += int32(std::max(healTick, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user