Core/Misc: rename Powers to PowerType

This commit is contained in:
Ovahlord committed 2026-06-09 08:19:48 +02:00
1 parent 2c2f200e14
commit 5d22ddd499
23 files changed
+112 -112

No files matched your search

+2 -2
View File
@@ -103,12 +103,12 @@ struct TC_GAME_API NonTankTargetSelector
struct TC_GAME_API PowerUsersSelector
{
public:
PowerUsersSelector(Unit const* unit, Powers power, float dist, bool playerOnly) : _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { }
PowerUsersSelector(Unit const* unit, PowerType power, float dist, bool playerOnly) : _me(unit), _power(power), _dist(dist), _playerOnly(playerOnly) { }
bool operator()(Unit const* target) const;
private:
Unit const* _me;
Powers const _power;
PowerType const _power;
float const _dist;
bool const _playerOnly;
};
@@ -312,7 +312,7 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
continue;
//Continue if we don't have the mana to actually cast this spell
if (tempSpell->ManaCost > (uint32)me->GetPower(Powers(tempSpell->PowerType)))
if (tempSpell->ManaCost > (uint32)me->GetPower(PowerType(tempSpell->PowerType)))
continue;
//Check if the spell meets our range requirements
@@ -2076,7 +2076,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
for (WorldObject* target : targets)
if (IsUnit(target))
target->ToUnit()->SetPower(Powers(e.action.power.powerType), e.action.power.newPower);
target->ToUnit()->SetPower(PowerType(e.action.power.powerType), e.action.power.newPower);
break;
}
@@ -2084,7 +2084,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
for (WorldObject* target : targets)
if (IsUnit(target))
target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) + e.action.power.newPower);
target->ToUnit()->SetPower(PowerType(e.action.power.powerType), target->ToUnit()->GetPower(PowerType(e.action.power.powerType)) + e.action.power.newPower);
break;
}
@@ -2092,7 +2092,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
for (WorldObject* target : targets)
if (IsUnit(target))
target->ToUnit()->SetPower(Powers(e.action.power.powerType), target->ToUnit()->GetPower(Powers(e.action.power.powerType)) - e.action.power.newPower);
target->ToUnit()->SetPower(PowerType(e.action.power.powerType), target->ToUnit()->GetPower(PowerType(e.action.power.powerType)) - e.action.power.newPower);
break;
}
@@ -2601,7 +2601,7 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{
if (e.target.hostilRandom.powerType)
{
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_MAXTHREAT, 1, PowerUsersSelector(me, Powers(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_MAXTHREAT, 1, PowerUsersSelector(me, PowerType(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
targets.push_back(u);
}
else if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_MAXTHREAT, 1, (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0))
@@ -2613,7 +2613,7 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{
if (e.target.hostilRandom.powerType)
{
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_MINTHREAT, 0, PowerUsersSelector(me, Powers(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_MINTHREAT, 0, PowerUsersSelector(me, PowerType(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
targets.push_back(u);
}
else if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_MINTHREAT, 0, (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0))
@@ -2625,7 +2625,7 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{
if (e.target.hostilRandom.powerType)
{
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, PowerUsersSelector(me, Powers(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, PowerUsersSelector(me, PowerType(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
targets.push_back(u);
}
else if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_RANDOM, 0, (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0))
@@ -2637,7 +2637,7 @@ void SmartScript::GetTargets(ObjectVector& targets, SmartScriptHolder const& e,
{
if (e.target.hostilRandom.powerType)
{
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_RANDOM, 1, PowerUsersSelector(me, Powers(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_RANDOM, 1, PowerUsersSelector(me, PowerType(e.target.hostilRandom.powerType - 1), (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0)))
targets.push_back(u);
}
else if (Unit* u = me->AI()->SelectTarget(SELECT_TARGET_RANDOM, 1, (float)e.target.hostilRandom.maxDist, e.target.hostilRandom.playerOnly != 0))
+3 -3
View File
@@ -1092,7 +1092,7 @@ CharSectionsEntry const* DBCManager::GetCharSectionEntry(uint8 race, CharSection
return nullptr;
}
uint32 DBCManager::GetPowerIndexByClass(Powers power, uint32 classId)
uint32 DBCManager::GetPowerIndexByClass(PowerType power, uint32 classId)
{
return PowersByClass[classId][power];
}
@@ -1332,7 +1332,7 @@ EmotesTextSoundEntry const* DBCManager::FindTextSoundEmoteFor(uint32 emote, uint
return itr != sEmotesTextSoundMap.end() ? itr->second : nullptr;
}
/*static*/ float DBCManager::GetBasePowerRegen(Powers powerType, bool isInCombat, uint32 powerBarId)
/*static*/ float DBCManager::GetBasePowerRegen(PowerType powerType, bool isInCombat, uint32 powerBarId)
{
if (powerType != POWER_ALTERNATE_POWER)
{
@@ -1360,7 +1360,7 @@ EmotesTextSoundEntry const* DBCManager::FindTextSoundEmoteFor(uint32 emote, uint
return 0.f;
}
/*static*/ bool DBCManager::IsPowerTypeAffectedByHaste(Powers powerType)
/*static*/ bool DBCManager::IsPowerTypeAffectedByHaste(PowerType powerType)
{
switch (powerType)
{
+3 -3
View File
@@ -242,7 +242,7 @@ public:
PvPDifficultyEntry const* GetBattlegroundBracketById(uint32 mapid, BattlegroundBracketId id);
CharStartOutfitEntry const* GetCharStartOutfitEntry(uint8 race, uint8 class_, uint8 gender);
CharSectionsEntry const* GetCharSectionEntry(uint8 race, CharSectionType genType, uint8 gender, uint8 type, uint8 color);
uint32 GetPowerIndexByClass(Powers power, uint32 classId);
uint32 GetPowerIndexByClass(PowerType power, uint32 classId);
static bool IsInArea(uint32 objectAreaId, uint32 areaId);
static LFGDungeonEntry const* GetLFGDungeon(uint32 mapId, Difficulty difficulty);
std::vector<uint32> const* GetPhasesForGroup(uint32 group);
@@ -250,8 +250,8 @@ public:
SkillRaceClassInfoEntry const* GetSkillRaceClassInfo(uint32 skill, uint8 race, uint8 class_);
ResponseCodes ValidateName(std::wstring const& name, LocaleConstant locale);
EmotesTextSoundEntry const* FindTextSoundEmoteFor(uint32 emote, uint32 race, uint32 gender);
static float GetBasePowerRegen(Powers powerType, bool isInCombat, uint32 powerBarId = 0);
static bool IsPowerTypeAffectedByHaste(Powers powerType);
static float GetBasePowerRegen(PowerType powerType, bool isInCombat, uint32 powerBarId = 0);
static bool IsPowerTypeAffectedByHaste(PowerType powerType);
static float GetGtOCTRegenMPPerSpirit(uint8 classId, uint8 level);
};
@@ -1432,7 +1432,7 @@ void Creature::UpdateLevelDependantStats()
SetStatFlatModifier(UNIT_MOD_HEALTH, BASE_VALUE, (float)health);
// mana
Powers powerType = CalculateDisplayPowerType();
PowerType powerType = CalculateDisplayPowerType();
SetCreateMana(stats->BaseMana);
SetStatPctModifier(UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(powerType)), BASE_PCT, cInfo->ModMana * cInfo->ModManaExtra);
RegisterPowerTypes();
+2 -2
View File
@@ -199,8 +199,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
void UpdateResistances(uint32 school) override;
void UpdateArmor() override;
void UpdateMaxHealth() override;
void UpdateMaxPower(Powers power) override;
uint32 GetPowerIndex(Powers power) const override;
void UpdateMaxPower(PowerType power) override;
uint32 GetPowerIndex(PowerType power) const override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) const override;
@@ -124,7 +124,7 @@ class TC_GAME_API Guardian : public Minion
void UpdateResistances(uint32 school) override;
void UpdateArmor() override;
void UpdateMaxHealth() override;
void UpdateMaxPower(Powers power) override;
void UpdateMaxPower(PowerType power) override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void UpdateDamagePhysical(WeaponAttackType attType) override;
+1 -1
View File
@@ -759,7 +759,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
for (uint8 i = SPELL_SCHOOL_HOLY; i < MAX_SPELL_SCHOOL; ++i)
SetStatFlatModifier(UnitMods(UNIT_MOD_RESISTANCE_START + i), BASE_VALUE, float(cinfo->resistance[i]));
Powers powerType = CalculateDisplayPowerType();
PowerType powerType = CalculateDisplayPowerType();
// Health, mana, armor and resistance
PetLevelInfo const* pInfo = sObjectMgr->GetPetLevelInfo(creature_ID, petlevel);
+7 -7
View File
@@ -2478,7 +2478,7 @@ void Player::InitStatsForLevel(bool reapplyMods)
// save new stats
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
SetMaxPower(Powers(i), GetCreatePowerValue(Powers(i)));
SetMaxPower(PowerType(i), GetCreatePowerValue(PowerType(i)));
SetMaxHealth(basehp); // stamina bonus will applied later
@@ -17164,11 +17164,11 @@ bool Player::LoadFromDB(ObjectGuid guid, CharacterDatabaseQueryHolder const& hol
uint32 loadedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndex(Powers(i)) != MAX_POWERS)
if (GetPowerIndex(PowerType(i)) != MAX_POWERS)
{
uint32 savedPower = fields[53 + loadedPowers].GetUInt32();
uint32 maxPower = GetUInt32Value(UNIT_FIELD_MAXPOWER1 + loadedPowers);
SetPower(Powers(i), (savedPower > maxPower) ? maxPower : savedPower);
SetPower(PowerType(i), (savedPower > maxPower) ? maxPower : savedPower);
if (++loadedPowers >= MAX_POWERS_PER_CLASS)
break;
}
@@ -19041,7 +19041,7 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false
uint32 storedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndex(Powers(i)) != MAX_POWERS)
if (GetPowerIndex(PowerType(i)) != MAX_POWERS)
{
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
if (++storedPowers >= MAX_POWERS_PER_CLASS)
@@ -19177,7 +19177,7 @@ void Player::SaveToDB(CharacterDatabaseTransaction trans, bool create /* = false
uint32 storedPowers = 0;
for (uint32 i = 0; i < MAX_POWERS; ++i)
{
if (GetPowerIndex(Powers(i)) != MAX_POWERS)
if (GetPowerIndex(PowerType(i)) != MAX_POWERS)
{
stmt->setUInt32(index++, GetUInt32Value(UNIT_FIELD_POWER1 + storedPowers));
if (++storedPowers >= MAX_POWERS_PER_CLASS)
@@ -20000,7 +20000,7 @@ void Player::_SaveStats(CharacterDatabaseTransaction& trans) const
stmt->setUInt32(index++, GetMaxHealth());
for (uint8 i = 0; i < MAX_POWERS_PER_CLASS; ++i)
stmt->setUInt32(index++, GetMaxPower(Powers(i)));
stmt->setUInt32(index++, GetMaxPower(PowerType(i)));
for (uint8 i = 0; i < MAX_STATS; ++i)
stmt->setUInt32(index++, GetStat(Stats(i)));
@@ -26680,7 +26680,7 @@ void Player::ActivateSpec(uint8 spec)
}));
}
Powers pw = GetPowerType();
PowerType pw = GetPowerType();
if (pw != POWER_MANA)
SetPower(POWER_MANA, 0); // Mana must be 0 even if it isn't the active power type.
+2 -2
View File
@@ -1748,8 +1748,8 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void UpdateResistances(uint32 school) override;
void UpdateArmor() override;
void UpdateMaxHealth() override;
void UpdateMaxPower(Powers power) override;
uint32 GetPowerIndex(Powers power) const override;
void UpdateMaxPower(PowerType power) override;
uint32 GetPowerIndex(PowerType power) const override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void ApplySpellPowerBonus(int32 amount, bool apply);
void UpdateSpellDamageAndHealingBonus();
+1 -1
View File
@@ -57,7 +57,7 @@ class TC_GAME_API Totem : public Minion
void UpdateResistances(uint32 /*school*/) override { }
void UpdateArmor() override { }
void UpdateMaxHealth() override { }
void UpdateMaxPower(Powers /*power*/) override { }
void UpdateMaxPower(PowerType /*power*/) override { }
void UpdateAttackPowerAndDamage(bool /*ranged*/) override { }
void UpdateDamagePhysical(WeaponAttackType /*attType*/) override { }
+10 -10
View File
@@ -87,7 +87,7 @@ void Unit::UpdateDamagePhysical(WeaponAttackType attType)
}
}
int32 Unit::GetCreatePowerValue(Powers power) const
int32 Unit::GetCreatePowerValue(PowerType power) const
{
switch (power)
{
@@ -120,7 +120,7 @@ int32 Unit::GetCreatePowerValue(Powers power) const
return 0;
}
void Unit::UpdatePowerRegeneration(Powers powerType)
void Unit::UpdatePowerRegeneration(PowerType powerType)
{
uint32 powerIndex = GetPowerIndex(powerType);
if ((powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS) && powerType != POWER_RUNE)
@@ -348,7 +348,7 @@ bool Player::UpdateAllStats()
UpdateMaxHealth();
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i));
UpdateMaxPower(PowerType(i));
UpdateAllRatings();
UpdateAllCritPercentages();
@@ -442,12 +442,12 @@ void Player::UpdateMaxHealth()
SetMaxHealth((uint32)value);
}
uint32 Player::GetPowerIndex(Powers power) const
uint32 Player::GetPowerIndex(PowerType power) const
{
return sDBCManager.GetPowerIndexByClass(power, getClass());
}
void Player::UpdateMaxPower(Powers power)
void Player::UpdateMaxPower(PowerType power)
{
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS || powerIndex >= MAX_POWERS_PER_CLASS)
@@ -951,7 +951,7 @@ bool Creature::UpdateAllStats()
UpdateAttackPowerAndDamage(true);
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i));
UpdateMaxPower(PowerType(i));
UpdateAllResistances();
@@ -981,7 +981,7 @@ void Creature::UpdateMaxHealth()
SetMaxHealth(uint32(value));
}
uint32 Creature::GetPowerIndex(Powers power) const
uint32 Creature::GetPowerIndex(PowerType power) const
{
if (power == GetPowerType())
return 0;
@@ -990,7 +990,7 @@ uint32 Creature::GetPowerIndex(Powers power) const
return MAX_POWERS;
}
void Creature::UpdateMaxPower(Powers power)
void Creature::UpdateMaxPower(PowerType power)
{
if (GetPowerIndex(power) == MAX_POWERS)
return;
@@ -1141,7 +1141,7 @@ bool Guardian::UpdateAllStats()
UpdateStats(Stats(i));
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i));
UpdateMaxPower(PowerType(i));
UpdateAllResistances();
@@ -1188,7 +1188,7 @@ void Guardian::UpdateMaxHealth()
SetMaxHealth((uint32)value);
}
void Guardian::UpdateMaxPower(Powers power)
void Guardian::UpdateMaxPower(PowerType power)
{
if (GetPowerIndex(power) == MAX_POWERS)
return;
+19 -19
View File
@@ -5243,7 +5243,7 @@ void Unit::SendAttackStateUpdate(uint32 HitInfo, Unit* target, uint8 /*SwingType
SendAttackStateUpdate(&dmgInfo);
}
void Unit::SetPowerType(Powers power)
void Unit::SetPowerType(PowerType power)
{
if (GetPowerType() == power)
return;
@@ -5292,9 +5292,9 @@ void Unit::SetPowerType(Powers power)
}
}
Powers Unit::CalculateDisplayPowerType() const
PowerType Unit::CalculateDisplayPowerType() const
{
Powers displayPower = POWER_MANA;
PowerType displayPower = POWER_MANA;
switch (GetShapeshiftForm())
{
case FORM_GHOUL:
@@ -5312,12 +5312,12 @@ Powers Unit::CalculateDisplayPowerType() const
{
ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass());
if (cEntry && cEntry->DisplayPower < MAX_POWERS)
displayPower = Powers(cEntry->DisplayPower);
displayPower = PowerType(cEntry->DisplayPower);
if (Vehicle* vehicle = GetVehicleKit())
{
if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(vehicle->GetVehicleInfo()->PowerDisplayID[0])) // To-do: 4.x has 3 power display id fields.
displayPower = Powers(powerDisplay->ActualType);
displayPower = PowerType(powerDisplay->ActualType);
else if (getClass() == CLASS_ROGUE)
displayPower = POWER_ENERGY;
}
@@ -6267,7 +6267,7 @@ int32 Unit::HealBySpell(HealInfo& healInfo, bool critical /*= false*/)
return healInfo.GetEffectiveHeal();
}
void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powers powerType)
void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, PowerType powerType)
{
WorldPackets::CombatLog::SpellEnergizeLog packet;
packet.TargetGUID = victim->GetGUID();
@@ -6279,13 +6279,13 @@ void Unit::SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powe
SendMessageToSet(packet.Write(), true);
}
void Unit::EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers powerType)
void Unit::EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, PowerType powerType)
{
if (SpellInfo const* info = sSpellMgr->GetSpellInfo(spellId))
EnergizeBySpell(victim, info, damage, powerType);
}
void Unit::EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, Powers powerType)
void Unit::EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, PowerType powerType)
{
victim->ModifyPower(powerType, damage, false);
victim->GetThreatManager().ForwardThreatForAssistingMe(this, float(damage) / 2, spellInfo, true);
@@ -8206,7 +8206,7 @@ int32 Unit::GetHealthGain(int32 dVal)
}
// returns negative amount on power reduction
int32 Unit::ModifyPower(Powers power, int32 dVal, bool withPowerUpdate /*= true*/)
int32 Unit::ModifyPower(PowerType power, int32 dVal, bool withPowerUpdate /*= true*/)
{
int32 gain = 0;
@@ -8239,7 +8239,7 @@ int32 Unit::ModifyPower(Powers power, int32 dVal, bool withPowerUpdate /*= true*
}
// Based on client function
float Unit::GetPowerRegen(Powers powerType, bool isInCombat) const
float Unit::GetPowerRegen(PowerType powerType, bool isInCombat) const
{
uint32 powerSlot = MAX_POWERS;
float totalRegeneration = 0.f;
@@ -9169,7 +9169,7 @@ Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const
return stat;
}
Powers Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const
PowerType Unit::GetPowerTypeByAuraGroup(UnitMods unitMod) const
{
switch (unitMod)
{
@@ -9295,7 +9295,7 @@ void Unit::SetMaxHealth(uint32 val)
SetHealth(val);
}
int32 Unit::GetPower(Powers power) const
int32 Unit::GetPower(PowerType power) const
{
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
@@ -9304,7 +9304,7 @@ int32 Unit::GetPower(Powers power) const
return GetUInt32Value(UNIT_FIELD_POWER1 + powerIndex);
}
int32 Unit::GetMaxPower(Powers power) const
int32 Unit::GetMaxPower(PowerType power) const
{
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
@@ -9313,7 +9313,7 @@ int32 Unit::GetMaxPower(Powers power) const
return GetInt32Value(UNIT_FIELD_MAXPOWER1 + powerIndex);
}
void Unit::SetPower(Powers power, int32 val, bool withPowerUpdate /*= true*/)
void Unit::SetPower(PowerType power, int32 val, bool withPowerUpdate /*= true*/)
{
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
@@ -9350,7 +9350,7 @@ void Unit::SetPower(Powers power, int32 val, bool withPowerUpdate /*= true*/)
}
}
void Unit::SetMaxPower(Powers power, int32 val)
void Unit::SetMaxPower(PowerType power, int32 val)
{
uint32 powerIndex = GetPowerIndex(power);
if (powerIndex == MAX_POWERS)
@@ -9379,7 +9379,7 @@ void Unit::SetMaxPower(Powers power, int32 val)
SetPower(power, val);
}
void Unit::Regenerate(Powers powerType, uint32 diff)
void Unit::Regenerate(PowerType powerType, uint32 diff)
{
uint32 maxValue = GetMaxPower(powerType);
if (!maxValue)
@@ -9476,11 +9476,11 @@ void Unit::RegisterPowerTypes()
{
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
{
uint32 powerIndex = GetPowerIndex(Powers(i));
uint32 powerIndex = GetPowerIndex(PowerType(i));
if (powerIndex == MAX_POWERS || powerIndex == MAX_POWERS_PER_CLASS)
continue;
_usedPowerTypes[powerIndex] = static_cast<Powers>(i);
_usedPowerTypes[powerIndex] = static_cast<PowerType>(i);
}
}
@@ -10444,7 +10444,7 @@ void Unit::ApplyHasteRegenMod(float val, bool apply)
SetFloatValue(PLAYER_FIELD_MOD_HASTE_REGEN, amount);
for (Powers powerType : GetUsedPowerTypes())
for (PowerType powerType : GetUsedPowerTypes())
{
if (powerType == MAX_POWERS || GetPowerIndex(powerType) == MAX_POWERS)
continue;
+25 -25
View File
@@ -802,26 +802,26 @@ class TC_GAME_API Unit : public WorldObject
int32 ModifyHealth(int32 val);
int32 GetHealthGain(int32 dVal);
Powers GetPowerType() const { return Powers(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); }
void SetPowerType(Powers power);
Powers CalculateDisplayPowerType() const;
PowerType GetPowerType() const { return PowerType(GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_POWER_TYPE)); }
void SetPowerType(PowerType power);
PowerType CalculateDisplayPowerType() const;
void UpdateDisplayPower();
int32 GetPower(Powers power) const;
int32 GetMinPower(Powers power) const { return power == POWER_ECLIPSE ? -100 : 0; }
int32 GetMaxPower(Powers power) const;
int32 CountPctFromMaxPower(Powers power, int32 pct) const { return CalculatePct(GetMaxPower(power), pct); }
void SetPower(Powers power, int32 val, bool withPowerUpdate = true);
void SetMaxPower(Powers power, int32 val);
int32 GetPower(PowerType power) const;
int32 GetMinPower(PowerType power) const { return power == POWER_ECLIPSE ? -100 : 0; }
int32 GetMaxPower(PowerType power) const;
int32 CountPctFromMaxPower(PowerType power, int32 pct) const { return CalculatePct(GetMaxPower(power), pct); }
void SetPower(PowerType power, int32 val, bool withPowerUpdate = true);
void SetMaxPower(PowerType power, int32 val);
void SetPowerBarID(uint32 id) { _powerBarId = id; }
void Regenerate(Powers powerType, uint32 diff);
void UpdatePowerRegeneration(Powers powerType);
void Regenerate(PowerType powerType, uint32 diff);
void UpdatePowerRegeneration(PowerType powerType);
void RegisterPowerTypes();
inline void SetFullPower(Powers power) { SetPower(power, GetMaxPower(power)); }
inline void SetFullPower(PowerType power) { SetPower(power, GetMaxPower(power)); }
// returns the change in power
int32 ModifyPower(Powers power, int32 val, bool withPowerUpdate = true);
float GetPowerRegen(Powers powerType, bool isInCombat) const;
int32 ModifyPower(PowerType power, int32 val, bool withPowerUpdate = true);
float GetPowerRegen(PowerType powerType, bool isInCombat) const;
virtual void RegenerateHealth() { }
@@ -1010,9 +1010,9 @@ class TC_GAME_API Unit : public WorldObject
void SendHealSpellLog(HealInfo& healInfo, bool critical = false);
int32 HealBySpell(HealInfo& healInfo, bool critical = false);
void SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, Powers powerType);
void EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, Powers powerType);
void EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, Powers powerType);
void SendEnergizeSpellLog(Unit* victim, uint32 spellId, int32 damage, PowerType powerType);
void EnergizeBySpell(Unit* victim, uint32 spellId, int32 damage, PowerType powerType);
void EnergizeBySpell(Unit* victim, SpellInfo const* spellInfo, int32 damage, PowerType powerType);
Aura* AddAura(uint32 spellId, Unit* target);
Aura* AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target);
@@ -1287,7 +1287,7 @@ class TC_GAME_API Unit : public WorldObject
uint32 GetCreateHealth() const { return GetUInt32Value(UNIT_FIELD_BASE_HEALTH); }
void SetCreateMana(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_MANA, val); }
uint32 GetCreateMana() const { return GetUInt32Value(UNIT_FIELD_BASE_MANA); }
int32 GetCreatePowerValue(Powers power) const;
int32 GetCreatePowerValue(PowerType power) const;
float GetPosStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0 + AsUnderlyingType(stat)); }
float GetNegStat(Stats stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0 + AsUnderlyingType(stat)); }
float GetCreateStat(Stats stat) const { return m_createStats[stat]; }
@@ -1364,7 +1364,7 @@ class TC_GAME_API Unit : public WorldObject
float GetTotalAuraModValue(UnitMods unitMod) const;
SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const;
Stats GetStatByAuraGroup(UnitMods unitMod) const;
Powers GetPowerTypeByAuraGroup(UnitMods unitMod) const;
PowerType GetPowerTypeByAuraGroup(UnitMods unitMod) const;
bool CanModifyStats() const { return m_canModifyStats; }
void SetCanModifyStats(bool modifyStats) { m_canModifyStats = modifyStats; }
virtual bool UpdateStats(Stats stat) = 0;
@@ -1373,8 +1373,8 @@ class TC_GAME_API Unit : public WorldObject
virtual void UpdateAllResistances();
virtual void UpdateArmor() = 0;
virtual void UpdateMaxHealth() = 0;
virtual void UpdateMaxPower(Powers power) = 0;
virtual uint32 GetPowerIndex(Powers power) const = 0;
virtual void UpdateMaxPower(PowerType power) = 0;
virtual uint32 GetPowerIndex(PowerType power) const = 0;
virtual void UpdateAttackPowerAndDamage(bool ranged = false) = 0;
virtual void UpdateDamagePhysical(WeaponAttackType attType);
float GetTotalAttackPowerValue(WeaponAttackType attType) const;
@@ -1727,10 +1727,10 @@ class TC_GAME_API Unit : public WorldObject
int32 _powerUpdateTimer;
int32 _healthRegenerationTimer;
std::array<float, MAX_POWERS_PER_CLASS> _powerFraction;
std::array<Powers, MAX_POWERS_PER_CLASS> _usedPowerTypes;
std::array<PowerType, MAX_POWERS_PER_CLASS> _usedPowerTypes;
public:
// Returns an array that contains information about which power type is used at which power index. MAX_POWERS implies that a power at given index is not used.
std::array<Powers, MAX_POWERS_PER_CLASS> const& GetUsedPowerTypes() const { return _usedPowerTypes; }
std::array<PowerType, MAX_POWERS_PER_CLASS> const& GetUsedPowerTypes() const { return _usedPowerTypes; }
protected:
@@ -1827,7 +1827,7 @@ namespace Trinity
class PowerPctOrderPred
{
public:
PowerPctOrderPred(Powers power, bool ascending = true) : _power(power), _ascending(ascending) { }
PowerPctOrderPred(PowerType power, bool ascending = true) : _power(power), _ascending(ascending) { }
bool operator()(WorldObject const* objA, WorldObject const* objB) const
{
@@ -1846,7 +1846,7 @@ namespace Trinity
}
private:
Powers const _power;
PowerType const _power;
bool const _ascending;
};
@@ -26,7 +26,7 @@ class Map;
class WorldObject;
struct VehicleSeatEntry;
enum PowerType : uint32
enum PowerDisplay : uint32
{
POWER_STEAM = 61,
POWER_PYRITE = 41,
@@ -1803,7 +1803,7 @@ void AuraEffect::HandleAuraModShapeshift(AuraApplication const* aurApp, uint8 mo
Unit* target = aurApp->GetTarget();
uint32 modelid = 0;
Powers PowerType = POWER_MANA;
PowerType PowerType = POWER_MANA;
ShapeshiftForm form = ShapeshiftForm(GetMiscValue());
switch (form)
@@ -3802,7 +3802,7 @@ void AuraEffect::HandleModPowerRegen(AuraApplication const* aurApp, uint8 mode,
return;
// Update power regen values
aurApp->GetTarget()->UpdatePowerRegeneration(Powers(GetMiscValue()));
aurApp->GetTarget()->UpdatePowerRegeneration(PowerType(GetMiscValue()));
}
void AuraEffect::HandleModPowerRegenPCT(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -3896,7 +3896,7 @@ void AuraEffect::HandleAuraModIncreaseEnergy(AuraApplication const* aurApp, uint
return;
Unit* target = aurApp->GetTarget();
Powers powerType = Powers(GetMiscValue());
PowerType powerType = PowerType(GetMiscValue());
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(powerType));
target->HandleStatFlatModifier(unitMod, TOTAL_VALUE, float(GetAmount()), apply);
@@ -3909,7 +3909,7 @@ void AuraEffect::HandleAuraModIncreaseEnergyPercent(AuraApplication const* aurAp
Unit* target = aurApp->GetTarget();
Powers powerType = Powers(GetMiscValue());
PowerType powerType = PowerType(GetMiscValue());
UnitMods unitMod = UnitMods(UNIT_MOD_POWER_START + AsUnderlyingType(powerType));
// Save old powers for further calculation
@@ -6086,7 +6086,7 @@ void AuraEffect::HandlePeriodicHealAurasTick(Unit* target, Unit* caster) const
void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) const
{
Powers powerType = Powers(GetMiscValue());
PowerType powerType = PowerType(GetMiscValue());
if (!caster || !caster->IsAlive() || !target->IsAlive() || target->GetPowerType() != powerType)
return;
@@ -6154,11 +6154,11 @@ void AuraEffect::HandlePeriodicManaLeechAuraTick(Unit* target, Unit* caster) con
void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const
{
Powers powerType;
PowerType powerType;
if (GetMiscValue() == POWER_ALL)
powerType = target->GetPowerType();
else
powerType = Powers(GetMiscValue());
powerType = PowerType(GetMiscValue());
if (!target->IsAlive() || !target->GetMaxPower(powerType))
return;
@@ -6189,7 +6189,7 @@ void AuraEffect::HandleObsModPowerAuraTick(Unit* target, Unit* caster) const
void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) const
{
Powers powerType = Powers(GetMiscValue());
PowerType powerType = PowerType(GetMiscValue());
if (!target->IsAlive() || !target->GetMaxPower(powerType))
return;
@@ -6220,7 +6220,7 @@ void AuraEffect::HandlePeriodicEnergizeAuraTick(Unit* target, Unit* caster) cons
void AuraEffect::HandlePeriodicPowerBurnAuraTick(Unit* target, Unit* caster) const
{
Powers powerType = Powers(GetMiscValue());
PowerType powerType = PowerType(GetMiscValue());
if (!caster || !target->IsAlive() || target->GetPowerType() != powerType)
return;
@@ -6449,7 +6449,7 @@ void AuraEffect::HandleProcOnPowerAmountAuraProc(AuraApplication* aurApp, ProcEv
Unit* triggerTarget = eventInfo.GetProcTarget();
int32 powerAmountRequired = GetAmount();
Powers powerRequired = Powers(GetMiscValue());
PowerType powerRequired = PowerType(GetMiscValue());
if (!powerRequired || !powerAmountRequired)
{
+1 -1
View File
@@ -858,7 +858,7 @@ void Aura::Update(uint32 diff, Unit* caster)
{
m_timeCla += 1000 - diff;
Powers powertype = Powers(m_spellInfo->PowerType);
PowerType powertype = PowerType(m_spellInfo->PowerType);
if (powertype == POWER_HEALTH)
{
if (int32(caster->GetHealth()) > manaPerSecond)
+6 -6
View File
@@ -4574,7 +4574,7 @@ void Spell::SendSpellStart()
m_targets.Write(castData.Target);
if (castFlags & CAST_FLAG_POWER_LEFT_SELF)
castData.RemainingPower = ASSERT_NOTNULL(m_caster->ToUnit())->GetPower(Powers(m_spellInfo->PowerType));
castData.RemainingPower = ASSERT_NOTNULL(m_caster->ToUnit())->GetPower(PowerType(m_spellInfo->PowerType));
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
@@ -4694,7 +4694,7 @@ void Spell::SendSpellGo()
}
if (castFlags & CAST_FLAG_POWER_LEFT_SELF)
castData.RemainingPower = ASSERT_NOTNULL(m_caster->ToUnit())->GetPower((Powers)m_spellInfo->PowerType);
castData.RemainingPower = ASSERT_NOTNULL(m_caster->ToUnit())->GetPower((PowerType)m_spellInfo->PowerType);
if (castFlags & CAST_FLAG_RUNE_LIST) // rune cooldowns list
{
@@ -5286,7 +5286,7 @@ void Spell::TakePower()
return;
}
Powers powerType = Powers(m_spellInfo->PowerType);
PowerType powerType = PowerType(m_spellInfo->PowerType);
if (unitCaster->GetTypeId() == TYPEID_PLAYER && m_spellInfo->HasAttribute(SPELL_ATTR1_DISCOUNT_POWER_ON_MISS))
{
ObjectGuid targetGUID = m_targets.GetUnitTargetGUID();
@@ -6146,7 +6146,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
// Can be area effect, Check only for players and not check if target - caster (spell can have multiply drain/burn effects)
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (Unit* target = m_targets.GetUnitTarget())
if (target != m_caster && target->GetPowerType() != Powers(m_spellInfo->Effects[i].MiscValue))
if (target != m_caster && target->GetPowerType() != PowerType(m_spellInfo->Effects[i].MiscValue))
return SPELL_FAILED_BAD_TARGETS;
break;
}
@@ -7122,7 +7122,7 @@ SpellCastResult Spell::CheckPower() const
}
// Check power amount
Powers powerType = Powers(m_spellInfo->PowerType);
PowerType powerType = PowerType(m_spellInfo->PowerType);
if (int32(unitCaster->GetPower(powerType)) < m_powerCost)
return SPELL_FAILED_NO_POWER;
else
@@ -7188,7 +7188,7 @@ SpellCastResult Spell::CheckItems(uint32* param1 /*= nullptr*/, uint32* param2 /
continue;
}
Powers power = Powers(m_spellInfo->Effects[i].MiscValue);
PowerType power = PowerType(m_spellInfo->Effects[i].MiscValue);
if (m_targets.GetUnitTarget()->GetPower(power) == m_targets.GetUnitTarget()->GetMaxPower(power))
{
failReason = SPELL_FAILED_ALREADY_AT_FULL_POWER;
+4 -4
View File
@@ -1055,7 +1055,7 @@ void Spell::EffectPowerDrain(SpellEffIndex effIndex)
if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
return;
Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue);
PowerType powerType = PowerType(m_spellInfo->Effects[effIndex].MiscValue);
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || damage < 0)
return;
@@ -1127,7 +1127,7 @@ void Spell::EffectPowerBurn(SpellEffIndex effIndex)
if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
return;
Powers powerType = Powers(m_spellInfo->Effects[effIndex].MiscValue);
PowerType powerType = PowerType(m_spellInfo->Effects[effIndex].MiscValue);
if (!unitTarget || !unitTarget->IsAlive() || unitTarget->GetPowerType() != powerType || damage < 0)
return;
@@ -1576,7 +1576,7 @@ void Spell::EffectEnergize(SpellEffIndex effIndex)
if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
return;
Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
PowerType power = PowerType(m_spellInfo->Effects[effIndex].MiscValue);
if (unitTarget->GetMaxPower(power) == 0)
return;
@@ -1637,7 +1637,7 @@ void Spell::EffectEnergizePct(SpellEffIndex effIndex)
if (m_spellInfo->Effects[effIndex].MiscValue < 0 || m_spellInfo->Effects[effIndex].MiscValue >= int8(MAX_POWERS))
return;
Powers power = Powers(m_spellInfo->Effects[effIndex].MiscValue);
PowerType power = PowerType(m_spellInfo->Effects[effIndex].MiscValue);
uint32 maxPower = unitTarget->GetMaxPower(power);
if (!maxPower)
return;
+2 -2
View File
@@ -3654,7 +3654,7 @@ int32 SpellInfo::CalcPowerCost(WorldObject const* caster, SpellSchoolMask school
return unitCaster->GetHealth();
// Else drain all power
if (PowerType < MAX_POWERS)
return unitCaster->GetPower(Powers(PowerType));
return unitCaster->GetPower(static_cast<::PowerType>(PowerType));
TC_LOG_ERROR("spells", "SpellInfo::CalcPowerCost: Unknown power type '%d' in spell %d", PowerType, Id);
return 0;
@@ -3693,7 +3693,7 @@ int32 SpellInfo::CalcPowerCost(WorldObject const* caster, SpellSchoolMask school
case POWER_RAGE:
case POWER_FOCUS:
case POWER_ENERGY:
ressource = unitCaster->GetMaxPower(Powers(PowerType));
ressource = unitCaster->GetMaxPower(static_cast<::PowerType>(PowerType));
break;
case POWER_RUNE:
case POWER_RUNIC_POWER:
+2 -2
View File
@@ -132,7 +132,7 @@ enum MiscSpells
class PowerCheck
{
public:
explicit PowerCheck(Powers const power) : _power(power) { }
explicit PowerCheck(PowerType const power) : _power(power) { }
bool operator()(WorldObject* obj) const
{
@@ -143,7 +143,7 @@ class PowerCheck
}
private:
Powers const _power;
PowerType const _power;
};
class RaidCheck
+1 -1
View File
@@ -238,7 +238,7 @@ enum Stats
#define MAX_STATS 5
enum Powers
enum PowerType
{
POWER_MANA = 0,
POWER_RAGE = 1,