From ae61d739948132d74e51f82f3375dfcc913bc6b3 Mon Sep 17 00:00:00 2001 From: schell244 Date: Fri, 20 Dec 2024 07:23:27 +0100 Subject: [PATCH] Some more code cleanup and refactoring (#2842) --- src/game/Battlegrounds/BattleGround.cpp | 5 +++-- src/game/Battlegrounds/BattleGround.h | 2 +- src/game/LootMgr.cpp | 1 - src/game/LootMgr.h | 4 ++-- src/game/Maps/MapPersistentStateMgr.h | 2 +- src/game/Maps/ZoneScriptMgr.cpp | 4 ++-- src/game/Maps/ZoneScriptMgr.h | 4 ++-- src/game/ObjectGuid.h | 19 ++++++---------- src/game/Objects/Creature.cpp | 2 +- src/game/Objects/Creature.h | 12 +++++----- src/game/Objects/Object.h | 10 ++++----- src/game/Objects/Pet.h | 2 +- src/game/Objects/Player.cpp | 24 ++++++++++---------- src/game/Objects/Player.h | 30 ++++++++++++------------- src/game/Objects/TemporarySummon.h | 2 +- src/game/Objects/Unit.h | 3 +-- src/game/OutdoorPvP/OutdoorPvPEP.cpp | 2 +- src/game/Transports/Transport.h | 2 +- src/game/World.h | 10 ++++----- src/game/WorldSession.h | 6 ++--- src/shared/WheatyExceptionReport.cpp | 2 +- src/shared/WheatyExceptionReport.h | 2 +- 22 files changed, 72 insertions(+), 78 deletions(-) diff --git a/src/game/Battlegrounds/BattleGround.cpp b/src/game/Battlegrounds/BattleGround.cpp index 6bb6ba14d4f..9fab08ea83a 100644 --- a/src/game/Battlegrounds/BattleGround.cpp +++ b/src/game/Battlegrounds/BattleGround.cpp @@ -757,9 +757,10 @@ uint32 BattleGround::GetBonusHonorFromKill(uint32 kills) const return kills * (uint32)MaNGOS::Honor::GetHonorGain(GetMaxLevel(), GetMaxLevel(), 1); } -float BattleGround::GetHonorModifier() { +float BattleGround::GetHonorModifier() const +{ // If the game ends in under one hour, less Bonus Honor will be earned from control of mines, graveyards and for the General kill (win). - float elapsed = (float)GetStartTime() / IN_MILLISECONDS / HOUR; + float const elapsed = (float)GetStartTime() / (float)IN_MILLISECONDS / (float)HOUR; return elapsed < 1.0f ? pow(60, elapsed - 1) : 1.0f; } diff --git a/src/game/Battlegrounds/BattleGround.h b/src/game/Battlegrounds/BattleGround.h index 8633862503c..c877b864af8 100644 --- a/src/game/Battlegrounds/BattleGround.h +++ b/src/game/Battlegrounds/BattleGround.h @@ -119,7 +119,7 @@ class BattleGround BattleGroundWinner GetWinner() const { return m_winner; } uint32 GetBattlemasterEntry() const; uint32 GetBonusHonorFromKill(uint32 kills) const; - float GetHonorModifier(); + float GetHonorModifier() const; // Set methods: void SetName(char const* name) { m_name = name; } diff --git a/src/game/LootMgr.cpp b/src/game/LootMgr.cpp index 26964ca9842..b9a5a8cb8f6 100644 --- a/src/game/LootMgr.cpp +++ b/src/game/LootMgr.cpp @@ -63,7 +63,6 @@ class LootTemplate::LootGroup // A set of loot def float TotalChance() const; // Overall chance for the group void Verify(LootStore const& lootstore, uint32 id, uint32 group_id) const; - void CollectLootIds(LootIdSet& set) const; void CheckLootRefs(LootIdSet* ref_set) const; private: LootStoreItemList ExplicitlyChanced; // Entries with chances defined in DB diff --git a/src/game/LootMgr.h b/src/game/LootMgr.h index 94ca766a42e..087fd66743a 100644 --- a/src/game/LootMgr.h +++ b/src/game/LootMgr.h @@ -217,7 +217,7 @@ class LootTemplate public: // Adds an entry to the group (at loading stage) void AddEntry(LootStoreItem& item); - // Rolls for every item in the template and adds the rolled items the the loot + // Rolls for every item in the template and adds the rolled items to the loot void Process(Loot& loot, LootStore const& store, bool rate, uint8 GroupId = 0) const; // True if template includes at least 1 quest drop entry @@ -238,7 +238,7 @@ class LootTemplate class LootValidatorRef : public Reference { public: - LootValidatorRef() {} + LootValidatorRef() = default; void targetObjectDestroyLink() override {} void sourceObjectDestroyLink() override {} }; diff --git a/src/game/Maps/MapPersistentStateMgr.h b/src/game/Maps/MapPersistentStateMgr.h index 1d2fb21ee61..91382f928d1 100644 --- a/src/game/Maps/MapPersistentStateMgr.h +++ b/src/game/Maps/MapPersistentStateMgr.h @@ -276,7 +276,7 @@ struct DungeonResetEvent DungeonResetEvent(ResetEventType t, uint32 _mapid, uint32 _instanceid) : type(t), mapId(_mapid), instanceId(_instanceid) {} - bool operator == (DungeonResetEvent const& e) { return e.mapId == mapId && e.instanceId == instanceId; } + bool operator==(DungeonResetEvent const& e) const { return e.mapId == mapId && e.instanceId == instanceId; } }; typedef std::map > ResetTimeMapType; diff --git a/src/game/Maps/ZoneScriptMgr.cpp b/src/game/Maps/ZoneScriptMgr.cpp index 4518909e090..e350ff75913 100644 --- a/src/game/Maps/ZoneScriptMgr.cpp +++ b/src/game/Maps/ZoneScriptMgr.cpp @@ -102,7 +102,7 @@ void ZoneScriptMgr::HandlePlayerLeaveZone(Player* plr, uint32 zoneid) //sLog.Out(LOG_BASIC, LOG_LVL_DEBUG, "Player %u left ZoneScript", plr->GetGUIDLow()); } -ZoneScript * ZoneScriptMgr::GetZoneScriptToZoneId(uint32 zoneid) +ZoneScript* ZoneScriptMgr::GetZoneScriptToZoneId(uint32 zoneid) { ZoneScriptsMap::iterator itr = m_ZoneScriptsMap.find(zoneid); if (itr == m_ZoneScriptsMap.end()) @@ -135,7 +135,7 @@ bool ZoneScriptMgr::HandleCustomSpell(Player* plr, uint32 spellId, GameObject* g return false; } -ZoneScript * ZoneScriptMgr::GetZoneScript(uint32 zoneId) +ZoneScript* ZoneScriptMgr::GetZoneScript(uint32 zoneId) { ZoneScriptsMap::iterator itr = m_ZoneScriptsMap.find(zoneId); if (itr != m_ZoneScriptsMap.end()) diff --git a/src/game/Maps/ZoneScriptMgr.h b/src/game/Maps/ZoneScriptMgr.h index c2f82374c6e..86a0fcbef60 100644 --- a/src/game/Maps/ZoneScriptMgr.h +++ b/src/game/Maps/ZoneScriptMgr.h @@ -63,7 +63,7 @@ class ZoneScriptMgr void HandlePlayerLeaveZone(Player* plr, uint32 areaflag); // return assigned outdoor pvp - ZoneScript * GetZoneScriptToZoneId(uint32 zoneid); + ZoneScript* GetZoneScriptToZoneId(uint32 zoneid); // handle custom (non-exist in dbc) spell if registered bool HandleCustomSpell(Player* plr, uint32 spellId, GameObject* go); @@ -71,7 +71,7 @@ class ZoneScriptMgr // handle custom go if registered bool HandleOpenGo(Player* plr, uint64 guid); - ZoneScript * GetZoneScript(uint32 zoneId); + ZoneScript* GetZoneScript(uint32 zoneId); void AddZone(uint32 zoneid, ZoneScript * handle); diff --git a/src/game/ObjectGuid.h b/src/game/ObjectGuid.h index 9fc9d10ddd5..671ab8b9db1 100644 --- a/src/game/ObjectGuid.h +++ b/src/game/ObjectGuid.h @@ -240,19 +240,14 @@ class ObjectGuid uint64 m_guid; }; -namespace std { - - template <> - struct hash +template <> +struct std::hash +{ + std::size_t operator()(ObjectGuid const& k) const { - std::size_t operator()(ObjectGuid const& k) const - { - using std::hash; - return hash()(k.GetRawValue()); - } - }; - -} + return std::hash()(k.GetRawValue()); + } +}; typedef std::unordered_set ObjectGuidSet; typedef std::list GuidList; diff --git a/src/game/Objects/Creature.cpp b/src/game/Objects/Creature.cpp index 396b92d9d08..f1dd835c775 100644 --- a/src/game/Objects/Creature.cpp +++ b/src/game/Objects/Creature.cpp @@ -215,7 +215,7 @@ Creature::Creature(CreatureSubtype subtype) : Creature::~Creature() { - CleanupsBeforeDelete(); + Unit::CleanupsBeforeDelete(); m_vendorItemCounts.clear(); diff --git a/src/game/Objects/Creature.h b/src/game/Objects/Creature.h index 952e505cc59..7f7bb359e34 100644 --- a/src/game/Objects/Creature.h +++ b/src/game/Objects/Creature.h @@ -68,8 +68,8 @@ struct CreatureCreatePos class ThreatListProcesser { public: - ThreatListProcesser() {} - virtual ~ThreatListProcesser() {} + ThreatListProcesser() = default; + virtual ~ThreatListProcesser() = default; virtual bool Process(Unit* unit) = 0; }; @@ -126,7 +126,7 @@ class Creature : public Unit void SaveHomePosition() { SetHomePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); } void SetHomePosition(float x, float y, float z, float o); void GetHomePosition(float &x, float &y, float &z, float &o); - Position const& GetHomePosition() { return m_homePosition; } + Position const& GetHomePosition() const { return m_homePosition; } float GetHomePositionO() const { return m_homePosition.o; } void ResetHomePosition(); @@ -141,12 +141,12 @@ class Creature : public Unit void SetDefaultValuesFromStaticFlags(); CreatureSubtype GetSubtype() const { return m_subtype; } - bool IsPet() const { return m_subtype == CREATURE_SUBTYPE_PET; } + bool IsPet() const override { return m_subtype == CREATURE_SUBTYPE_PET; } bool IsTotem() const { return m_subtype == CREATURE_SUBTYPE_TOTEM; } Totem const* ToTotem() const { return IsTotem() ? reinterpret_cast(this) : nullptr; } Totem* ToTotem() { return IsTotem() ? reinterpret_cast(this) : nullptr; } bool IsTemporarySummon() const { return m_subtype == CREATURE_SUBTYPE_TEMPORARY_SUMMON; } - bool IsCorpse() const { return GetDeathState() == CORPSE; } + bool IsCorpse() const override { return GetDeathState() == CORPSE; } bool IsDespawned() const { return GetDeathState() == DEAD; } void SetCorpseDelay(uint32 delay) { m_corpseDelay = delay; } bool IsRacialLeader() const { return GetCreatureInfo()->racial_leader; } @@ -272,7 +272,7 @@ class Creature : public Unit bool FallGround(); bool LoadFromDB(uint32 guid, Map* map, bool force = false); - void SaveToDB(); + virtual void SaveToDB(); // overwrited in Pet virtual void SaveToDB(uint32 mapid); virtual void DeleteFromDB(); // overwrited in Pet diff --git a/src/game/Objects/Object.h b/src/game/Objects/Object.h index 0a027432f59..6df526b381e 100644 --- a/src/game/Objects/Object.h +++ b/src/game/Objects/Object.h @@ -391,11 +391,11 @@ class Object SpellCaster* ToSpellCaster(); SpellCaster const* ToSpellCaster() const; - inline bool IsCorpse() const { return GetTypeId() == TYPEID_CORPSE; } + virtual inline bool IsCorpse() const { return GetTypeId() == TYPEID_CORPSE; } Corpse* ToCorpse(); Corpse const* ToCorpse() const; - bool IsPet() const; + virtual bool IsPet() const; Pet* ToPet(); Pet const* ToPet() const; @@ -403,7 +403,7 @@ class Object virtual bool HasInvolvedQuest(uint32 /* quest_id */) const { return false; } protected: - Object (); + Object(); void _InitValues(); void _Create (uint32 guidlow, uint32 entry, HighGuid guidhigh); @@ -651,7 +651,7 @@ class WorldObject : public Object bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_FLYING); } bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_WALK_MODE); } bool IsWalkingBackward() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_BACKWARD); } - bool IsMoving() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_MASK_MOVING); } + virtual bool IsMoving() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_MASK_MOVING); } bool IsSwimming() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_SWIMMING); } bool IsMovingButNotWalking() const { return IsMoving() && !(IsWalking() || IsWalkingBackward()); } @@ -744,7 +744,7 @@ class WorldObject : public Object bool HasMMapsForCurrentMap() const; void SetZoneScript(); - ZoneScript* GetZoneScript() const { return m_zoneScript; } + virtual ZoneScript* GetZoneScript() const { return m_zoneScript; } void AddToClientUpdateList() override; void RemoveFromClientUpdateList() override; diff --git a/src/game/Objects/Pet.h b/src/game/Objects/Pet.h index c227bef8dae..3d7a3338dd4 100644 --- a/src/game/Objects/Pet.h +++ b/src/game/Objects/Pet.h @@ -226,7 +226,7 @@ class Pet : public Creature void CastPetAuras(bool current); void CastPetAura(PetAura const* aura); - virtual void RemoveAllCooldowns(bool sendOnly = false) override; + void RemoveAllCooldowns(bool sendOnly = false) override; void _LoadSpellCooldowns(); void _SaveSpellCooldowns(); diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 8a0f43235b9..5c714afbe6c 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -1487,7 +1487,7 @@ SpellAuraHolder const* Player::GetMirrorTimerBuff(MirrorTimer::Type timer) const } } -bool Player::IsCityProtector() { return m_ExtraFlags & PLAYER_EXTRA_CITY_PROTECTOR; } +bool Player::IsCityProtector() const { return m_ExtraFlags & PLAYER_EXTRA_CITY_PROTECTOR; } void Player::SetCityTitle() { @@ -4467,7 +4467,7 @@ void Player::_LoadSpellCooldowns(std::unique_ptr result) } } -void Player::_SaveSpellCooldowns() +void Player::_SaveSpellCooldowns() const { static SqlStatementID deleteSpellCooldown; @@ -17873,7 +17873,7 @@ void Player::PossessSpellInitialize() GetSession()->SendPacket(&data); } -void Player::CharmSpellInitialize() +void Player::CharmSpellInitialize() const { Unit* charm = GetCharm(); @@ -17941,7 +17941,7 @@ void Player::CharmSpellInitialize() GetSession()->SendPacket(&data); } -void Player::RemovePetActionBar() +void Player::RemovePetActionBar() const { WorldPacket data(SMSG_PET_SPELLS, 8); data << ObjectGuid(); @@ -18507,7 +18507,7 @@ bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 0*/, boo return ActivateTaxiPathTo(nodes, nullptr, spellid, nocheck); } -void Player::ContinueTaxiFlight() +void Player::ContinueTaxiFlight() const { uint32 sourceNode = m_taxi.GetTaxiSource(); if (!sourceNode) @@ -18882,7 +18882,7 @@ bool Player::BuyItemFromVendor(ObjectGuid vendorGuid, uint32 item, uint8 count, return crItem->maxcount != 0; } -void Player::SendRaidGroupOnlyError(uint32 timer, RaidGroupError error) +void Player::SendRaidGroupOnlyError(uint32 timer, RaidGroupError error) const { WorldPacket data(SMSG_RAID_GROUP_ONLY, 4 + 4); data << uint32(timer); @@ -19361,7 +19361,7 @@ void Player::SetLongSight(Aura const* aura) } } -void Player::UpdateLongSight() +void Player::UpdateLongSight() const { if (!m_longSightSpell) return; @@ -20109,7 +20109,7 @@ ZoneScript* Player::GetZoneScript() const return sZoneScriptMgr.GetZoneScriptToZoneId(GetZoneId()); } -bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem) +bool Player::HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem) const { if (spellInfo->EquippedItemClass < 0) return true; @@ -20458,7 +20458,7 @@ void Player::ResurectUsingRequestData() SpawnCorpseBones(); } -void Player::SetClientControl(Unit const* target, uint8 allowMove) +void Player::SetClientControl(Unit const* target, uint8 allowMove) const { #if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 WorldPacket data(SMSG_CLIENT_CONTROL_UPDATE, target->GetPackGUID().size() + 1); @@ -21402,17 +21402,17 @@ bool Player::TeleportToHomebind(uint32 options, bool hearthCooldown) return TeleportTo(m_homebind, (options | TELE_TO_FORCE_MAP_CHANGE)); } -Unit* Player::GetSelectedUnit() +Unit* Player::GetSelectedUnit() const { return GetMap()->GetUnit(m_curSelectionGuid); } -Creature* Player::GetSelectedCreature() +Creature* Player::GetSelectedCreature() const { return GetMap()->GetCreature(m_curSelectionGuid); } -Player* Player::GetSelectedPlayer() +Player* Player::GetSelectedPlayer() const { return GetMap()->GetPlayer(m_curSelectionGuid); } diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index bb4e50f7712..0cd5dc3a8e1 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -1126,7 +1126,7 @@ class Player final: public Unit uint8 GetBankBagSlotCount() const { return GetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_BANK_BAG_SLOTS); } void SetBankBagSlotCount(uint8 count) { SetByteValue(PLAYER_BYTES_2, PLAYER_BYTES_2_OFFSET_BANK_BAG_SLOTS, count); } bool HasItemCount(uint32 item, uint32 count = 1, bool inBankAlso = false) const; - bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = nullptr); + bool HasItemFitToSpellReqirements(SpellEntry const* spellInfo, Item const* ignoreItem = nullptr) const; bool HasItemWithIdEquipped(uint32 item, uint32 count = 1, uint8 except_slot = NULL_SLOT) const; InventoryResult CanStoreNewItem(uint8 bag, uint8 slot, ItemPosCountVec& dest, uint32 item, uint32 count, uint32* no_space_count = nullptr) const { @@ -1488,9 +1488,9 @@ class Player final: public Unit public: void SendPetTameFailure(PetTameFailureReason reason) const; void PetSpellInitialize(); - void CharmSpellInitialize(); + void CharmSpellInitialize() const; void PossessSpellInitialize(); - void RemovePetActionBar(); + void RemovePetActionBar() const; // Take possession of a new spawned creature Creature* SummonPossessedMinion(uint32 creatureId, uint32 spellId, float x, float y, float z, float ang, uint32 duration); @@ -1584,7 +1584,7 @@ class Player final: public Unit void SendClearAllCooldowns(Unit const* target) const; void SendSpellCooldown(uint32 spellId, uint32 cooldown, ObjectGuid target) const; void _LoadSpellCooldowns(std::unique_ptr result); - void _SaveSpellCooldowns(); + void _SaveSpellCooldowns() const; template void RemoveSomeCooldown(F check) @@ -1929,7 +1929,7 @@ class Player final: public Unit bool IsFalling() const { return m_fallStartZ != 0; } bool IsControlledByOwnClient() const { return m_session->GetClientMoverGuid() == GetObjectGuid(); } - void SetClientControl(Unit const* target, uint8 allowMove); + void SetClientControl(Unit const* target, uint8 allowMove) const; void SetMover(Unit* target) { m_mover = target ? target : this; } Unit* GetMover() const { return m_mover; } // can never be null Unit* GetConfirmedMover() const; // only returns mover confirmed by client, can be null @@ -1939,7 +1939,7 @@ class Player final: public Unit ObjectGuid const& GetFarSightGuid() const { return GetGuidValue(PLAYER_FARSIGHT); } void SaveRecallPosition(); - void GetRecallPosition(uint32& map, float& x, float& y, float& z, float& o) + void GetRecallPosition(uint32& map, float& x, float& y, float& z, float& o) const { map = m_recallMap; x = m_recallX; @@ -1972,7 +1972,7 @@ class Player final: public Unit uint32 GetLongSight() const { return m_longSightSpell; } void SetLongSight(Aura const* aura = nullptr); - void UpdateLongSight(); + void UpdateLongSight() const; bool CanWalk() const override { return true; } bool CanSwim() const override { return true; } @@ -2025,7 +2025,7 @@ class Player final: public Unit bool IsLaunched() const { return m_launched; } void SetLaunched(bool apply) { m_launched = apply; } - void SendRaidGroupOnlyError(uint32 timer, RaidGroupError error); + void SendRaidGroupOnlyError(uint32 timer, RaidGroupError error) const; void SendInitialPacketsBeforeAddToMap(); void SendInitialPacketsAfterAddToMap(bool login = true); @@ -2113,7 +2113,7 @@ class Player final: public Unit bool ActivateTaxiPathTo(std::vector const& nodes, Creature const* npc = nullptr, uint32 spellid = 0, bool nocheck = false); bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0, bool nocheck = false); void TaxiStepFinished(bool lastPointReached); - void ContinueTaxiFlight(); + void ContinueTaxiFlight() const; /*********************************************************/ /*** CINEMATIC SYSTEM ***/ @@ -2250,9 +2250,9 @@ class Player final: public Unit void SetSelectedGobj(ObjectGuid guid) { m_selectedGobj = guid; } ObjectGuid const& GetSelectionGuid() const { return m_curSelectionGuid; } void SetSelectionGuid(ObjectGuid guid) { m_curSelectionGuid = guid; SetTargetGuid(guid); } - Unit* GetSelectedUnit(); - Creature* GetSelectedCreature(); - Player* GetSelectedPlayer(); + Unit* GetSelectedUnit() const; + Creature* GetSelectedCreature() const; + Player* GetSelectedPlayer() const; Object* GetObjectByTypeMask(ObjectGuid guid, TypeMask typemask); void SetResurrectRequestData(ObjectGuid guid, uint16 mapId, uint32 instanceId, float x, float y, float z, float o, uint32 health, uint32 mana) @@ -2413,7 +2413,7 @@ class Player final: public Unit void RewardHonor(Unit const* uVictim, uint32 groupSize); void RewardHonorOnDeath(); bool IsHonorOrXPTarget(Unit const* pVictim) const; - bool IsCityProtector(); + bool IsCityProtector() const; void SetCityTitle(); void RemoveCityTitle(); @@ -2425,7 +2425,7 @@ class Player final: public Unit /*********************************************************/ public: - ZoneScript* GetZoneScript() const; + ZoneScript* GetZoneScript() const override; // returns true if the player is in active state for outdoor pvp objective capturing, false otherwise bool IsOutdoorPvPActive() const; @@ -2572,7 +2572,7 @@ class Player final: public Unit std::shared_ptr m_broadcaster; void DeletePacketBroadcaster(); void CreatePacketBroadcaster(); - std::shared_ptr GetPacketBroadcaster() { return m_broadcaster; } + std::shared_ptr GetPacketBroadcaster() const { return m_broadcaster; } /*********************************************************/ /*** INSTANCE SYSTEM ***/ diff --git a/src/game/Objects/TemporarySummon.h b/src/game/Objects/TemporarySummon.h index 9bd14e62d12..42f1274d193 100644 --- a/src/game/Objects/TemporarySummon.h +++ b/src/game/Objects/TemporarySummon.h @@ -35,7 +35,7 @@ class TemporarySummon : public Creature void Summon(TempSummonType type, uint32 lifetime, CreatureAiSetter pFuncAiSetter = nullptr); void UnSummon(uint32 delayDespawnTime = 0); void CleanupsBeforeDelete() override; - void SaveToDB(); + void SaveToDB() override; ObjectGuid const& GetSummonerGuid() const { return m_summoner ; } Unit* GetSummoner() const { return ObjectAccessor::GetUnit(*this, m_summoner); } TempSummonType GetDespawnType() const { return m_type; } diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index 09f546e2ea5..115182ec308 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -363,7 +363,7 @@ class Unit : public SpellCaster typedef std::set ComboPointHolderSet; typedef std::map SingleCastSpellTargetMap; - virtual ~Unit () override; + virtual ~Unit() override; void AddToWorld() override; void RemoveFromWorld() override; @@ -1357,7 +1357,6 @@ class Unit : public SpellCaster bool IsFallingSlow() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_SAFE_FALL); } void SetLevitate(bool apply); - bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_LEVITATING); } void KnockBackFrom(WorldObject const* target, float horizontalSpeed, float verticalSpeed); void KnockBack(float angle, float horizontalSpeed, float verticalSpeed); diff --git a/src/game/OutdoorPvP/OutdoorPvPEP.cpp b/src/game/OutdoorPvP/OutdoorPvPEP.cpp index edc3e268a21..59b299e1d93 100644 --- a/src/game/OutdoorPvP/OutdoorPvPEP.cpp +++ b/src/game/OutdoorPvP/OutdoorPvPEP.cpp @@ -1119,7 +1119,7 @@ class OutdoorPvP_eastern_plaguelands : public ZoneScript_Script { return 0; } - ZoneScript* GetZoneScript() const + ZoneScript* GetZoneScript() const override { return new OutdoorPvPEP(); } diff --git a/src/game/Transports/Transport.h b/src/game/Transports/Transport.h index 28ad51b2f8c..cc9be2a19ef 100644 --- a/src/game/Transports/Transport.h +++ b/src/game/Transports/Transport.h @@ -105,7 +105,7 @@ class Transport : public GenericTransport void MoveToNextWayPoint(); // move m_next/m_cur to next points float CalculateSegmentPos(float perc); - bool IsMoving() const { return m_isMoving; } + bool IsMoving() const override { return m_isMoving; } void SetMoving(bool val) { m_isMoving = val; } ShortTimeTracker m_positionChangeTimer; diff --git a/src/game/World.h b/src/game/World.h index a931ccfbd51..5941df91fd3 100644 --- a/src/game/World.h +++ b/src/game/World.h @@ -633,8 +633,8 @@ enum RealmType class SessionPacketSendTask { - SessionPacketSendTask(const SessionPacketSendTask&) = delete; public: + SessionPacketSendTask(SessionPacketSendTask const&) = delete; SessionPacketSendTask(uint32 accountId, WorldPacket& data) : m_accountId(accountId), m_data(data) {} void operator ()(); private: @@ -758,7 +758,7 @@ class World // Uptime (in secs) uint32 GetUptime() const { return uint32(m_gameTime - m_startTime); } - tm *GetLocalTimeByTime(time_t now) const { return localtime(&now); } + static tm *GetLocalTimeByTime(time_t now) { return localtime(&now); } uint32 GetLastMaintenanceDay() const { @@ -826,8 +826,8 @@ class World bool getConfig(eConfigBoolValues index) const { return m_configBoolValues[index]; } // Are we on a "Player versus Player" server? - bool IsPvPRealm() { return (getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_PVP || getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_RPPVP || getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_FFA_PVP); } - bool IsFFAPvPRealm() { return getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_FFA_PVP; } + bool IsPvPRealm() const { return (getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_PVP || getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_RPPVP || getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_FFA_PVP); } + bool IsFFAPvPRealm() const { return getConfig(CONFIG_UINT32_GAME_TYPE) == REALM_TYPE_FFA_PVP; } void KickAll(); void KickAllLess(AccountTypes sec); @@ -861,7 +861,7 @@ class World LocaleConstant GetAvailableDbcLocale(LocaleConstant locale) const { if (m_availableDbcLocaleMask & (1 << locale)) return locale; else return m_defaultDbcLocale; } // Nostalrius - MovementBroadcaster* GetBroadcaster() { return m_broadcaster.get(); } + MovementBroadcaster* GetBroadcaster() const { return m_broadcaster.get(); } float GetTimeRate() const { return m_timeRate; } void SetTimeRate(float rate) { m_timeRate = rate; } float m_timeRate; diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index f692eb1add6..c7669aab5d5 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -368,11 +368,11 @@ class WorldSession // Public chat cooldown restriction functionality // Intentionally session-based to avoid login/logout hijinks - time_t GetLastPubChanMsgTime() { return m_lastPubChannelMsgTime; } + time_t GetLastPubChanMsgTime() const { return m_lastPubChannelMsgTime; } void SetLastPubChanMsgTime(time_t time) { m_lastPubChannelMsgTime = time; } // Bot system - PlayerBotEntry* GetBot() { return m_bot.get(); } + PlayerBotEntry* GetBot() const { return m_bot.get(); } void SetBot(std::shared_ptr const& b) { m_bot = b; } // Warden / Anticheat @@ -484,7 +484,7 @@ class WorldSession void LoadTutorialsData(); void SendTutorialsData(); void SaveTutorialsData(); - uint32 GetTutorialInt(uint32 intId) + uint32 GetTutorialInt(uint32 intId) const { ASSERT(intId < ACCOUNT_TUTORIALS_COUNT); return m_tutorials[intId]; diff --git a/src/shared/WheatyExceptionReport.cpp b/src/shared/WheatyExceptionReport.cpp index 1f7c2ea609b..5d63af5d3eb 100644 --- a/src/shared/WheatyExceptionReport.cpp +++ b/src/shared/WheatyExceptionReport.cpp @@ -822,7 +822,7 @@ DWORD dwTypeIndex, unsigned nestingLevel, DWORD_PTR offset, bool& bHandled, -char* Name) +char const* Name) { bHandled = false; diff --git a/src/shared/WheatyExceptionReport.h b/src/shared/WheatyExceptionReport.h index 1ee4bca7c37..75b2777b3d8 100644 --- a/src/shared/WheatyExceptionReport.h +++ b/src/shared/WheatyExceptionReport.h @@ -98,7 +98,7 @@ class WheatyExceptionReport static bool FormatSymbolValue(PSYMBOL_INFO, STACKFRAME*, char* pszBuffer, unsigned cbBuffer); - static char* DumpTypeIndex(char*, DWORD64, DWORD, unsigned, DWORD_PTR, bool&, char*); + static char* DumpTypeIndex(char*, DWORD64, DWORD, unsigned, DWORD_PTR, bool&, char const*); static char* FormatOutputValue(char* pszCurrBuffer, BasicType basicType, DWORD64 length, PVOID pAddress);