mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
refactor(Core/Misc): ceil() to std::ceil() (#9791)
- prefer std functions over C functions
This commit is contained in:
@@ -891,7 +891,7 @@ bool BfCapturePoint::HandlePlayerEnter(Player* player)
|
||||
if (GameObject* go = GetCapturePointGo(player))
|
||||
{
|
||||
player->SendUpdateWorldState(go->GetGOInfo()->capturePoint.worldState1, 1);
|
||||
player->SendUpdateWorldState(go->GetGOInfo()->capturePoint.worldstate2, uint32(ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)));
|
||||
player->SendUpdateWorldState(go->GetGOInfo()->capturePoint.worldstate2, uint32(std::ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)));
|
||||
player->SendUpdateWorldState(go->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
|
||||
}
|
||||
return m_activePlayers[player->GetTeamId()].insert(player->GetGUID()).second;
|
||||
@@ -924,7 +924,7 @@ void BfCapturePoint::SendChangePhase()
|
||||
// send this too, sometimes the slider disappears, dunno why :(
|
||||
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldState1, 1);
|
||||
// send these updates to only the ones in this objective
|
||||
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32) ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
|
||||
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate2, (uint32) std::ceil((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f));
|
||||
// send this too, sometimes it resets :S
|
||||
player->SendUpdateWorldState(capturePoint->GetGOInfo()->capturePoint.worldstate3, m_neutralValuePct);
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ struct CreatureBaseStats
|
||||
|
||||
uint32 GenerateHealth(CreatureTemplate const* info) const
|
||||
{
|
||||
return uint32(ceil(BaseHealth[info->expansion] * info->ModHealth));
|
||||
return uint32(std::ceil(BaseHealth[info->expansion] * info->ModHealth));
|
||||
}
|
||||
|
||||
uint32 GenerateMana(CreatureTemplate const* info) const
|
||||
@@ -223,12 +223,12 @@ struct CreatureBaseStats
|
||||
if (!BaseMana)
|
||||
return 0;
|
||||
|
||||
return uint32(ceil(BaseMana * info->ModMana));
|
||||
return uint32(std::ceil(BaseMana * info->ModMana));
|
||||
}
|
||||
|
||||
uint32 GenerateArmor(CreatureTemplate const* info) const
|
||||
{
|
||||
return uint32(ceil(BaseArmor * info->ModArmor));
|
||||
return uint32(std::ceil(BaseArmor * info->ModArmor));
|
||||
}
|
||||
|
||||
float GenerateBaseDamage(CreatureTemplate const* info) const
|
||||
|
||||
@@ -5926,7 +5926,7 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
|
||||
else
|
||||
victim_guid.Clear(); // Don't show HK: <rank> message, only log.
|
||||
|
||||
honor_f = ceil(Acore::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey));
|
||||
honor_f = std::ceil(Acore::Honor::hk_honor_at_level_f(k_level) * (v_level - k_grey) / (k_level - k_grey));
|
||||
|
||||
// count the number of playerkills in one day
|
||||
ApplyModUInt32Value(PLAYER_FIELD_KILLS, 1, true);
|
||||
@@ -12129,7 +12129,7 @@ uint32 Player::GetCorpseReclaimDelay(bool pvp) const
|
||||
|
||||
time_t now = time(nullptr);
|
||||
// 0..2 full period
|
||||
// should be ceil(x)-1 but not floor(x)
|
||||
// should be std::ceil(x)-1 but not floor(x)
|
||||
uint64 count = (now < m_deathExpireTime - 1) ? (m_deathExpireTime - 1 - now) / DEATH_EXPIRE_STEP : 0;
|
||||
return copseReclaimDelay[count];
|
||||
}
|
||||
|
||||
@@ -9311,7 +9311,7 @@ bool Unit::HandleProcTriggerSpell(Unit* victim, uint32 damage, AuraEffect* trigg
|
||||
|
||||
uint8 fofRank = sSpellMgr->GetSpellRank(triggeredByAura->GetId());
|
||||
uint8 fbRank = sSpellMgr->GetSpellRank(aurEff->GetId());
|
||||
uint8 chance = uint8(ceil(fofRank * fbRank * 16.6f));
|
||||
uint8 chance = uint8(std::ceil(fofRank * fbRank * 16.6f));
|
||||
|
||||
if (roll_chance_i(chance))
|
||||
CastSpell(victim, aurEff->GetSpellInfo()->Effects[EFFECT_0].TriggerSpell, true);
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Acore::Honor
|
||||
|
||||
inline uint32 hk_honor_at_level(uint8 level, float multiplier = 1.0f)
|
||||
{
|
||||
return uint32(ceil(hk_honor_at_level_f(level, multiplier)));
|
||||
return uint32(std::ceil(hk_honor_at_level_f(level, multiplier)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4316,7 +4316,7 @@ void AuraEffect::HandleAuraModIncreaseMaxHealth(AuraApplication const* aurApp, u
|
||||
// refresh percentage
|
||||
if (oldhealth > 0)
|
||||
{
|
||||
uint32 newhealth = uint32(ceil((double)target->GetMaxHealth() * healthPercentage));
|
||||
uint32 newhealth = uint32(std::ceil((double)target->GetMaxHealth() * healthPercentage));
|
||||
if (newhealth == 0)
|
||||
newhealth = 1;
|
||||
|
||||
@@ -6328,7 +6328,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
|
||||
}
|
||||
}
|
||||
else // xinef: ceil obtained value, it may happen that 10 ticks for 10% damage may not kill owner
|
||||
damage = uint32(ceil(CalculatePct<float, float>(target->GetMaxHealth(), damage)));
|
||||
damage = uint32(std::ceil(CalculatePct<float, float>(target->GetMaxHealth(), damage)));
|
||||
|
||||
// calculate crit chance
|
||||
bool crit = false;
|
||||
|
||||
@@ -3410,7 +3410,7 @@ uint32 World::GetNextWhoListUpdateDelaySecs()
|
||||
uint32 t = m_timers[WUPDATE_5_SECS].GetInterval() - m_timers[WUPDATE_5_SECS].GetCurrent();
|
||||
t = std::min(t, (uint32)m_timers[WUPDATE_5_SECS].GetInterval());
|
||||
|
||||
return uint32(ceil(t / 1000.0f));
|
||||
return uint32(std::ceil(t / 1000.0f));
|
||||
}
|
||||
|
||||
void World::FinalizePlayerWorldSession(WorldSession* session)
|
||||
|
||||
@@ -65,7 +65,7 @@ void LiquidHandler::HandleNewLiquid()
|
||||
if ((Utils::IsAllZero(renderMask.Mask, 8) || (information.Width == 8 && information.Height == 8)) && information.OffsetMask2)
|
||||
{
|
||||
fseek(stream, chunk->Offset + information.OffsetMask2, SEEK_SET);
|
||||
uint32 size = ceil(information.Width * information.Height / 8.0f);
|
||||
uint32 size = std::ceil(information.Width * information.Height / 8.0f);
|
||||
uint8* altMask = new uint8[size];
|
||||
if (fread(altMask, sizeof(uint8), size, stream) == size)
|
||||
for (uint32 mi = 0; mi < size; mi++)
|
||||
|
||||
Reference in New Issue
Block a user