mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-28 16:16:27 +00:00
refactor(Core/Misc): abs() to std::abs() (#9789)
This commit is contained in:
@@ -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++)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user