diff options
| author | Spp <none@none> | 2010-12-06 02:07:53 +0100 |
|---|---|---|
| committer | Spp <none@none> | 2010-12-06 02:07:53 +0100 |
| commit | 408fce1de69249b82cc042cb31f3fd16983c7e81 (patch) | |
| tree | f4b99f386821e70f155d9aa61b70cfb1f2d3d825 /src/server/game | |
| parent | e226c4ac344d06c7abbd6f04725ced2b33606349 (diff) | |
Core: Some optimizations
- Declare some functions const
- Fix some mem leak
- Fix some resource leak
- Remove unused variables and functions
- Remove duplicate functions
- Reduce the scope of some variables
- Remove unused file
--HG--
branch : trunk
Diffstat (limited to 'src/server/game')
42 files changed, 85 insertions, 125 deletions
diff --git a/src/server/game/AI/CoreAI/GameObjectAI.h b/src/server/game/AI/CoreAI/GameObjectAI.h index ec3802ced37..e0f657b2868 100644 --- a/src/server/game/AI/CoreAI/GameObjectAI.h +++ b/src/server/game/AI/CoreAI/GameObjectAI.h @@ -46,7 +46,7 @@ class GameObjectAI virtual bool GossipSelectCode(Player* /*player*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) {return false;} virtual bool QuestAccept(Player* /*player*/, Quest const* /*quest*/) {return false;} virtual bool QuestReward(Player* /*player*/, Quest const* /*quest*/, uint32 /*opt*/) {return false;} - uint32 GetDialogStatus(Player* /*player*/) {return 100;} + virtual uint32 GetDialogStatus(Player* /*player*/) {return 100;} virtual void Destroyed(Player* /*player*/, uint32 /*eventId*/) {} virtual void SetData(uint32 /*id*/, uint32 /*value*/) {} }; diff --git a/src/server/game/AI/CreatureAI.h b/src/server/game/AI/CreatureAI.h index e1067dadd88..98e0e448195 100755 --- a/src/server/game/AI/CreatureAI.h +++ b/src/server/game/AI/CreatureAI.h @@ -70,7 +70,6 @@ class CreatureAI : public UnitAI bool UpdateVictim(); bool UpdateVictimWithGaze(); - bool UpdateCombatState(); void SetGazeOn(Unit *target); diff --git a/src/server/game/AI/CreatureAIImpl.h b/src/server/game/AI/CreatureAIImpl.h index cab8c54d471..ae989fdb987 100755 --- a/src/server/game/AI/CreatureAIImpl.h +++ b/src/server/game/AI/CreatureAIImpl.h @@ -524,26 +524,6 @@ inline bool CreatureAI::UpdateVictimWithGaze() return me->getVictim(); } -inline bool CreatureAI::UpdateCombatState() -{ - if (!me->isInCombat()) - return false; - - if (!me->HasReactState(REACT_PASSIVE)) - { - if (Unit *victim = me->SelectVictim()) - AttackStart(victim); - return me->getVictim(); - } - else if (me->getThreatManager().isThreatListEmpty()) - { - EnterEvadeMode(); - return false; - } - - return true; -} - inline bool CreatureAI::UpdateVictim() { if (!me->isInCombat()) diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h index 84e02ae169e..36f31c52e8e 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h +++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h @@ -269,7 +269,7 @@ struct BossAI : public ScriptedAI void Reset() { _Reset(); } void EnterCombat(Unit * /*who*/) { _EnterCombat(); } void JustDied(Unit * /*killer*/) { _JustDied(); } - void JustReachedHome() { me->setActive(false); } + void JustReachedHome() { _JustReachedHome(); } protected: void _Reset(); diff --git a/src/server/game/AI/SmartScripts/SmartScript.h b/src/server/game/AI/SmartScripts/SmartScript.h index 74b3a4f4d33..fdb819ab530 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.h +++ b/src/server/game/AI/SmartScripts/SmartScript.h @@ -53,7 +53,7 @@ class SmartScript SmartScriptHolder CreateEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0); void AddEvent(SMART_EVENT e, uint32 event_flags, uint32 event_param1, uint32 event_param2, uint32 event_param3, uint32 event_param4, SMART_ACTION action, uint32 action_param1, uint32 action_param2, uint32 action_param3, uint32 action_param4, uint32 action_param5, uint32 action_param6, SMARTAI_TARGETS t, uint32 target_param1, uint32 target_param2, uint32 target_param3, uint32 phaseMask = 0); void SetPathId(uint32 id) { mPathId = id; } - uint32 GetPathId() { return mPathId; } + uint32 GetPathId() const { return mPathId; } WorldObject* GetBaseObject() { WorldObject* obj = NULL; @@ -188,7 +188,7 @@ class SmartScript DecPhase(abs(p)); } void DecPhase(int32 p = 1) { mEventPhase -= (mEventPhase < (uint32)p ? (uint32)p - mEventPhase : (uint32)p); } - bool IsInPhase(uint32 p) { return mEventPhase & p; } + bool IsInPhase(uint32 p) const { return mEventPhase & p; } void SetPhase(uint32 p = 0) { mEventPhase = p; } SmartAIEventList mEvents; diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 55332117770..46de5bf1ac8 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -1121,10 +1121,10 @@ struct SmartScriptHolder SmartTarget target; public: - uint32 GetScriptType() { return (uint32)source_type; } - uint32 GetEventType() { return (uint32)event.type; } - uint32 GetActionType() { return (uint32)action.type; } - uint32 GetTargetType() { return (uint32)target.type; } + uint32 GetScriptType() const { return (uint32)source_type; } + uint32 GetEventType() const { return (uint32)event.type; } + uint32 GetActionType() const { return (uint32)action.type; } + uint32 GetTargetType() const { return (uint32)target.type; } uint32 timer; bool active; diff --git a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp index 88d42368215..4c31527ac6a 100644 --- a/src/server/game/AuctionHouse/AuctionHouseMgr.cpp +++ b/src/server/game/AuctionHouse/AuctionHouseMgr.cpp @@ -98,12 +98,12 @@ void AuctionHouseMgr::SendAuctionWonMail(AuctionEntry *auction, SQLTransaction& return; uint32 bidder_accId = 0; - uint32 bidder_security = 0; uint64 bidder_guid = MAKE_NEW_GUID(auction->bidder, 0, HIGHGUID_PLAYER); Player *bidder = sObjectMgr.GetPlayer(bidder_guid); // data for gm.log if (sWorld.getBoolConfig(CONFIG_GM_LOG_TRADE)) { + uint32 bidder_security = 0; std::string bidder_name; if (bidder) { diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 6dd2bd9fe5d..bf2664929b5 100755 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1803,7 +1803,7 @@ void Battleground::HandleKillPlayer(Player *player, Player *killer) // return the player's team based on battlegroundplayer info // used in same faction arena matches mainly -uint32 Battleground::GetPlayerTeam(uint64 guid) +uint32 Battleground::GetPlayerTeam(uint64 guid) const { BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) @@ -1811,12 +1811,12 @@ uint32 Battleground::GetPlayerTeam(uint64 guid) return 0; } -uint32 Battleground::GetOtherTeam(uint32 teamId) +uint32 Battleground::GetOtherTeam(uint32 teamId) const { return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; } -bool Battleground::IsPlayerInBattleground(uint64 guid) +bool Battleground::IsPlayerInBattleground(uint64 guid) const { BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid); if (itr != m_Players.end()) @@ -1935,13 +1935,13 @@ void Battleground::RewardXPAtKill(Player* plr, Player* victim) return; uint32 xp = 0; - uint32 count = 0; - uint32 sum_level = 0; Player* member_with_max_level = NULL; Player* not_gray_member_with_max_level = NULL; if (Group *pGroup = plr->GetGroup())//should be always in a raid group while in any bg { + uint32 count = 0; + uint32 sum_level = 0; for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) { Player* member = itr->getSource(); diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index 81540b43f6a..e8d5f032850 100755 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -373,7 +373,7 @@ class Battleground uint32 GetScriptId() const { return ScriptId; } uint32 GetBattlemasterEntry() const; uint32 GetBonusHonorFromKill(uint32 kills) const; - bool IsRandom() { return m_IsRandom; } + bool IsRandom() const { return m_IsRandom; } // Set methods: void SetName(char const* Name) { m_Name = Name; } @@ -569,9 +569,9 @@ class Battleground virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; } // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player - uint32 GetPlayerTeam(uint64 guid); - uint32 GetOtherTeam(uint32 teamId); - bool IsPlayerInBattleground(uint64 guid); + uint32 GetPlayerTeam(uint64 guid) const; + uint32 GetOtherTeam(uint32 teamId) const; + bool IsPlayerInBattleground(uint64 guid) const; void SetDeleteThis() {m_SetDeleteThis = true;} diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index d286a1220cd..b7d82e8ac72 100755 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -900,7 +900,6 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint6 else // battleground { size_t count_pos = data->wpos(); - uint32 count = 0; *data << uint32(0); // number of bg instances if (Battleground* bgTemplate = sBattlegroundMgr.GetBattlegroundTemplate(bgTypeId)) @@ -908,6 +907,7 @@ void BattlegroundMgr::BuildBattlegroundListPacket(WorldPacket *data, const uint6 // expected bracket entry if (PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bgTemplate->GetMapId(),plr->getLevel())) { + uint32 count = 0; BattlegroundBracketId bracketId = bracketEntry->GetBracketId(); for (std::set<uint32>::iterator itr = m_ClientBattlegroundIds[bgTypeId][bracketId].begin(); itr != m_ClientBattlegroundIds[bgTypeId][bracketId].end();++itr) { diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index ef664b24b8b..8078db8956b 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -258,7 +258,7 @@ void BattlegroundQueue::PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* g (*lastPlayerAddedPointer) %= COUNT_OF_PLAYERS_TO_AVERAGE_WAIT_TIME; } -uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) +uint32 BattlegroundQueue::GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const { uint8 team_index = BG_TEAM_ALLIANCE; //default set to BG_TEAM_ALLIANCE - or non rated arenas! if (!ginfo->ArenaType) diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.h b/src/server/game/Battlegrounds/BattlegroundQueue.h index 5618746fcc5..bad3692d942 100755 --- a/src/server/game/Battlegrounds/BattlegroundQueue.h +++ b/src/server/game/Battlegrounds/BattlegroundQueue.h @@ -80,7 +80,7 @@ class BattlegroundQueue bool IsPlayerInvited(const uint64& pl_guid, const uint32 bgInstanceGuid, const uint32 removeTime); bool GetPlayerGroupInfoData(const uint64& guid, GroupQueueInfo* ginfo); void PlayerInvitedToBGUpdateAverageWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id); - uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id); + uint32 GetAverageQueueWaitTime(GroupQueueInfo* ginfo, BattlegroundBracketId bracket_id) const; typedef std::map<uint64, PlayerQueueInfo> QueuedPlayersMap; QueuedPlayersMap m_QueuedPlayers; diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 30f9f95adfc..316d4e5ac99 100755 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -624,10 +624,7 @@ void Channel::Say(uint64 p, const char *what, uint32 lang) if (sWorld.getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL)) lang = LANG_UNIVERSAL; - uint32 sec = 0; Player *plr = sObjectMgr.GetPlayer(p); - if (plr) - sec = plr->GetSession()->GetSecurity(); if (!IsOn(p)) { diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index 63f8fa6b502..5bbb8997ae8 100755 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -123,21 +123,21 @@ class Channel uint64 player; uint8 flags; - bool HasFlag(uint8 flag) { return flags & flag; } + bool HasFlag(uint8 flag) const { return flags & flag; } void SetFlag(uint8 flag) { if (!HasFlag(flag)) flags |= flag; } - bool IsOwner() { return flags & MEMBER_FLAG_OWNER; } + bool IsOwner() const { return flags & MEMBER_FLAG_OWNER; } void SetOwner(bool state) { if (state) flags |= MEMBER_FLAG_OWNER; else flags &= ~MEMBER_FLAG_OWNER; } - bool IsModerator() { return flags & MEMBER_FLAG_MODERATOR; } + bool IsModerator() const { return flags & MEMBER_FLAG_MODERATOR; } void SetModerator(bool state) { if (state) flags |= MEMBER_FLAG_MODERATOR; else flags &= ~MEMBER_FLAG_MODERATOR; } - bool IsMuted() { return flags & MEMBER_FLAG_MUTED; } + bool IsMuted() const { return flags & MEMBER_FLAG_MUTED; } void SetMuted(bool state) { if (state) flags |= MEMBER_FLAG_MUTED; @@ -255,7 +255,7 @@ class Channel void SetAnnounce(bool nannounce) { m_announce = nannounce; } uint32 GetNumPlayers() const { return players.size(); } uint8 GetFlags() const { return m_flags; } - bool HasFlag(uint8 flag) { return m_flags & flag; } + bool HasFlag(uint8 flag) const { return m_flags & flag; } void Join(uint64 p, const char *pass); void Leave(uint64 p, bool send = true); diff --git a/src/server/game/Chat/Commands/Level2.cpp b/src/server/game/Chat/Commands/Level2.cpp index f1bc40d77bf..4124b54a7e8 100755 --- a/src/server/game/Chat/Commands/Level2.cpp +++ b/src/server/game/Chat/Commands/Level2.cpp @@ -205,7 +205,6 @@ bool ChatHandler::HandleDeMorphCommand(const char* /*args*/) //kick player bool ChatHandler::HandleKickPlayerCommand(const char *args) { - const char* kickName = strtok((char*)args, " "); Player* target = NULL; std::string playerName; if (!extractPlayerTarget((char*)args, &target, NULL, &playerName)) diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h index d93e3151eec..7aa8c905fee 100755 --- a/src/server/game/Combat/ThreatManager.h +++ b/src/server/game/Combat/ThreatManager.h @@ -170,9 +170,9 @@ class ThreatContainer void setDirty(bool pDirty) { iDirty = pDirty; } - bool isDirty() { return iDirty; } + bool isDirty() const { return iDirty; } - bool empty() { return(iThreatList.empty()); } + bool empty() const { return(iThreatList.empty()); } HostileReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); } diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index d245483a6d7..538b4e92f1b 100755 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -128,7 +128,7 @@ struct Condition } bool Meets(Player * player, Unit* invoker = NULL); - bool isLoaded() { return mConditionType > CONDITION_NONE || mReferenceId; } + bool isLoaded() const { return mConditionType > CONDITION_NONE || mReferenceId; } }; typedef std::list<Condition*> ConditionList; @@ -168,7 +168,7 @@ class ConditionMgr bool addToGossipMenuItems(Condition* cond); bool IsPlayerMeetToConditionList(Player* player,const ConditionList& conditions, Unit* invoker = NULL); - bool isGroupable(ConditionSourceType sourceType) + bool isGroupable(ConditionSourceType sourceType) const { return (sourceType == CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE || sourceType == CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE || diff --git a/src/server/game/Entities/Creature/GossipDef.h b/src/server/game/Entities/Creature/GossipDef.h index b6eba922559..df321683893 100755 --- a/src/server/game/Entities/Creature/GossipDef.h +++ b/src/server/game/Entities/Creature/GossipDef.h @@ -159,7 +159,7 @@ class GossipMenu void AddMenuItem(uint8 Icon, char const* Message, uint32 dtSender, uint32 dtAction, char const* BoxMessage, uint32 BoxMoney, bool Coded = false); void SetMenuId(uint32 menu_id) { m_gMenuId = menu_id; } - uint32 GetMenuId() { return m_gMenuId; } + uint32 GetMenuId() const { return m_gMenuId; } void AddGossipMenuItemData(uint32 action_menu, uint32 action_poi, uint32 action_script); @@ -173,12 +173,12 @@ class GossipMenu return m_gItems.empty(); } - GossipMenuItem const& GetItem(unsigned int Id) + GossipMenuItem const& GetItem(unsigned int Id) const { return m_gItems[ Id ]; } - GossipMenuItemData const& GetItemData(unsigned int indexId) + GossipMenuItemData const& GetItemData(unsigned int indexId) const { return m_gItemsData[indexId]; } @@ -217,7 +217,7 @@ class QuestMenu bool HasItem(uint32 questid); - QuestMenuItem const& GetItem(uint16 Id) + QuestMenuItem const& GetItem(uint16 Id) const { return m_qItems[ Id ]; } diff --git a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp index 7ff96662f51..e177e4db485 100755 --- a/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp +++ b/src/server/game/Entities/Item/ItemEnchantmentMgr.cpp @@ -48,15 +48,11 @@ void LoadRandomEnchantmentsTable() { RandomItemEnch.clear(); // for reload case - EnchantmentStore::const_iterator tab; - uint32 entry, ench; - float chance; - uint32 count = 0; - QueryResult result = WorldDatabase.Query("SELECT entry, ench, chance FROM item_enchantment_template"); if (result) { + uint32 count = 0; barGoLink bar(result->GetRowCount()); do @@ -64,9 +60,9 @@ void LoadRandomEnchantmentsTable() Field *fields = result->Fetch(); bar.step(); - entry = fields[0].GetUInt32(); - ench = fields[1].GetUInt32(); - chance = fields[2].GetFloat(); + uint32 entry = fields[0].GetUInt32(); + uint32 ench = fields[1].GetUInt32(); + float chance = fields[2].GetFloat(); if (chance > 0.000001f && chance <= 100.0f) RandomItemEnch[entry].push_back(EnchStoreItem(ench, chance)); diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index 2b02020299a..98cb9e66d85 100755 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -1351,8 +1351,6 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel return false; } - uint32 oldspell_id = 0; - PetSpell newspell; newspell.state = state; newspell.type = type; @@ -1402,7 +1400,6 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel if (newspell.active == ACT_ENABLED) ToggleAutocast(itr2->first, false); - oldspell_id = itr2->first; unlearnSpell(itr2->first,false,false); break; } diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 5cbddf37082..c12a5081f2d 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -13593,7 +13593,6 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId, bool showQue uint32 npcflags = 0; Creature *pCreature = NULL; - GameObject *pGo = NULL; if (pSource->GetTypeId() == TYPEID_UNIT) { @@ -13602,8 +13601,6 @@ void Player::PrepareGossipMenu(WorldObject *pSource, uint32 menuId, bool showQue if (npcflags & UNIT_NPC_FLAG_QUESTGIVER && showQuests) PrepareQuestMenu(pSource->GetGUID()); } - else if (pSource->GetTypeId() == TYPEID_GAMEOBJECT) - pGo = (GameObject*)pSource; for (GossipMenuItemsMap::const_iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr) { diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h index 1baf668cd8b..e64b82fdfa2 100755 --- a/src/server/game/Entities/Player/SocialMgr.h +++ b/src/server/game/Entities/Player/SocialMgr.h @@ -128,7 +128,7 @@ class PlayerSocial // Misc bool HasFriend(uint32 friend_guid); bool HasIgnore(uint32 ignore_guid); - uint32 GetPlayerGUID() { return m_playerGUID; } + uint32 GetPlayerGUID() const { return m_playerGUID; } void SetPlayerGUID(uint32 guid) { m_playerGUID = guid; } uint32 GetNumberOfSocialsWithFlag(SocialFlag flag); private: diff --git a/src/server/game/Entities/Unit/StatSystem.cpp b/src/server/game/Entities/Unit/StatSystem.cpp index 10e855188fc..c57cc75ea77 100755 --- a/src/server/game/Entities/Unit/StatSystem.cpp +++ b/src/server/game/Entities/Unit/StatSystem.cpp @@ -433,22 +433,18 @@ void Player::UpdateShieldBlockValue() void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& min_damage, float& max_damage) { UnitMods unitMod; - UnitMods attPower; switch(attType) { case BASE_ATTACK: default: unitMod = UNIT_MOD_DAMAGE_MAINHAND; - attPower = UNIT_MOD_ATTACK_POWER; break; case OFF_ATTACK: unitMod = UNIT_MOD_DAMAGE_OFFHAND; - attPower = UNIT_MOD_ATTACK_POWER; break; case RANGED_ATTACK: unitMod = UNIT_MOD_DAMAGE_RANGED; - attPower = UNIT_MOD_ATTACK_POWER_RANGED; break; } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index a0014d06bf1..deae7df8ca8 100755 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -989,8 +989,8 @@ struct CharmInfo void SetPetNumber(uint32 petnumber, bool statwindow); void SetCommandState(CommandStates st) { m_CommandState = st; } - CommandStates GetCommandState() { return m_CommandState; } - bool HasCommandState(CommandStates state) { return (m_CommandState == state); } + CommandStates GetCommandState() const { return m_CommandState; } + bool HasCommandState(CommandStates state) const { return (m_CommandState == state); } //void SetReactState(ReactStates st) { m_reactState = st; } //ReactStates GetReactState() { return m_reactState; } //bool HasReactState(ReactStates state) { return (m_reactState == state); } diff --git a/src/server/game/Entities/Vehicle/Vehicle.h b/src/server/game/Entities/Vehicle/Vehicle.h index 4c1f383bc74..f24d24dc697 100755 --- a/src/server/game/Entities/Vehicle/Vehicle.h +++ b/src/server/game/Entities/Vehicle/Vehicle.h @@ -99,7 +99,7 @@ class Vehicle void InstallAllAccessories(uint32 entry); Unit *GetBase() const { return me; } - VehicleEntry const *GetVehicleInfo() { return m_vehicleInfo; } + VehicleEntry const *GetVehicleInfo() const { return m_vehicleInfo; } bool HasEmptySeat(int8 seatId) const; Unit *GetPassenger(int8 seatId) const; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index af0515e7d78..d5b8786c280 100755 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -5858,13 +5858,13 @@ void ObjectMgr::GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uin uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt_team /* = false */) { - uint32 mount_entry = 0; uint32 mount_id = 0; // select mount creature id TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id); if (node) { + uint32 mount_entry = 0; if (team == ALLIANCE) mount_entry = node->MountCreatureID[1]; else diff --git a/src/server/game/Grids/ObjectGridLoader.h b/src/server/game/Grids/ObjectGridLoader.h index c9503c8fd5d..e224855827a 100755 --- a/src/server/game/Grids/ObjectGridLoader.h +++ b/src/server/game/Grids/ObjectGridLoader.h @@ -39,9 +39,9 @@ class ObjectGridLoader void Load(GridType &grid); void Visit(GameObjectMapType &m); void Visit(CreatureMapType &m); - void Visit(CorpseMapType &) {} + void Visit(CorpseMapType &) const {} - void Visit(DynamicObjectMapType&) { } + void Visit(DynamicObjectMapType&) const {} void LoadN(void); diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp index 78fe393e696..ae053e4c681 100755 --- a/src/server/game/Groups/Group.cpp +++ b/src/server/game/Groups/Group.cpp @@ -1928,7 +1928,7 @@ void Group::SetLfgState(LfgState state) m_LfgState = state; } -LfgState Group::GetLfgState() +LfgState Group::GetLfgState() const { return m_LfgState; } @@ -1944,7 +1944,7 @@ void Group::SetLfgDungeonEntry(uint32 dungeonEntry) m_LfgDungeonEntry = dungeonEntry; } -uint32 Group::GetLfgDungeonEntry(bool id /* = true*/) +uint32 Group::GetLfgDungeonEntry(bool id /* = true*/) const { if (id) return (m_LfgDungeonEntry & 0x00FFFFFF); @@ -2168,7 +2168,7 @@ void Group::LinkMember(GroupReference *pRef) m_memberMgr.insertFirst(pRef); } -void Group::DelinkMember(GroupReference* /*pRef*/) +void Group::DelinkMember(GroupReference* /*pRef*/) const { } diff --git a/src/server/game/Groups/Group.h b/src/server/game/Groups/Group.h index 7e0cfe1413c..cf690196526 100755 --- a/src/server/game/Groups/Group.h +++ b/src/server/game/Groups/Group.h @@ -196,10 +196,10 @@ class Group // Dungeon Finder void SetLfgState(LfgState state); - LfgState GetLfgState(); + LfgState GetLfgState() const; void RestoreLfgState(); void SetLfgDungeonEntry(uint32 dungeonEntry); - uint32 GetLfgDungeonEntry(bool id = true); + uint32 GetLfgDungeonEntry(bool id = true) const; uint8 GetLfgKicks() const; void SetLfgKicks(uint8 kicks); void SetLfgRoles(uint64 guid, const uint8 roles); @@ -292,7 +292,7 @@ class Group void ResetMaxEnchantingLevel(); void LinkMember(GroupReference *pRef); - void DelinkMember(GroupReference* /*pRef*/); + void DelinkMember(GroupReference* /*pRef*/) const; InstanceGroupBind* BindToInstance(InstanceSave *save, bool permanent, bool load = false); void UnbindInstance(uint32 mapid, uint8 difficulty, bool unload = false); diff --git a/src/server/game/Instances/InstanceSaveMgr.h b/src/server/game/Instances/InstanceSaveMgr.h index 029b46be9f6..aaeefe65c9d 100755 --- a/src/server/game/Instances/InstanceSaveMgr.h +++ b/src/server/game/Instances/InstanceSaveMgr.h @@ -61,8 +61,8 @@ class InstanceSave /* A map corresponding to the InstanceId/MapId does not always exist. InstanceSave objects may be created on player logon but the maps are created and loaded only when a player actually enters the instance. */ - uint32 GetInstanceId() { return m_instanceid; } - uint32 GetMapId() { return m_mapid; } + uint32 GetInstanceId() const { return m_instanceid; } + uint32 GetMapId() const { return m_mapid; } /* Saved when the instance is generated for the first time */ void SaveToDB(); @@ -71,7 +71,7 @@ class InstanceSave /* for normal instances this corresponds to max(creature respawn time) + X hours for raid/heroic instances this caches the global respawn time for the map */ - time_t GetResetTime() { return m_resetTime; } + time_t GetResetTime() const { return m_resetTime; } void SetResetTime(time_t resetTime) { m_resetTime = resetTime; } time_t GetResetTimeForDB(); @@ -89,12 +89,12 @@ class InstanceSave /* instances cannot be reset (except at the global reset time) if there are players permanently bound to it this is cached for the case when those players are offline */ - bool CanReset() { return m_canReset; } + bool CanReset() const { return m_canReset; } void SetCanReset(bool canReset) { m_canReset = canReset; } /* currently it is possible to omit this information from this structure but that would depend on a lot of things that can easily change in future */ - Difficulty GetDifficulty() { return m_difficulty; } + Difficulty GetDifficulty() const { return m_difficulty; } typedef std::list<Player*> PlayerListType; typedef std::list<Group*> GroupListType; diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp index f25029765c1..904d27d2dd9 100755 --- a/src/server/game/Loot/LootMgr.cpp +++ b/src/server/game/Loot/LootMgr.cpp @@ -94,7 +94,6 @@ void LootStore::Verify() const void LootStore::LoadLootTable() { LootTemplateMap::const_iterator tab; - uint32 count = 0; // Clearing store (for reloading case) Clear(); @@ -106,6 +105,8 @@ void LootStore::LoadLootTable() if (result) { + uint32 count = 0; + barGoLink bar(result->GetRowCount()); do diff --git a/src/server/game/Movement/Waypoints/WaypointManager.h b/src/server/game/Movement/Waypoints/WaypointManager.h index 4b57c6ae815..0c7f608d893 100755 --- a/src/server/game/Movement/Waypoints/WaypointManager.h +++ b/src/server/game/Movement/Waypoints/WaypointManager.h @@ -57,7 +57,7 @@ class WaypointStore else return 0; } - inline uint32 GetRecordsCount() { return records; } + inline uint32 GetRecordsCount() const { return records; } }; #define sWaypointMgr WaypointStore::instance() diff --git a/src/server/game/Pools/PoolMgr.h b/src/server/game/Pools/PoolMgr.h index 29371f68fe9..369de80e90f 100755 --- a/src/server/game/Pools/PoolMgr.h +++ b/src/server/game/Pools/PoolMgr.h @@ -58,7 +58,7 @@ class ActivePoolData template<typename T> void RemoveObject(uint32 db_guid_or_pool_id, uint32 pool_id); - ActivePoolObjects GetActiveQuests() { return mActiveQuests; } // a copy of the set + ActivePoolObjects GetActiveQuests() const { return mActiveQuests; } // a copy of the set private: ActivePoolObjects mSpawnedCreatures; ActivePoolObjects mSpawnedGameobjects; diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp index 934c8579edd..cbd469edb69 100755 --- a/src/server/game/Reputation/ReputationMgr.cpp +++ b/src/server/game/Reputation/ReputationMgr.cpp @@ -424,7 +424,7 @@ void ReputationMgr::SetAtWar(RepListID repListID, bool on) SetAtWar(&itr->second,on); } -void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) +void ReputationMgr::SetAtWar(FactionState* faction, bool atWar) const { // not allow declare war to own faction if (atWar && (faction->Flags & FACTION_FLAG_PEACE_FORCED)) @@ -452,7 +452,7 @@ void ReputationMgr::SetInactive(RepListID repListID, bool on) SetInactive(&itr->second,on); } -void ReputationMgr::SetInactive(FactionState* faction, bool inactive) +void ReputationMgr::SetInactive(FactionState* faction, bool inactive) const { // always invisible or hidden faction can't be inactive if (inactive && ((faction->Flags & (FACTION_FLAG_INVISIBLE_FORCED|FACTION_FLAG_HIDDEN)) || !(faction->Flags & FACTION_FLAG_VISIBLE))) diff --git a/src/server/game/Reputation/ReputationMgr.h b/src/server/game/Reputation/ReputationMgr.h index 2fe3054971e..2d167c9c1dc 100755 --- a/src/server/game/Reputation/ReputationMgr.h +++ b/src/server/game/Reputation/ReputationMgr.h @@ -141,8 +141,8 @@ class ReputationMgr bool SetReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); bool SetOneFactionReputation(FactionEntry const* factionEntry, int32 standing, bool incremental); void SetVisible(FactionState* faction); - void SetAtWar(FactionState* faction, bool atWar); - void SetInactive(FactionState* faction, bool inactive); + void SetAtWar(FactionState* faction, bool atWar) const; + void SetInactive(FactionState* faction, bool inactive) const; void SendVisible(FactionState const* faction) const; void UpdateRankCounters(ReputationRank old_rank, ReputationRank new_rank); private: diff --git a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp index 3a3a23cc4ec..7be5f7fafbf 100755 --- a/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/CharacterHandler.cpp @@ -23,7 +23,6 @@ #include "World.h" #include "WorldPacket.h" #include "WorldSession.h" -#include "MD5.h" #include "DatabaseEnv.h" #include "ArenaTeam.h" diff --git a/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp b/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp index 421275c94be..0ff97ee8fbe 100755 --- a/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp +++ b/src/server/game/Server/Protocol/Handlers/GuildHandler.cpp @@ -465,7 +465,6 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket & recv_data) uint8 playerBag = NULL_BAG; uint8 playerSlotId = NULL_SLOT; uint8 toChar = 1; - uint32 autoStoreCount = 0; recv_data >> tabId; recv_data >> slotId; @@ -475,7 +474,7 @@ void WorldSession::HandleGuildBankSwapItems(WorldPacket & recv_data) recv_data >> autoStore; if (autoStore) { - recv_data >> autoStoreCount; + recv_data.read_skip<uint32>(); // autoStoreCount recv_data.read_skip<uint8>(); // ToChar (?), always and expected to be 1 (autostore only triggered in Bank -> Char) recv_data.read_skip<uint32>(); // Always 0 } diff --git a/src/server/game/Skills/SkillExtraItems.cpp b/src/server/game/Skills/SkillExtraItems.cpp index 2f5a310d840..5cc86ffbe3c 100755 --- a/src/server/game/Skills/SkillExtraItems.cpp +++ b/src/server/game/Skills/SkillExtraItems.cpp @@ -52,8 +52,6 @@ SkillExtraItemMap SkillExtraItemStore; // loads the extra item creation info from DB void LoadSkillExtraItemTable() { - uint32 count = 0; - SkillExtraItemStore.clear(); // need for reload // 0 1 2 3 @@ -61,6 +59,8 @@ void LoadSkillExtraItemTable() if (result) { + uint32 count = 0; + barGoLink bar(result->GetRowCount()); do diff --git a/src/server/game/Tickets/TicketMgr.h b/src/server/game/Tickets/TicketMgr.h index 2dc99d65e0d..b6b6513eef0 100755 --- a/src/server/game/Tickets/TicketMgr.h +++ b/src/server/game/Tickets/TicketMgr.h @@ -132,7 +132,7 @@ public: uint64 GenerateGMTicketId(); bool GetStatus() const { return status; } void SetStatus(bool newStatus) { status = newStatus; } - uint64 GetOpenTicketCount() { return m_openTickets; } + uint64 GetOpenTicketCount() const { return m_openTickets; } uint64 GetNextSurveyID() { return ++m_GMSurveyID; } void Initialize() @@ -149,7 +149,7 @@ public: return NULL; } - time_t GetLastChange() { return lastChange; } + time_t GetLastChange() const { return lastChange; } void UpdateLastChange() { lastChange = time(NULL); } GmTicketList m_GMTicketList; diff --git a/src/server/game/Tools/PlayerDump.cpp b/src/server/game/Tools/PlayerDump.cpp index dd6a7bb5498..8f0d375596d 100755 --- a/src/server/game/Tools/PlayerDump.cpp +++ b/src/server/game/Tools/PlayerDump.cpp @@ -595,7 +595,8 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s { //store a map of old pet id to new inserted pet id for use by type 5 tables snprintf(currpetid, 20, "%s", getnth(line, 1).c_str()); - if (strlen(lastpetid) == 0) snprintf(lastpetid, 20, "%s", currpetid); + if (*lastpetid == '\0') + snprintf(lastpetid, 20, "%s", currpetid); if (strcmp(lastpetid,currpetid) != 0) { snprintf(newpetid, 20, "%d", sObjectMgr.GeneratePetNumber()); diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index c8f38b2eb85..f7466f6c092 100755 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -221,9 +221,9 @@ World::AddSession_(WorldSession* s) ///- kick already loaded player with same account (if any) and remove session ///- if player is in loading and want to load again, return - if (!RemoveSession (s->GetAccountId ())) + if (!RemoveSession (s->GetAccountId())) { - s->KickPlayer (); + s->KickPlayer(); delete s; // session not added yet in session list, so not listed in queue return; } @@ -234,7 +234,7 @@ World::AddSession_(WorldSession* s) // if session already exist, prepare to it deleting at next world update // NOTE - KickPlayer() should be called on "old" in RemoveSession() { - SessionMap::const_iterator old = m_sessions.find(s->GetAccountId ()); + SessionMap::const_iterator old = m_sessions.find(s->GetAccountId()); if (old != m_sessions.end()) { @@ -246,22 +246,22 @@ World::AddSession_(WorldSession* s) } } - m_sessions[s->GetAccountId ()] = s; + m_sessions[s->GetAccountId()] = s; - uint32 Sessions = GetActiveAndQueuedSessionCount (); - uint32 pLimit = GetPlayerAmountLimit (); - uint32 QueueSize = GetQueueSize (); //number of players in the queue + uint32 Sessions = GetActiveAndQueuedSessionCount(); + uint32 pLimit = GetPlayerAmountLimit(); + uint32 QueueSize = GetQueuedSessionCount(); //number of players in the queue //so we don't count the user trying to //login as a session and queue the socket that we are using if (decrease_session) --Sessions; - if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity () == SEC_PLAYER && !HasRecentlyDisconnected(s)) + if (pLimit > 0 && Sessions >= pLimit && s->GetSecurity() == SEC_PLAYER && !HasRecentlyDisconnected(s)) { AddQueuedPlayer (s); - UpdateMaxSessionCounters (); - sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId (), ++QueueSize); + UpdateMaxSessionCounters(); + sLog.outDetail ("PlayerQueue: Account id %u is in Queue Position (%u).", s->GetAccountId(), ++QueueSize); return; } @@ -273,7 +273,7 @@ World::AddSession_(WorldSession* s) s->SendTutorialsData(); - UpdateMaxSessionCounters (); + UpdateMaxSessionCounters(); // Updates the population if (pLimit > 0) diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 750c7dc7e4a..02c1dbed570 100755 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -572,7 +572,6 @@ class World bool RemoveQueuedPlayer(WorldSession* session); int32 GetQueuePos(WorldSession*); bool HasRecentlyDisconnected(WorldSession*); - uint32 GetQueueSize() const { return m_QueuedPlayer.size(); } /// \todo Actions on m_allowMovement still to be implemented /// Is movement allowed? @@ -725,8 +724,8 @@ class World //used World DB version void LoadDBVersion(); - char const* GetDBVersion() { return m_DBVersion.c_str(); } - char const* GetCreatureEventAIVersion() { return m_CreatureEventAIVersion.c_str(); } + char const* GetDBVersion() const { return m_DBVersion.c_str(); } + char const* GetCreatureEventAIVersion() const { return m_CreatureEventAIVersion.c_str(); } void RecordTimeDiff(const char * text, ...); @@ -736,7 +735,7 @@ class World void ProcessStartEvent(); void ProcessStopEvent(); - bool GetEventKill() { return isEventKillStart; } + bool GetEventKill() const { return isEventKillStart; } bool isEventKillStart; protected: |
