From ac99eb48e1529addafcf03fa30635e627d000c7a Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Fri, 31 Dec 2021 23:29:39 +0100 Subject: [PATCH] refactor(Core/Misc): abs() to std::abs() (#9789) --- src/common/Cryptography/BigNumber.cpp | 2 +- src/common/Utilities/Geometry.h | 4 ++-- src/server/game/AI/CoreAI/PetAI.cpp | 2 +- .../game/AI/SmartScripts/SmartScriptMgr.cpp | 6 +++--- .../game/Battlefield/Zones/BattlefieldWG.cpp | 4 ++-- .../game/Battlegrounds/BattlegroundQueue.cpp | 8 ++++---- src/server/game/Conditions/ConditionMgr.cpp | 4 ++-- .../game/Entities/Object/ObjectPosSelector.h | 2 +- src/server/game/Entities/Player/Player.cpp | 2 +- .../game/Entities/Player/PlayerQuest.cpp | 2 +- .../game/Entities/Player/PlayerStorage.cpp | 8 ++++---- src/server/game/Globals/ObjectMgr.cpp | 4 ++-- src/server/game/Guilds/Guild.cpp | 2 +- .../MovementGenerators/PathGenerator.cpp | 2 +- src/server/game/Scripting/MapScripts.cpp | 2 +- .../game/Spells/Auras/SpellAuraEffects.cpp | 2 +- src/server/game/Spells/Auras/SpellAuras.cpp | 12 ++++++------ src/server/game/Spells/Spell.cpp | 6 +++--- src/server/game/Spells/SpellInfo.cpp | 10 +++++----- src/server/game/Spells/SpellMgr.cpp | 18 +++++++++--------- src/server/scripts/Commands/cs_modify.cpp | 4 ++-- .../Karazhan/boss_netherspite.cpp | 2 +- .../instance_the_black_morass.cpp | 2 +- .../instance_vault_of_archavon.cpp | 8 ++++---- .../scripts/Northrend/isle_of_conquest.cpp | 2 +- 25 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/common/Cryptography/BigNumber.cpp b/src/common/Cryptography/BigNumber.cpp index d8079b861..5670ce4e3 100644 --- a/src/common/Cryptography/BigNumber.cpp +++ b/src/common/Cryptography/BigNumber.cpp @@ -24,7 +24,7 @@ BigNumber::~BigNumber() void BigNumber::SetDword(int32 val) { - SetDword(uint32(abs(val))); + SetDword(uint32(std::abs(val))); if (val < 0) { BN_set_negative(_bn, 1); diff --git a/src/common/Utilities/Geometry.h b/src/common/Utilities/Geometry.h index 038462792..0cb9a197f 100644 --- a/src/common/Utilities/Geometry.h +++ b/src/common/Utilities/Geometry.h @@ -42,12 +42,12 @@ [[nodiscard]] inline float getSlopeAngle(float startX, float startY, float startZ, float destX, float destY, float destZ) { float floorDist = sqrt(pow(startY - destY, 2.0f) + pow(startX - destX, 2.0f)); - return atan(abs(destZ - startZ) / abs(floorDist)); + return atan(std::abs(destZ - startZ) / std::abs(floorDist)); } [[nodiscard]] inline float getSlopeAngleAbs(float startX, float startY, float startZ, float destX, float destY, float destZ) { - return abs(getSlopeAngle(startX, startY, startZ, destX, destY, destZ)); + return std::abs(getSlopeAngle(startX, startY, startZ, destX, destY, destZ)); } [[nodiscard]] inline double getCircleAreaByRadius(double radius) diff --git a/src/server/game/AI/CoreAI/PetAI.cpp b/src/server/game/AI/CoreAI/PetAI.cpp index 39f78334f..8b8106cd9 100644 --- a/src/server/game/AI/CoreAI/PetAI.cpp +++ b/src/server/game/AI/CoreAI/PetAI.cpp @@ -207,7 +207,7 @@ void PetAI::UpdateAI(uint32 diff) { if (owner && owner->GetTypeId() == TYPEID_PLAYER && me->GetCharmInfo()->GetForcedSpell() && me->GetCharmInfo()->GetForcedTarget()) { - owner->ToPlayer()->GetSession()->HandlePetActionHelper(me, me->GetGUID(), abs(me->GetCharmInfo()->GetForcedSpell()), ACT_ENABLED, me->GetCharmInfo()->GetForcedTarget()); + owner->ToPlayer()->GetSession()->HandlePetActionHelper(me, me->GetGUID(), std::abs(me->GetCharmInfo()->GetForcedSpell()), ACT_ENABLED, me->GetCharmInfo()->GetForcedTarget()); // xinef: if spell was casted properly and we are in passive mode, handle return if (!me->GetCharmInfo()->GetForcedSpell() && me->HasReactState(REACT_PASSIVE)) diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp index b3415c73c..243a4ae1a 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.cpp @@ -191,9 +191,9 @@ void SmartAIMgr::LoadSmartAIFromDB() } else { - if (!sObjectMgr->GetCreatureData(uint32(abs(temp.entryOrGuid)))) + if (!sObjectMgr->GetCreatureData(uint32(std::abs(temp.entryOrGuid)))) { - LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid (%u) does not exist, skipped loading.", uint32(abs(temp.entryOrGuid))); + LOG_ERROR("sql.sql", "SmartAIMgr::LoadSmartAIFromDB: Creature guid (%u) does not exist, skipped loading.", uint32(std::abs(temp.entryOrGuid))); continue; } } @@ -1280,7 +1280,7 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e) if (e.entryOrGuid >= 0) entry = uint32(e.entryOrGuid); else { - entry = uint32(abs(e.entryOrGuid)); + entry = uint32(std::abs(e.entryOrGuid)); CreatureData const* data = sObjectMgr->GetCreatureData(entry); if (!data) { diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 73e16bf93..08939dab5 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -1085,7 +1085,7 @@ void BattlefieldWG::UpdateTenacity() if (Player* newPlayer = ObjectAccessor::FindPlayer(*itr)) if ((newPlayer->GetTeamId() == TEAM_ALLIANCE && m_tenacityStack > 0) || (newPlayer->GetTeamId() == TEAM_HORDE && m_tenacityStack < 0)) { - newStack = std::min(abs(newStack), 20); + newStack = std::min(std::abs(newStack), 20); uint32 buff_honor = GetHonorBuff(newStack); newPlayer->SetAuraStack(SPELL_TENACITY, newPlayer, newStack); if (buff_honor) @@ -1119,7 +1119,7 @@ void BattlefieldWG::UpdateTenacity() if (newStack) { team = newStack > 0 ? TEAM_ALLIANCE : TEAM_HORDE; - newStack = std::min(abs(newStack), 20); + newStack = std::min(std::abs(newStack), 20); uint32 buff_honor = GetHonorBuff(newStack); for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr) diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 168c0497f..eaa798517 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -89,7 +89,7 @@ bool BattlegroundQueue::SelectionPool::KickGroup(const uint32 size) for (auto itr = groupToKick; itr != SelectedGroups.end(); ++itr) { // if proper size - overwrite to kick last one - if (abs(int32((*itr)->Players.size()) - (int32)size) <= 1) + if (std::abs(int32((*itr)->Players.size()) - (int32)size) <= 1) { groupToKick = itr; foundProper = true; @@ -421,7 +421,7 @@ void BattlegroundQueue::FillPlayersToBG(Battleground* bg, const int32 aliFree, c } // balance the teams based on the difference allowed - while (abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0)) + while (std::abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0)) { // if results in more alliance players than horde: if (aliDiff < hordeDiff) @@ -504,7 +504,7 @@ void BattlegroundQueue::FillPlayersToBGWithSpecific(Battleground* bg, const int3 } // if free space differs too much, ballance - while (abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0)) + while (std::abs(aliDiff - hordeDiff) > invDiff && (m_SelectionPools[TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() > 0)) { // if results in more alliance players than horde: if (aliDiff < hordeDiff) @@ -610,7 +610,7 @@ bool BattlegroundQueue::CheckNormalMatch(Battleground* bgTemplate, BattlegroundB return m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers; case BG_QUEUE_INVITATION_TYPE_BALANCED: // check difference between selection pools - if = 1 or less start. - return abs(static_cast(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount()) - static_cast(m_SelectionPools[TEAM_HORDE].GetPlayerCount())) <= 1 && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers; + return std::abs(static_cast(m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount()) - static_cast(m_SelectionPools[TEAM_HORDE].GetPlayerCount())) <= 1 && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers; case BG_QUEUE_INVITATION_TYPE_EVEN: // if both counts are same then it's an even match return (m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() == m_SelectionPools[TEAM_HORDE].GetPlayerCount()) && m_SelectionPools[TEAM_ALLIANCE].GetPlayerCount() >= minPlayers && m_SelectionPools[TEAM_HORDE].GetPlayerCount() >= minPlayers; diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 3945a0eae..52879c9e2 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -931,7 +931,7 @@ void ConditionMgr::LoadConditions(bool isReload) delete cond; continue; } - cond->ReferenceId = uint32(abs(iConditionTypeOrReference)); + cond->ReferenceId = uint32(std::abs(iConditionTypeOrReference)); const char* rowType = "reference template"; if (iSourceTypeOrReferenceId >= 0) @@ -960,7 +960,7 @@ void ConditionMgr::LoadConditions(bool isReload) if (iSourceTypeOrReferenceId < 0) // it is a reference template { - uint32 uRefId = abs(iSourceTypeOrReferenceId); + uint32 uRefId = std::abs(iSourceTypeOrReferenceId); if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end()) // make sure we have a list for our conditions, based on reference id { ConditionList mCondList; diff --git a/src/server/game/Entities/Object/ObjectPosSelector.h b/src/server/game/Entities/Object/ObjectPosSelector.h index 4baf0268c..ad1b69ce5 100644 --- a/src/server/game/Entities/Object/ObjectPosSelector.h +++ b/src/server/game/Entities/Object/ObjectPosSelector.h @@ -41,7 +41,7 @@ struct ObjectPosSelector float dist; // dist to central point (including central point size) }; - typedef std::multimap UsedPosList; // abs(angle)->Node + typedef std::multimap UsedPosList; // std::abs(angle)->Node ObjectPosSelector(float x, float y, float size, float dist); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index c90efc3eb..28b3c261d 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -5799,7 +5799,7 @@ void Player::RewardReputation(Quest const* quest) uint32 row = ((quest->RewardFactionValueId[i] < 0) ? 1 : 0) + 1; if (QuestFactionRewEntry const* questFactionRewEntry = sQuestFactionRewardStore.LookupEntry(row)) { - uint32 field = abs(quest->RewardFactionValueId[i]); + uint32 field = std::abs(quest->RewardFactionValueId[i]); rep = questFactionRewEntry->QuestRewFactionValue[field]; } } diff --git a/src/server/game/Entities/Player/PlayerQuest.cpp b/src/server/game/Entities/Player/PlayerQuest.cpp index c20921dcb..47d1461bf 100644 --- a/src/server/game/Entities/Player/PlayerQuest.cpp +++ b/src/server/game/Entities/Player/PlayerQuest.cpp @@ -987,7 +987,7 @@ bool Player::SatisfyQuestPreviousQuest(Quest const* qInfo, bool msg) const for (Quest::PrevQuests::const_iterator iter = qInfo->prevQuests.begin(); iter != qInfo->prevQuests.end(); ++iter) { - uint32 prevId = abs(*iter); + uint32 prevId = std::abs(*iter); Quest const* qPrevInfo = sObjectMgr->GetQuestTemplate(prevId); diff --git a/src/server/game/Entities/Player/PlayerStorage.cpp b/src/server/game/Entities/Player/PlayerStorage.cpp index b345bed3d..9f070051d 100644 --- a/src/server/game/Entities/Player/PlayerStorage.cpp +++ b/src/server/game/Entities/Player/PlayerStorage.cpp @@ -4399,7 +4399,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool // Random Property Exist - try found basepoints for spell (basepoints depends from item suffix factor) if (item->GetItemRandomPropertyId()) { - ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); if (item_rand) { // Search enchant_amount @@ -4426,7 +4426,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool case ITEM_ENCHANTMENT_TYPE_RESISTANCE: if (!enchant_amount) { - ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand = sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); if (item_rand) { for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) @@ -4446,7 +4446,7 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool { if (!enchant_amount) { - ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(item->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(std::abs(item->GetItemRandomPropertyId())); if (item_rand_suffix) { for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; ++k) @@ -5215,7 +5215,7 @@ bool Player::LoadFromDB(ObjectGuid playerGuid, CharacterDatabaseQueryHolder cons map = sMapMgr->CreateMap(mapId, this); if (map) { - auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(abs(transLowGUID)); + auto bounds = map->GetGameObjectBySpawnIdStore().equal_range(std::abs(transLowGUID)); if (bounds.first != bounds.second) transGO = bounds.first->second->ToTransport(); } diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index ca1a68381..219878a50 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -4653,7 +4653,7 @@ void ObjectMgr::LoadQuests() { if (qinfo->RewardFactionId[j]) { - if (abs(qinfo->RewardFactionValueId[j]) > 9) + if (std::abs(qinfo->RewardFactionValueId[j]) > 9) { LOG_ERROR("sql.sql", "Quest %u has RewardFactionValueId%d = %i. That is outside the range of valid values (-9 to 9).", qinfo->GetQuestId(), j + 1, qinfo->RewardFactionValueId[j]); } @@ -4763,7 +4763,7 @@ void ObjectMgr::LoadQuests() // fill additional data stores if (qinfo->PrevQuestId) { - if (_questTemplates.find(abs(qinfo->GetPrevQuestId())) == _questTemplates.end()) + if (_questTemplates.find(std::abs(qinfo->GetPrevQuestId())) == _questTemplates.end()) { LOG_ERROR("sql.sql", "Quest %d has PrevQuestId %i, but no such quest", qinfo->GetQuestId(), qinfo->GetPrevQuestId()); } diff --git a/src/server/game/Guilds/Guild.cpp b/src/server/game/Guilds/Guild.cpp index 9a6eb7ab0..43935a840 100644 --- a/src/server/game/Guilds/Guild.cpp +++ b/src/server/game/Guilds/Guild.cpp @@ -2807,7 +2807,7 @@ void Guild::_SendBankList(WorldSession* session /* = nullptr*/, uint8 tabId /*= itemInfo.Slot = *itr; itemInfo.ItemID = tabItem->GetEntry(); itemInfo.Count = int32(tabItem->GetCount()); - itemInfo.Charges = int32(abs(tabItem->GetSpellCharges())); + itemInfo.Charges = int32(std::abs(tabItem->GetSpellCharges())); itemInfo.EnchantmentID = int32(tabItem->GetEnchantmentId(PERM_ENCHANTMENT_SLOT)); itemInfo.Flags = tabItem->GetInt32Value(ITEM_FIELD_FLAGS); diff --git a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp index c8702d8b4..cf905e9f8 100644 --- a/src/server/game/Movement/MovementGenerators/PathGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PathGenerator.cpp @@ -1004,7 +1004,7 @@ bool PathGenerator::IsWalkableClimb(float x, float y, float z, float destX, floa */ bool PathGenerator::IsWalkableClimb(float x, float y, float z, float destX, float destY, float destZ, float sourceHeight) { - float diffHeight = abs(destZ - z); + float diffHeight = std::abs(destZ - z); float reqHeight = GetRequiredHeightToClimb(x, y, z, destX, destY, destZ, sourceHeight); // check walkable slopes, based on unit height return diffHeight <= reqHeight; diff --git a/src/server/game/Scripting/MapScripts.cpp b/src/server/game/Scripting/MapScripts.cpp index f755e3cb0..97d9ce5b6 100644 --- a/src/server/game/Scripting/MapScripts.cpp +++ b/src/server/game/Scripting/MapScripts.cpp @@ -693,7 +693,7 @@ void Map::ScriptsProcess() break; case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry uSource = source ? source->ToUnit() : nullptr; - uTarget = uSource ? GetClosestCreatureWithEntry(uSource, abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : nullptr; + uTarget = uSource ? GetClosestCreatureWithEntry(uSource, std::abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : nullptr; break; } diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 9dee0f3a9..b98d6fc2c 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -461,7 +461,7 @@ int32 AuraEffect::CalculateAmount(Unit* caster) if (Item* castItem = playerCaster->GetItemByGuid(itemGUID)) if (castItem->GetItemSuffixFactor()) { - ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId())); + ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(std::abs(castItem->GetItemRandomPropertyId())); if (item_rand_suffix) { for (uint8 k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; k++) diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index aee2a4b1d..886a8d9db 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -189,7 +189,7 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply) { AuraApplication* strongestApp = apply ? this : nullptr; AuraEffect* strongestEff = apply ? aurEff : nullptr; - int32 amount = apply ? abs(aurEff->GetAmount()) : 0; + int32 amount = apply ? std::abs(aurEff->GetAmount()) : 0; Unit* target = GetTarget(); Unit::AuraEffectList const& auraList = target->GetAuraEffectsByType(aurEff->GetAuraType()); for (Unit::AuraEffectList::const_iterator iter = auraList.begin(); iter != auraList.end(); ++iter) @@ -207,7 +207,7 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply) if (!aurApp) continue; - if (amount < abs((*iter)->GetForcedAmount())) + if (amount < std::abs((*iter)->GetForcedAmount())) { // xinef: if we have strongest aura and it is active, turn it off // xinef: otherwise just save new aura; @@ -220,7 +220,7 @@ void AuraApplication::_HandleEffect(uint8 effIndex, bool apply) } strongestApp = aurApp; strongestEff = (*iter); - amount = abs((*iter)->GetAmount()); + amount = std::abs((*iter)->GetAmount()); } // xinef: itered aura is weaker, deactivate if active else if (aurApp->IsActive((*iter)->GetEffIndex())) @@ -1930,11 +1930,11 @@ bool Aura::IsAuraStronger(Aura const* newAura) const continue; // xinef: assume that all spells are either positive or negative, otherwise they should not be in one group - int32 curValue = abs(thisEffect->GetAmount()); - if (curValue < abs(newEffect->GetAmount())) + int32 curValue = std::abs(thisEffect->GetAmount()); + if (curValue < std::abs(newEffect->GetAmount())) return true; - if (curValue == abs(newEffect->GetAmount())) + if (curValue == std::abs(newEffect->GetAmount())) if(!IsPassive() && !IsPermanent() && GetDuration() < newAura->GetDuration()) return true; } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 60ab5cba2..fedfa2323 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -4873,7 +4873,7 @@ void Spell::TakeCastItem() // item has charges left if (charges) { - (charges > 0) ? --charges : ++charges; // abs(charges) less at 1 after use + (charges > 0) ? --charges : ++charges; // std::abs(charges) less at 1 after use if (proto->Stackable == 1) m_CastItem->SetSpellCharges(i, charges); m_CastItem->SetState(ITEM_CHANGED, m_caster->ToPlayer()); @@ -5143,7 +5143,7 @@ void Spell::TakeReagents() { // CastItem will be used up and does not count as reagent int32 charges = m_CastItem->GetSpellCharges(s); - if (castItemTemplate->Spells[s].SpellCharges < 0 && abs(charges) < 2) + if (castItemTemplate->Spells[s].SpellCharges < 0 && std::abs(charges) < 2) { ++itemcount; break; @@ -6839,7 +6839,7 @@ SpellCastResult Spell::CheckItems() { // CastItem will be used up and does not count as reagent int32 charges = m_CastItem->GetSpellCharges(s); - if (proto->Spells[s].SpellCharges < 0 && abs(charges) < 2) + if (proto->Spells[s].SpellCharges < 0 && std::abs(charges) < 2) { ++itemcount; break; diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 8a9dd4698..500d94c83 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1652,10 +1652,10 @@ bool SpellInfo::IsStrongerAuraActive(Unit const* caster, Unit const* target) con if (player->m_spellModTakingSpell && player->m_spellModTakingSpell->m_spellInfo->Id == Id) basePoints = player->m_spellModTakingSpell->GetSpellValue()->EffectBasePoints[i]; - int32 curValue = abs(Effects[i].CalcValue(caster, &basePoints)); + int32 curValue = std::abs(Effects[i].CalcValue(caster, &basePoints)); int32 auraValue = (sFlag & SPELL_GROUP_SPECIAL_FLAG_BASE_AMOUNT_CHECK) ? - abs((*iter)->GetSpellInfo()->Effects[(*iter)->GetEffIndex()].CalcValue((*iter)->GetCaster())) : - abs((*iter)->GetAmount()); + std::abs((*iter)->GetSpellInfo()->Effects[(*iter)->GetEffIndex()].CalcValue((*iter)->GetCaster())) : + std::abs((*iter)->GetAmount()); // xinef: for same spells, divide amount by stack amount if (Id == (*iter)->GetId()) @@ -2291,14 +2291,14 @@ int32 SpellInfo::GetDuration() const { if (!DurationEntry) return 0; - return (DurationEntry->Duration[0] == -1) ? -1 : abs(DurationEntry->Duration[0]); + return (DurationEntry->Duration[0] == -1) ? -1 : std::abs(DurationEntry->Duration[0]); } int32 SpellInfo::GetMaxDuration() const { if (!DurationEntry) return 0; - return (DurationEntry->Duration[2] == -1) ? -1 : abs(DurationEntry->Duration[2]); + return (DurationEntry->Duration[2] == -1) ? -1 : std::abs(DurationEntry->Duration[2]); } uint32 SpellInfo::CalcCastTime(Unit* caster, Spell* spell) const diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index cdcebb495..cdce1f3cf 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2261,16 +2261,16 @@ void SpellMgr::LoadSpellLinked() int32 effect = fields[1].GetInt32(); int32 type = fields[2].GetUInt8(); - SpellInfo const* spellInfo = GetSpellInfo(abs(trigger)); + SpellInfo const* spellInfo = GetSpellInfo(std::abs(trigger)); if (!spellInfo) { - LOG_ERROR("sql.sql", "Spell %u listed in `spell_linked_spell` does not exist", abs(trigger)); + LOG_ERROR("sql.sql", "Spell %u listed in `spell_linked_spell` does not exist", std::abs(trigger)); continue; } - spellInfo = GetSpellInfo(abs(effect)); + spellInfo = GetSpellInfo(std::abs(effect)); if (!spellInfo) { - LOG_ERROR("sql.sql", "Spell %u listed in `spell_linked_spell` does not exist", abs(effect)); + LOG_ERROR("sql.sql", "Spell %u listed in `spell_linked_spell` does not exist", std::abs(effect)); continue; } @@ -2576,16 +2576,16 @@ void SpellMgr::LoadSpellAreas() if (spellArea.auraSpell) { - SpellInfo const* spellInfo = GetSpellInfo(abs(spellArea.auraSpell)); + SpellInfo const* spellInfo = GetSpellInfo(std::abs(spellArea.auraSpell)); if (!spellInfo) { - LOG_ERROR("sql.sql", "Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell, abs(spellArea.auraSpell)); + LOG_ERROR("sql.sql", "Spell %u listed in `spell_area` have wrong aura spell (%u) requirement", spell, std::abs(spellArea.auraSpell)); continue; } - if (uint32(abs(spellArea.auraSpell)) == spellArea.spellId) + if (uint32(std::abs(spellArea.auraSpell)) == spellArea.spellId) { - LOG_ERROR("sql.sql", "Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell, abs(spellArea.auraSpell)); + LOG_ERROR("sql.sql", "Spell %u listed in `spell_area` have aura spell (%u) requirement for itself", spell, std::abs(spellArea.auraSpell)); continue; } @@ -2655,7 +2655,7 @@ void SpellMgr::LoadSpellAreas() // for search at aura apply if (spellArea.auraSpell) - mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(abs(spellArea.auraSpell), sa)); + mSpellAreaForAuraMap.insert(SpellAreaForAuraMap::value_type(std::abs(spellArea.auraSpell), sa)); ++count; } while (result->NextRow()); diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index a9e912dbc..72ad5acd5 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -644,9 +644,9 @@ public: if (newmoney > MAX_MONEY_AMOUNT) newmoney = MAX_MONEY_AMOUNT; - handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, abs(moneyToAdd), handler->GetNameLink(target).c_str()); + handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, std::abs(moneyToAdd), handler->GetNameLink(target).c_str()); if (handler->needReportToTarget(target)) - ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), abs(moneyToAdd)); + ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink().c_str(), std::abs(moneyToAdd)); target->SetMoney(newmoney); } } diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp index 9e8eff1e8..e3eb1940d 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_netherspite.cpp @@ -111,7 +111,7 @@ public: if (dist(xn, yn, xh, yh) >= dist(xn, yn, xp, yp) || dist(xp, yp, xh, yh) >= dist(xn, yn, xp, yp)) return false; // check distance from the beam - return (abs((xn - xp) * yh + (yp - yn) * xh - xn * yp + xp * yn) / dist(xn, yn, xp, yp) < 1.5f); + return (std::abs((xn - xp) * yh + (yp - yn) * xh - xn * yp + xp * yn) / dist(xn, yn, xp, yp) < 1.5f); } float dist(float xa, float ya, float xb, float yb) // auxiliary method for distance diff --git a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp index b0c4bfcb9..e3d1f60cb 100644 --- a/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp +++ b/src/server/scripts/Kalimdor/CavernsOfTime/TheBlackMorass/instance_the_black_morass.cpp @@ -270,7 +270,7 @@ public: Position pos = rift->GetNearPosition(10.0f, 2 * M_PI * rand_norm()); - if (TempSummon* summon = instance->SummonCreature(abs(entry), pos)) + if (TempSummon* summon = instance->SummonCreature(std::abs(entry), pos)) { summon->SetTempSummonType(TEMPSUMMON_CORPSE_TIMED_DESPAWN); summon->SetTimer(3 * MINUTE * IN_MILLISECONDS); diff --git a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp index ba480aacd..9ca876b3e 100644 --- a/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp +++ b/src/server/scripts/Northrend/VaultOfArchavon/instance_vault_of_archavon.cpp @@ -216,10 +216,10 @@ public: if (ArchavonDeath && EmalonDeath && KoralonDeath) { // instance difficulty check is already done in db (achievement_criteria_data) - // int() for Visual Studio, compile errors with abs(time_t) - return (abs(int(ArchavonDeath - EmalonDeath)) < MINUTE && \ - abs(int(EmalonDeath - KoralonDeath)) < MINUTE && \ - abs(int(KoralonDeath - ArchavonDeath)) < MINUTE); + // int() for Visual Studio, compile errors with std::abs(time_t) + return (std::abs(int(ArchavonDeath - EmalonDeath)) < MINUTE && \ + std::abs(int(EmalonDeath - KoralonDeath)) < MINUTE && \ + std::abs(int(KoralonDeath - ArchavonDeath)) < MINUTE); } break; default: diff --git a/src/server/scripts/Northrend/isle_of_conquest.cpp b/src/server/scripts/Northrend/isle_of_conquest.cpp index 048115881..ce5874d67 100644 --- a/src/server/scripts/Northrend/isle_of_conquest.cpp +++ b/src/server/scripts/Northrend/isle_of_conquest.cpp @@ -245,7 +245,7 @@ public: } else { - if (me->GetDistance(me->GetHomePosition()) < 40.0f && abs(me->GetPositionZ() - me->GetHomePosition().GetPositionZ()) < 5.0f) + if (me->GetDistance(me->GetHomePosition()) < 40.0f && std::abs(me->GetPositionZ() - me->GetHomePosition().GetPositionZ()) < 5.0f) { rage = false; me->RemoveAurasDueToSpell(SPELL_IOCBOSS_RAGE);