diff options
| author | ccrs <ccrs@users.noreply.github.com> | 2019-07-01 21:36:32 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-13 00:42:20 +0100 |
| commit | 4e6c59dca78ce563c327ea3106d0ff6786b1e127 (patch) | |
| tree | 11baa861d6e0eda35d4d73feba91a79c1bae788d /src/server/game/Entities/Unit | |
| parent | b8d675eba761a5616c7d69a78851ea61af61f4f6 (diff) | |
Core/Unit: rename several getters to follow codestyle
uint8 GetLevel()
uint8 GetLevelForTarget(WorldObject const* /*target*/)
void SetLevel(uint8 lvl)
uint8 GetRace()
uint32 GetRaceMask()
uint8 GetClass()
uint32 GetClassMask()
uint8 GetGender()
(cherry picked from commit 5c09ff51f7015b775def8d5cc1f678eaef37200f)
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/StatSystem.cpp | 24 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 44 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 16 |
3 files changed, 42 insertions, 42 deletions
diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index c85f50f8692..f86e2740df3 100644 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -268,7 +268,7 @@ float Player::GetHealthBonusFromStamina() const { // Taken from PaperDollFrame.lua - 6.0.3.19085 float ratio = 10.0f; - if (GtHpPerStaEntry const* hpBase = sHpPerStaGameTable.GetRow(getLevel())) + if (GtHpPerStaEntry const* hpBase = sHpPerStaGameTable.GetRow(GetLevel())) ratio = hpBase->Health; float stamina = GetStat(STAT_STAMINA); @@ -283,7 +283,7 @@ Stats Player::GetPrimaryStat() const if (ChrSpecializationEntry const* specialization = sChrSpecializationStore.LookupEntry(GetPrimarySpecialization())) return specialization->PrimaryStatPriority; - return sChrClassesStore.AssertEntry(getClass())->PrimaryStatPriority; + return sChrClassesStore.AssertEntry(GetClass())->PrimaryStatPriority; }(); if (primaryStatPriority >= 4) @@ -309,7 +309,7 @@ void Player::UpdateMaxHealth() uint32 Player::GetPowerIndex(Powers power) const { - return sDB2Manager.GetPowerIndexByClass(power, getClass()); + return sDB2Manager.GetPowerIndexByClass(power, GetClass()); } void Player::UpdateMaxPower(Powers power) @@ -331,9 +331,9 @@ void Player::UpdateMaxPower(Powers power) void Player::UpdateAttackPowerAndDamage(bool ranged) { float val2 = 0.0f; - float level = float(getLevel()); + float level = float(GetLevel()); - ChrClassesEntry const* entry = sChrClassesStore.AssertEntry(getClass()); + ChrClassesEntry const* entry = sChrClassesStore.AssertEntry(GetClass()); UnitMods unitMod = ranged ? UNIT_MOD_ATTACK_POWER_RANGED : UNIT_MOD_ATTACK_POWER; if (!HasAuraType(SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT)) @@ -562,7 +562,7 @@ void Player::UpdateVersatilityDamageDone() // No proof that CR_VERSATILITY_DAMAGE_DONE is allways = ActivePlayerData::Versatility SetUpdateFieldValue(m_values.ModifyValue(&Player::m_activePlayerData).ModifyValue(&UF::ActivePlayerData::Versatility), m_activePlayerData->CombatRatings[CR_VERSATILITY_DAMAGE_DONE]); - if (getClass() == CLASS_HUNTER) + if (GetClass() == CLASS_HUNTER) UpdateDamagePhysical(RANGED_ATTACK); else UpdateDamagePhysical(BASE_ATTACK); @@ -640,7 +640,7 @@ void Player::UpdateParryPercentage() { // No parry float value = 0.0f; - uint32 pclass = getClass() - 1; + uint32 pclass = GetClass() - 1; if (CanParry() && parry_cap[pclass] > 0.0f) { float nondiminishing = 5.0f; @@ -650,7 +650,7 @@ void Player::UpdateParryPercentage() nondiminishing += GetTotalAuraModifier(SPELL_AURA_MOD_PARRY_PERCENT); // apply diminishing formula to diminishing parry chance - value = CalculateDiminishingReturns(parry_cap, getClass(), nondiminishing, diminishing); + value = CalculateDiminishingReturns(parry_cap, GetClass(), nondiminishing, diminishing); if (sWorld->getBoolConfig(CONFIG_STATS_LIMITS_ENABLE)) value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_PARRY) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_PARRY) : value; @@ -685,7 +685,7 @@ void Player::UpdateDodgePercentage() diminishing += GetRatingBonusValue(CR_DODGE); // apply diminishing formula to diminishing dodge chance - float value = CalculateDiminishingReturns(dodge_cap, getClass(), nondiminishing, diminishing); + float value = CalculateDiminishingReturns(dodge_cap, GetClass(), nondiminishing, diminishing); if (sWorld->getBoolConfig(CONFIG_STATS_LIMITS_ENABLE)) value = value > sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) ? sWorld->getFloatConfig(CONFIG_STATS_LIMITS_DODGE) : value; @@ -804,7 +804,7 @@ void Player::UpdateManaRegen() // Get base of Mana Pool in sBaseMPGameTable uint32 basemana = 0; - sObjectMgr->GetPlayerClassLevelInfo(getClass(), getLevel(), basemana); + sObjectMgr->GetPlayerClassLevelInfo(GetClass(), GetLevel(), basemana); float base_regen = basemana / 100.f; base_regen += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_POWER_REGEN, POWER_MANA); @@ -821,7 +821,7 @@ void Player::UpdateManaRegen() void Player::UpdateAllRunesRegen() { - if (getClass() != CLASS_DEATH_KNIGHT) + if (GetClass() != CLASS_DEATH_KNIGHT) return; uint32 runeIndex = GetPowerIndex(POWER_RUNES); @@ -1047,7 +1047,7 @@ bool Guardian::UpdateStats(Stats stat) //warlock's and mage's pets gain 30% of owner's intellect else if (stat == STAT_INTELLECT) { - if (owner->getClass() == CLASS_WARLOCK || owner->getClass() == CLASS_MAGE) + if (owner->GetClass() == CLASS_WARLOCK || owner->GetClass() == CLASS_MAGE) { ownersBonus = CalculatePct(owner->GetStat(stat), 30); value += ownersBonus; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index ebb7d809331..cd09b420779 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1075,7 +1075,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama if (blocked) { // double blocked amount if block is critical - uint32 value = victim->GetBlockPercent(getLevel()); + uint32 value = victim->GetBlockPercent(GetLevel()); if (victim->isBlockCritical()) value *= 2; // double blocked percent damageInfo->blocked = CalculatePct(damage, value); @@ -1290,7 +1290,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, CalcDamageInfo* damageInfo, Weapon damageInfo->TargetState = VICTIMSTATE_HIT; damageInfo->HitInfo |= HITINFO_BLOCK; // 30% damage blocked, double blocked amount if block is critical - damageInfo->Blocked = CalculatePct(damageInfo->Damage, damageInfo->Target->GetBlockPercent(getLevel())); + damageInfo->Blocked = CalculatePct(damageInfo->Damage, damageInfo->Target->GetBlockPercent(GetLevel())); if (damageInfo->Target->isBlockCritical()) damageInfo->Blocked *= 2; @@ -1302,7 +1302,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, CalcDamageInfo* damageInfo, Weapon { damageInfo->HitInfo |= HITINFO_GLANCING; damageInfo->TargetState = VICTIMSTATE_HIT; - int32 leveldif = int32(victim->getLevel()) - int32(getLevel()); + int32 leveldif = int32(victim->GetLevel()) - int32(GetLevel()); if (leveldif > 3) leveldif = 3; @@ -1410,7 +1410,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss) float chance = 20.0f; // there is a newbie protection, at level 10 just 7% base chance; assuming linear function - if (victim->getLevel() < 30) + if (victim->GetLevel() < 30) chance = 0.65f * victim->GetLevelForTarget(this) + 0.5f; uint32 const victimDefense = victim->GetMaxSkillValueForLevel(this); @@ -1568,7 +1568,7 @@ void Unit::HandleEmoteCommand(uint32 anim_id, Player* target /*=nullptr*/, Trini if (attacker) { attackerLevel = attacker->GetLevelForTarget(victim); - attackerClass = Classes(attacker->getClass()); + attackerClass = Classes(attacker->GetClass()); } // Expansion and ContentTuningID necessary? Does Player get a ContentTuningID too ? @@ -1678,7 +1678,7 @@ void Unit::HandleEmoteCommand(uint32 anim_id, Player* target /*=nullptr*/, Trini static uint32 const bossLevel = 83; static float const bossResistanceConstant = 510.0f; - uint32 level = caster ? victim->GetLevelForTarget(caster) : victim->getLevel(); + uint32 level = caster ? victim->GetLevelForTarget(caster) : victim->GetLevel(); float resistanceConstant = 0.0f; if (level == bossLevel) @@ -5282,7 +5282,7 @@ void Unit::UpdateDisplayPower() } else if (GetTypeId() == TYPEID_PLAYER) { - ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(getClass()); + ChrClassesEntry const* cEntry = sChrClassesStore.LookupEntry(GetClass()); if (cEntry && cEntry->DisplayPower < MAX_POWERS) displayPower = Powers(cEntry->DisplayPower); } @@ -5292,7 +5292,7 @@ void Unit::UpdateDisplayPower() { if (PowerDisplayEntry const* powerDisplay = sPowerDisplayStore.LookupEntry(vehicle->GetVehicleInfo()->PowerDisplayID[0])) displayPower = Powers(powerDisplay->ActualType); - else if (getClass() == CLASS_ROGUE) + else if (GetClass() == CLASS_ROGUE) displayPower = POWER_ENERGY; } else if (Pet* pet = ToPet()) @@ -6667,7 +6667,7 @@ float Unit::SpellCritChanceTaken(Unit const* caster, Spell* spell, AuraEffect co // Spell crit suppression if (GetTypeId() == TYPEID_UNIT) { - int32 const levelDiff = static_cast<int32>(GetLevelForTarget(caster)) - caster->getLevel(); + int32 const levelDiff = static_cast<int32>(GetLevelForTarget(caster)) - caster->GetLevel(); crit_chance -= levelDiff * 1.0f; } } @@ -9581,7 +9581,7 @@ void Unit::ProcSkillsAndReactives(bool isVictim, Unit* procTarget, uint32 typeMa if (hitMask & PROC_HIT_DODGE) { // Update AURA_STATE on dodge - if (getClass() != CLASS_ROGUE) // skip Rogue Riposte + if (GetClass() != CLASS_ROGUE) // skip Rogue Riposte { ModifyAuraState(AURA_STATE_DEFENSIVE, true); StartReactiveTimer(REACTIVE_DEFENSE); @@ -10170,7 +10170,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id) return nullptr; } - uint8 level = creatureTarget->GetLevelForTarget(this) + 5 < getLevel() ? (getLevel() - 5) : creatureTarget->GetLevelForTarget(this); + uint8 level = creatureTarget->GetLevelForTarget(this) + 5 < GetLevel() ? (GetLevel() - 5) : creatureTarget->GetLevelForTarget(this); InitTamedPet(pet, level, spell_id); @@ -10188,7 +10188,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id) Pet* pet = new Pet(ToPlayer(), HUNTER_PET); - if (!pet->CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, getLevel(), spell_id)) + if (!pet->CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, GetLevel(), spell_id)) { delete pet; return nullptr; @@ -10932,7 +10932,7 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au AddUnitState(UNIT_STATE_POSSESSED); break; case CHARM_TYPE_CHARM: - if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) + if (GetTypeId() == TYPEID_UNIT && charmer->GetClass() == CLASS_WARLOCK) { CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate(); if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) @@ -11030,7 +11030,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) RemoveUnitFlag(UNIT_FLAG_POSSESSED); break; case CHARM_TYPE_CHARM: - if (GetTypeId() == TYPEID_UNIT && charmer->getClass() == CLASS_WARLOCK) + if (GetTypeId() == TYPEID_UNIT && charmer->GetClass() == CLASS_WARLOCK) { CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate(); if (cinfo && cinfo->type == CREATURE_TYPE_DEMON) @@ -11073,7 +11073,7 @@ void Unit::RemoveCharmedBy(Unit* charmer) void Unit::RestoreFaction() { if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->setFactionForRace(getRace()); + ToPlayer()->setFactionForRace(GetRace()); else { if (HasUnitTypeMask(UNIT_MASK_MINION)) @@ -11499,7 +11499,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const if (ShapeshiftForm(artifactAppearance->OverrideShapeshiftFormID) == form) return artifactAppearance->OverrideShapeshiftDisplayID; - if (ShapeshiftFormModelData const* formModelData = sDB2Manager.GetShapeshiftFormModelData(getRace(), thisPlayer->GetNativeSex(), form)) + if (ShapeshiftFormModelData const* formModelData = sDB2Manager.GetShapeshiftFormModelData(GetRace(), thisPlayer->GetNativeSex(), form)) { bool useRandom = false; switch (form) @@ -11524,7 +11524,7 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const if (ChrCustomizationDisplayInfoEntry const* displayInfo = formModelData->Displays[i]) { ChrCustomizationReqEntry const* choiceReq = sChrCustomizationReqStore.LookupEntry((*formModelData->Choices)[i]->ChrCustomizationReqID); - if (!choiceReq || thisPlayer->GetSession()->MeetsChrCustomizationReq(choiceReq, Classes(getClass()), false, + if (!choiceReq || thisPlayer->GetSession()->MeetsChrCustomizationReq(choiceReq, Classes(GetClass()), false, MakeChrCustomizationChoiceRange(thisPlayer->m_playerData->Customizations))) displayIds.push_back(displayInfo->DisplayID); } @@ -11569,13 +11569,13 @@ uint32 Unit::GetModelForForm(ShapeshiftForm form, uint32 spellId) const return formEntry->CreatureDisplayID[0]; else { - if (Player::TeamForRace(getRace()) == ALLIANCE) + if (Player::TeamForRace(GetRace()) == ALLIANCE) modelid = formEntry->CreatureDisplayID[0]; else modelid = formEntry->CreatureDisplayID[1]; // If the player is horde but there are no values for the horde modelid - take the alliance modelid - if (!modelid && Player::TeamForRace(getRace()) == HORDE) + if (!modelid && Player::TeamForRace(GetRace()) == HORDE) modelid = formEntry->CreatureDisplayID[0]; } } @@ -13029,7 +13029,7 @@ void Unit::Talk(uint32 textId, ChatMsg msgType, float textRange, WorldObject con return; } - Trinity::BroadcastTextBuilder builder(this, msgType, textId, getGender(), target); + Trinity::BroadcastTextBuilder builder(this, msgType, textId, GetGender(), target); Trinity::LocalizedDo<Trinity::BroadcastTextBuilder> localizer(builder); Trinity::PlayerDistWorker<Trinity::LocalizedDo<Trinity::BroadcastTextBuilder> > worker(this, textRange, localizer); Cell::VisitWorldObjects(this, worker, textRange); @@ -13064,7 +13064,7 @@ void Unit::Whisper(uint32 textId, Player* target, bool isBossWhisper /*= false*/ LocaleConstant locale = target->GetSession()->GetSessionDbLocaleIndex(); WorldPackets::Chat::Chat packet; - packet.Initialize(isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, DB2Manager::GetBroadcastTextValue(bct, locale, getGender()), 0, "", locale); + packet.Initialize(isBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, DB2Manager::GetBroadcastTextValue(bct, locale, GetGender()), 0, "", locale); target->SendDirectMessage(packet.Write()); } @@ -13149,6 +13149,6 @@ std::string Unit::GetDebugInfo() const << std::boolalpha << "IsAIEnabled: " << IsAIEnabled() << " DeathState: " << std::to_string(getDeathState()) << " UnitMovementFlags: " << GetUnitMovementFlags() << " ExtraUnitMovementFlags: " << GetExtraUnitMovementFlags() - << " Class: " << std::to_string(getClass()); + << " Class: " << std::to_string(GetClass()); return sstr.str(); } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index ba205ddec2a..0c7fc42742b 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -851,16 +851,16 @@ class TC_GAME_API Unit : public WorldObject bool IsTotem() const { return (m_unitTypeMask & UNIT_MASK_TOTEM) != 0; } bool IsVehicle() const { return (m_unitTypeMask & UNIT_MASK_VEHICLE) != 0; } - uint8 getLevel() const { return uint8(m_unitData->Level); } - uint8 GetLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); } + uint8 GetLevel() const { return uint8(m_unitData->Level); } + uint8 GetLevelForTarget(WorldObject const* /*target*/) const override { return GetLevel(); } void SetLevel(uint8 lvl); - uint8 getRace() const { return m_unitData->Race; } + uint8 GetRace() const { return m_unitData->Race; } void SetRace(uint8 race) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Race), race); } - uint64 getRaceMask() const { return UI64LIT(1) << (getRace() - 1); } - uint8 getClass() const { return m_unitData->ClassId; } + uint64 GetRaceMask() const { return UI64LIT(1) << (GetRace() - 1); } + uint8 GetClass() const { return m_unitData->ClassId; } void SetClass(uint8 classId) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::ClassId), classId); } - uint32 getClassMask() const { return 1 << (getClass()-1); } - uint8 getGender() const { return m_unitData->Sex; } + uint32 GetClassMask() const { return 1 << (GetClass()-1); } + uint8 GetGender() const { return m_unitData->Sex; } void SetGender(uint8 sex) { SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::Sex), sex); } float GetStat(Stats stat) const { return float(m_unitData->Stats[stat]); } @@ -1011,7 +1011,7 @@ class TC_GAME_API Unit : public WorldObject void SetMeleeAnimKitId(uint16 animKitId); uint16 GetMeleeAnimKitId() const override { return _meleeAnimKitId; } - uint16 GetMaxSkillValueForLevel(Unit const* target = nullptr) const { return (target ? GetLevelForTarget(target) : getLevel()) * 5; } + uint16 GetMaxSkillValueForLevel(Unit const* target = nullptr) const { return (target ? GetLevelForTarget(target) : GetLevel()) * 5; } static void DealDamageMods(Unit const* attacker, Unit const* victim, uint32& damage, uint32* absorb); static uint32 DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage const* cleanDamage = nullptr, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = nullptr, bool durabilityLoss = true); static void Kill(Unit* attacker, Unit* victim, bool durabilityLoss = true, bool skipSettingDeathState = false); |
