Core/Misc: rename Stats to StatType

This commit is contained in:
Ovahlord committed 2026-06-10 10:24:10 +02:00
1 parent 490ed994bc
commit c1c7dc5ef9
13 files changed
+95 -40

No files matched your search

+1 -1
View File
@@ -194,7 +194,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool UpdateEntry(uint32 entry, CreatureData const* data = nullptr, bool updateLevel = true);
bool UpdateStats(Stats stat) override;
bool UpdateStats(StatType stat) override;
bool UpdateAllStats() override;
void UpdateResistances(uint32 school) override;
void UpdateArmor() override;
@@ -119,7 +119,7 @@ class TC_GAME_API Guardian : public Minion
bool InitStatsForLevel(uint8 level);
void InitSummon() override;
bool UpdateStats(Stats stat) override;
bool UpdateStats(StatType stat) override;
bool UpdateAllStats() override;
void UpdateResistances(uint32 school) override;
void UpdateArmor() override;
@@ -129,7 +129,7 @@ class TC_GAME_API Guardian : public Minion
void UpdateDamagePhysical(WeaponAttackType attType) override;
int32 GetBonusDamage() const { return m_bonusSpellDamage; }
float GetBonusStatFromOwner(Stats stat) const { return m_statFromOwner[stat]; }
float GetBonusStatFromOwner(StatType stat) const { return m_statFromOwner[stat]; }
void SetBonusDamage(int32 damage);
protected:
int32 m_bonusSpellDamage;
+1 -1
View File
@@ -774,7 +774,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetStatFlatModifier(UNIT_MOD_ARMOR, BASE_VALUE, float(pInfo->armor));
for (uint8 stat = 0; stat < MAX_STATS; ++stat)
SetCreateStat(Stats(stat), float(pInfo->stats[stat]));
SetCreateStat(StatType(stat), float(pInfo->stats[stat]));
}
else // not exist in DB, use some default fake data
{
+6 -6
View File
@@ -2233,7 +2233,7 @@ void Player::GiveLevel(uint8 level)
packet.PowerDelta[5] = 0;
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
packet.StatDelta[i] = int32(info.stats[i]) - GetCreateStat(Stats(i));
packet.StatDelta[i] = int32(info.stats[i]) - GetCreateStat(StatType(i));
SendDirectMessage(packet.Write());
@@ -2250,7 +2250,7 @@ void Player::GiveLevel(uint8 level)
// save base values (bonuses already included in stored stats
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
SetCreateStat(Stats(i), info.stats[i]);
SetCreateStat(StatType(i), info.stats[i]);
SetCreateHealth(basehp);
SetCreateMana(basemana);
@@ -2379,10 +2379,10 @@ void Player::InitStatsForLevel(bool reapplyMods)
// save base values (bonuses already included in stored stats
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
SetCreateStat(Stats(i), info.stats[i]);
SetCreateStat(StatType(i), info.stats[i]);
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
SetStat(Stats(i), info.stats[i]);
SetStat(StatType(i), info.stats[i]);
SetCreateHealth(basehp);
@@ -5043,7 +5043,7 @@ void Player::UpdateRating(CombatRating cr)
AuraEffectList const& modRatingFromStat = GetAuraEffectsByType(SPELL_AURA_MOD_RATING_FROM_STAT);
for (AuraEffectList::const_iterator i = modRatingFromStat.begin(); i != modRatingFromStat.end(); ++i)
if ((*i)->GetMiscValue() & (1<<cr))
amount += int32(CalculatePct(GetStat(Stats((*i)->GetMiscValueB())), (*i)->GetAmount()));
amount += int32(CalculatePct(GetStat(StatType((*i)->GetMiscValueB())), (*i)->GetAmount()));
if (amount < 0)
amount = 0;
SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + AsUnderlyingType(cr), uint32(amount));
@@ -20003,7 +20003,7 @@ void Player::_SaveStats(CharacterDatabaseTransaction& trans) const
stmt->setUInt32(index++, GetMaxPower(PowerType(i)));
for (uint8 i = 0; i < MAX_STATS; ++i)
stmt->setUInt32(index++, GetStat(Stats(i)));
stmt->setUInt32(index++, GetStat(StatType(i)));
for (int i = 0; i < MAX_SPELL_SCHOOL; ++i)
stmt->setUInt32(index++, GetResistance(SpellSchools(i)));
+1 -1
View File
@@ -1742,7 +1742,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
float GetHealthBonusFromStamina();
float GetManaBonusFromIntellect();
bool UpdateStats(Stats stat) override;
bool UpdateStats(StatType stat) override;
bool UpdateAllStats() override;
void ApplySpellPenetrationBonus(int32 amount, bool apply);
void UpdateResistances(uint32 school) override;
+1 -1
View File
@@ -52,7 +52,7 @@ class TC_GAME_API Totem : public Minion
void SetTotemDuration(uint32 duration) { m_duration = duration; }
TotemType GetTotemType() const { return m_type; }
bool UpdateStats(Stats /*stat*/) override { return true; }
bool UpdateStats(StatType /*stat*/) override { return true; }
bool UpdateAllStats() override { return true; }
void UpdateResistances(uint32 /*school*/) override { }
void UpdateArmor() override { }
+8 -8
View File
@@ -224,7 +224,7 @@ void Unit::UpdatePowerRegeneration(PowerType powerType)
######## ########
#######################################*/
bool Player::UpdateStats(Stats stat)
bool Player::UpdateStats(StatType stat)
{
if (stat > STAT_SPIRIT)
return false;
@@ -270,7 +270,7 @@ bool Player::UpdateStats(Stats stat)
uint32 mask = 0;
AuraEffectList const& modRatingFromStat = GetAuraEffectsByType(SPELL_AURA_MOD_RATING_FROM_STAT);
for (AuraEffectList::const_iterator i = modRatingFromStat.begin(); i != modRatingFromStat.end(); ++i)
if (Stats((*i)->GetMiscValueB()) == stat)
if (StatType((*i)->GetMiscValueB()) == stat)
mask |= (*i)->GetMiscValue();
if (mask)
{
@@ -338,8 +338,8 @@ bool Player::UpdateAllStats()
{
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
{
float value = GetTotalStatValue(Stats(i));
SetStat(Stats(i), int32(value));
float value = GetTotalStatValue(StatType(i));
SetStat(StatType(i), int32(value));
}
UpdateArmor();
@@ -396,7 +396,7 @@ void Player::UpdateArmor()
for (AuraEffectList::const_iterator i = mResbyIntellect.begin(); i != mResbyIntellect.end(); ++i)
{
if ((*i)->GetMiscValue() & SPELL_SCHOOL_MASK_NORMAL)
value += CalculatePct(GetStat(Stats((*i)->GetMiscValueB())), (*i)->GetAmount());
value += CalculatePct(GetStat(StatType((*i)->GetMiscValueB())), (*i)->GetAmount());
}
value *= GetPctModifierValue(unitMod, TOTAL_PCT);
@@ -939,7 +939,7 @@ void Player::_RemoveAllStatBonuses()
######## ########
#######################################*/
bool Creature::UpdateStats(Stats /*stat*/)
bool Creature::UpdateStats(StatType /*stat*/)
{
return true;
}
@@ -1096,7 +1096,7 @@ void Creature::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized,
######## ########
#######################################*/
bool Guardian::UpdateStats(Stats stat)
bool Guardian::UpdateStats(StatType stat)
{
if (stat >= MAX_STATS)
return false;
@@ -1138,7 +1138,7 @@ bool Guardian::UpdateAllStats()
UpdateMaxHealth();
for (uint8 i = STAT_STRENGTH; i < MAX_STATS; ++i)
UpdateStats(Stats(i));
UpdateStats(StatType(i));
for (uint8 i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(PowerType(i));
+19
View File
@@ -0,0 +1,19 @@
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "Stats.h"
+36
View File
@@ -0,0 +1,36 @@
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _Stats_h__
#define _Stats_h__
#include "Define.h"
class Unit;
class TC_GAME_API //Stats
{
public:
Stats() = delete;
Stats(Stats const&) = delete;
Stats& operator=(Stats const&) = delete;
~Stats();
explicit Stats(Unit* owner);
};
#endif // _Stats_h__
+6 -6
View File
@@ -4815,7 +4815,7 @@ void Unit::InitStatBuffMods()
SetFloatValue(UNIT_FIELD_NEGSTAT0+i, 0);
}
void Unit::UpdateStatBuffMod(Stats stat)
void Unit::UpdateStatBuffMod(StatType stat)
{
float modPos = 0.0f;
float modNeg = 0.0f;
@@ -6740,7 +6740,7 @@ int32 Unit::SpellBaseDamageBonusDone(SpellSchoolMask schoolMask, bool withSpellP
if ((aurEff->GetMiscValue() & schoolMask) != 0)
{
// stat used stored in miscValueB for this aura
Stats const usedStat = static_cast<Stats>(aurEff->GetMiscValueB());
StatType const usedStat = static_cast<StatType>(aurEff->GetMiscValueB());
DoneAdvertisedBenefit += static_cast<int32>(CalculatePct(GetStat(usedStat), aurEff->GetAmount()));
}
}
@@ -7326,7 +7326,7 @@ int32 Unit::SpellBaseHealingBonusDone(SpellSchoolMask schoolMask, bool withSpell
for (AuraEffectList::const_iterator i = mHealingDoneOfStatPercent.begin(); i != mHealingDoneOfStatPercent.end(); ++i)
{
// stat used dependent from misc value (stat index)
Stats usedStat = Stats((*i)->GetSpellInfo()->Effects[(*i)->GetEffIndex()].MiscValue);
StatType usedStat = StatType((*i)->GetSpellInfo()->Effects[(*i)->GetEffIndex()].MiscValue);
advertisedBenefit += int32(CalculatePct(GetStat(usedStat), (*i)->GetAmount()));
}
@@ -9101,7 +9101,7 @@ void Unit::UpdateAllDamagePctDoneMods()
UpdateDamagePctDoneMods(WeaponAttackType(i));
}
float Unit::GetTotalStatValue(Stats stat) const
float Unit::GetTotalStatValue(StatType stat) const
{
UnitMods unitMod = UnitMods(UNIT_MOD_STAT_START + AsUnderlyingType(stat));
@@ -9150,9 +9150,9 @@ SpellSchools Unit::GetSpellSchoolByAuraGroup(UnitMods unitMod) const
return school;
}
Stats Unit::GetStatByAuraGroup(UnitMods unitMod) const
StatType Unit::GetStatByAuraGroup(UnitMods unitMod) const
{
Stats stat = STAT_STRENGTH;
StatType stat = STAT_STRENGTH;
switch (unitMod)
{
+10 -10
View File
@@ -774,8 +774,8 @@ class TC_GAME_API Unit : public WorldObject
uint32 getClassMask() const { return 1 << (getClass()-1); }
uint8 getGender() const { return GetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER); }
float GetStat(Stats stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0 + AsUnderlyingType(stat))); }
void SetStat(Stats stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0 + AsUnderlyingType(stat), val); }
float GetStat(StatType stat) const { return float(GetUInt32Value(UNIT_FIELD_STAT0 + AsUnderlyingType(stat))); }
void SetStat(StatType stat, int32 val) { SetStatInt32Value(UNIT_FIELD_STAT0 + AsUnderlyingType(stat), val); }
uint32 GetArmor() const { return GetResistance(SPELL_SCHOOL_NORMAL); }
void SetArmor(int32 val) { SetResistance(SPELL_SCHOOL_NORMAL, val); }
@@ -1281,16 +1281,16 @@ class TC_GAME_API Unit : public WorldObject
void UpdateResistanceBuffModsMod(SpellSchools school);
void InitStatBuffMods();
void UpdateStatBuffMod(Stats stat);
void SetCreateStat(Stats stat, float val) { m_createStats[stat] = val; }
void UpdateStatBuffMod(StatType stat);
void SetCreateStat(StatType stat, float val) { m_createStats[stat] = val; }
void SetCreateHealth(uint32 val) { SetUInt32Value(UNIT_FIELD_BASE_HEALTH, val); }
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(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]; }
float GetPosStat(StatType stat) const { return GetFloatValue(UNIT_FIELD_POSSTAT0 + AsUnderlyingType(stat)); }
float GetNegStat(StatType stat) const { return GetFloatValue(UNIT_FIELD_NEGSTAT0 + AsUnderlyingType(stat)); }
float GetCreateStat(StatType stat) const { return m_createStats[stat]; }
ObjectGuid GetChannelObjectGuid() const { return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); }
void SetChannelObjectGuid(ObjectGuid guid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, guid); }
@@ -1360,14 +1360,14 @@ class TC_GAME_API Unit : public WorldObject
void UpdateDamagePctDoneMods(WeaponAttackType attackType);
void UpdateAllDamagePctDoneMods();
float GetTotalStatValue(Stats stat) const;
float GetTotalStatValue(StatType stat) const;
float GetTotalAuraModValue(UnitMods unitMod) const;
SpellSchools GetSpellSchoolByAuraGroup(UnitMods unitMod) const;
Stats GetStatByAuraGroup(UnitMods unitMod) const;
StatType GetStatByAuraGroup(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;
virtual bool UpdateStats(StatType stat) = 0;
virtual bool UpdateAllStats() = 0;
virtual void UpdateResistances(uint32 school) = 0;
virtual void UpdateAllResistances();
@@ -3587,12 +3587,12 @@ void AuraEffect::HandleAuraModStat(AuraApplication const* aurApp, uint8 mode, bo
{
target->HandleStatFlatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(spellGroupVal), !apply);
if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet())
target->UpdateStatBuffMod(Stats(i));
target->UpdateStatBuffMod(StatType(i));
}
target->HandleStatFlatModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_VALUE, float(GetAmount()), apply);
if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet())
target->UpdateStatBuffMod(Stats(i));
target->UpdateStatBuffMod(StatType(i));
}
}
}
@@ -3747,7 +3747,7 @@ void AuraEffect::HandleModTotalPercentStat(AuraApplication const* aurApp, uint8
target->SetStatPctModifier(UnitMods(UNIT_MOD_STAT_START + i), TOTAL_PCT, amount);
if (target->GetTypeId() == TYPEID_PLAYER || target->IsPet())
target->UpdateStatBuffMod(Stats(i));
target->UpdateStatBuffMod(StatType(i));
}
}
+1 -1
View File
@@ -227,7 +227,7 @@ enum MoneyConstants
GOLD = SILVER*100
};
enum Stats
enum StatType
{
STAT_STRENGTH = 0,
STAT_AGILITY = 1,