diff --git a/src/game/AuctionHouseBot/AuctionHouseBot.cpp b/src/game/AuctionHouseBot/AuctionHouseBot.cpp index 4b4b68e59..c59c93d36 100644 --- a/src/game/AuctionHouseBot/AuctionHouseBot.cpp +++ b/src/game/AuctionHouseBot/AuctionHouseBot.cpp @@ -4,6 +4,7 @@ #include "../ObjectMgr.h" #include "../AuctionHouseMgr.h" #include "SystemConfig.h" +#include "../SQLStorages.h" // Format is YYYYMMDDRR where RR is the change in the conf file // for that day. diff --git a/src/game/Item.cpp b/src/game/Item.cpp index 25ebd35a2..ecb8ddb3b 100644 --- a/src/game/Item.cpp +++ b/src/game/Item.cpp @@ -22,6 +22,7 @@ #include "WorldPacket.h" #include "Database/DatabaseEnv.h" #include "ItemEnchantmentMgr.h" +#include "SQLStorages.h" void AddItemsSetItem(Player* player, Item* item) { diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp index 70ecb00cf..c86c1282a 100755 --- a/src/game/ObjectMgr.cpp +++ b/src/game/ObjectMgr.cpp @@ -18,7 +18,6 @@ #include "ObjectMgr.h" #include "Database/DatabaseEnv.h" -#include "Database/SQLStorageImpl.h" #include "Policies/SingletonImp.h" #include "SQLStorages.h" @@ -223,11 +222,6 @@ ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(ObjectGuid guid) const return NULL; } -CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id) -{ - return sCreatureStorage.LookupEntry(id); -} - void ObjectMgr::LoadCreatureLocales() { mCreatureLocaleMap.clear(); // need for reload case @@ -831,11 +825,6 @@ void ObjectMgr::LoadCreatureAddons() sLog.outErrorDb("Creature (GUID: %u) does not exist but has a record in `creature_addon`",addon->guidOrEntry); } -EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry) -{ - return sEquipmentStorage.LookupEntry(entry); -} - void ObjectMgr::LoadEquipmentTemplates() { sEquipmentStorage.Load(); @@ -881,31 +870,26 @@ void ObjectMgr::LoadEquipmentTemplates() sLog.outString(); } -CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid) -{ - return sCreatureModelStorage.LookupEntry(modelid); -} - // generally models that does not have a gender(2), or has alternative model for same gender -uint32 ObjectMgr::GetCreatureModelAlternativeModel(uint32 modelId) +uint32 ObjectMgr::GetCreatureModelAlternativeModel(uint32 modelId) const { - if (const CreatureModelInfo *modelInfo = GetCreatureModelInfo(modelId)) + if (const CreatureModelInfo* modelInfo = GetCreatureModelInfo(modelId)) return modelInfo->modelid_alternative; return 0; } -CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_id) +CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_id) const { - CreatureModelInfo const *minfo = GetCreatureModelInfo(display_id); - if(!minfo) + CreatureModelInfo const* minfo = GetCreatureModelInfo(display_id); + if (!minfo) return NULL; // If a model for another gender exists, 50% chance to use it - if(minfo->modelid_other_gender != 0 && urand(0,1) == 0) + if (minfo->modelid_other_gender != 0 && urand(0, 1) == 0) { - CreatureModelInfo const *minfo_tmp = GetCreatureModelInfo(minfo->modelid_other_gender); - if(!minfo_tmp) + CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(minfo->modelid_other_gender); + if (!minfo_tmp) { sLog.outErrorDb("Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", minfo->modelid, minfo->modelid_other_gender); return minfo; // not fatal, just use the previous one @@ -3390,6 +3374,24 @@ void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, Play } } +/* ********************************************************************************************* */ +/* * Static Wrappers */ +/* ********************************************************************************************* */ +GameObjectInfo const* ObjectMgr::GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry(id); } +Player* ObjectMgr::GetPlayer(const char* name) { return ObjectAccessor::FindPlayerByName(name); } +Player* ObjectMgr::GetPlayer(ObjectGuid guid, bool inWorld /*=true*/) { return ObjectAccessor::FindPlayer(guid, inWorld); } +CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id) { return sCreatureStorage.LookupEntry(id); } +CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid) { return sCreatureModelStorage.LookupEntry(modelid); } +EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry) { return sEquipmentStorage.LookupEntry(entry); } +CreatureDataAddon const* ObjectMgr::GetCreatureAddon(uint32 lowguid) { return sCreatureDataAddonStorage.LookupEntry(lowguid); } +CreatureDataAddon const* ObjectMgr::GetCreatureTemplateAddon(uint32 entry) { return sCreatureInfoAddonStorage.LookupEntry(entry); } +ItemPrototype const* ObjectMgr::GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry(id); } +InstanceTemplate const* ObjectMgr::GetInstanceTemplate(uint32 map) { return sInstanceTemplate.LookupEntry(map); } +WorldTemplate const* ObjectMgr::GetWorldTemplate(uint32 map) { return sWorldTemplate.LookupEntry(map); } + +/* ********************************************************************************************* */ +/* * Loading Functions */ +/* ********************************************************************************************* */ void ObjectMgr::LoadArenaTeams() { uint32 count = 0; @@ -7536,6 +7538,18 @@ uint16 ObjectMgr::GetConditionId( ConditionType condition, uint32 value1, uint32 return mConditions.size() - 1; } +// Check if a player meets condition conditionId +bool ObjectMgr::IsPlayerMeetToNEWCondition(Player const* pPlayer, uint16 conditionId) const +{ + if (!pPlayer) + return false; // player not present, return false + + if (const PlayerCondition* condition = sConditionStorage.LookupEntry(conditionId)) + return condition->Meets(pPlayer); + + return false; +} + bool ObjectMgr::CheckDeclinedNames( std::wstring mainpart, DeclinedName const& names ) { for(int i =0; i < MAX_DECLINED_NAME_CASES; ++i) diff --git a/src/game/ObjectMgr.h b/src/game/ObjectMgr.h index a078cee67..f44e7ca10 100755 --- a/src/game/ObjectMgr.h +++ b/src/game/ObjectMgr.h @@ -36,7 +36,6 @@ #include "ObjectAccessor.h" #include "ObjectGuid.h" #include "Policies/Singleton.h" -#include "SQLStorages.h" #include #include @@ -45,6 +44,7 @@ class Group; class ArenaTeam; class Item; +class SQLStorage; struct GameTele { @@ -487,11 +487,6 @@ class ObjectMgr typedef UNORDERED_MAP WeatherZoneMap; - static Player* GetPlayer(const char* name) { return ObjectAccessor::FindPlayerByName(name);} - static Player* GetPlayer(ObjectGuid guid, bool inWorld = true) { return ObjectAccessor::FindPlayer(guid, inWorld); } - - static GameObjectInfo const *GetGameObjectInfo(uint32 id) { return sGOStorage.LookupEntry(id); } - void LoadGameobjectInfo(); void AddGameobjectInfo(GameObjectInfo *goinfo); @@ -508,33 +503,8 @@ class ObjectMgr ArenaTeamMap::iterator GetArenaTeamMapBegin() { return mArenaTeamMap.begin(); } ArenaTeamMap::iterator GetArenaTeamMapEnd() { return mArenaTeamMap.end(); } - static CreatureInfo const *GetCreatureTemplate( uint32 id ); - CreatureModelInfo const *GetCreatureModelInfo( uint32 modelid ); - CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id); - uint32 GetCreatureModelAlternativeModel(uint32 modelId); - - EquipmentInfo const *GetEquipmentInfo( uint32 entry ); - static CreatureDataAddon const *GetCreatureAddon( uint32 lowguid ) - { - return sCreatureDataAddonStorage.LookupEntry(lowguid); - } - - static CreatureDataAddon const *GetCreatureTemplateAddon( uint32 entry ) - { - return sCreatureInfoAddonStorage.LookupEntry(entry); - } - - static ItemPrototype const* GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry(id); } - - static InstanceTemplate const* GetInstanceTemplate(uint32 map) - { - return sInstanceTemplate.LookupEntry(map); - } - - static WorldTemplate const* GetWorldTemplate(uint32 map) - { - return sWorldTemplate.LookupEntry(map); - } + CreatureModelInfo const* GetCreatureModelRandomGender(uint32 display_id) const; + uint32 GetCreatureModelAlternativeModel(uint32 modelId) const; PetLevelInfo const* GetPetLevelInfo(uint32 creature_id, uint32 level) const; @@ -650,6 +620,20 @@ class ObjectMgr return NULL; } + // Static wrappers for various accessors + static GameObjectInfo const* GetGameObjectInfo(uint32 id); ///< Wrapper for sGOStorage.LookupEntry + static Player* GetPlayer(const char* name); ///< Wrapper for ObjectAccessor::FindPlayerByName + static Player* GetPlayer(ObjectGuid guid, bool inWorld = true); ///< Wrapper for ObjectAccessor::FindPlayer + static CreatureInfo const* GetCreatureTemplate(uint32 id); ///< Wrapper for sCreatureStorage.LookupEntry + static CreatureModelInfo const* GetCreatureModelInfo(uint32 modelid); ///< Wrapper for sCreatureModelStorage.LookupEntry + static EquipmentInfo const* GetEquipmentInfo(uint32 entry); ///< Wrapper for sEquipmentStorage.LookupEntry + static CreatureDataAddon const* GetCreatureAddon(uint32 lowguid); ///< Wrapper for sCreatureDataAddonStorage.LookupEntry + static CreatureDataAddon const* GetCreatureTemplateAddon(uint32 entry); ///< Wrapper for sCreatureInfoAddonStorage.LookupEntry + static ItemPrototype const* GetItemPrototype(uint32 id); ///< Wrapper for sItemStorage.LookupEntry + static InstanceTemplate const* GetInstanceTemplate(uint32 map); ///< Wrapper for sInstanceTemplate.LookupEntry + static WorldTemplate const* GetWorldTemplate(uint32 map); ///< Wrapper for sWorldTemplate.LookupEntry + + // Loading functions void LoadArenaTeams(); void LoadGroups(); void LoadQuests(); @@ -957,16 +941,7 @@ class ObjectMgr } // Check if a player meets condition conditionId - bool IsPlayerMeetToNEWCondition(Player const* pPlayer, uint16 conditionId) const - { - if (!pPlayer) - return false; // player not present, return false - - if (const PlayerCondition* condition = sConditionStorage.LookupEntry(conditionId)) - return condition->Meets(pPlayer); - - return false; - } + bool IsPlayerMeetToNEWCondition(Player const* pPlayer, uint16 conditionId) const; GameTele const* GetGameTele(uint32 id) const { diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp index 15cbccfca..808bd8c53 100644 --- a/src/game/QueryHandler.cpp +++ b/src/game/QueryHandler.cpp @@ -32,6 +32,7 @@ #include "NPCHandler.h" #include "Pet.h" #include "MapManager.h" +#include "SQLStorages.h" void WorldSession::SendNameQueryOpcode(Player *p) { diff --git a/src/game/SQLStorages.cpp b/src/game/SQLStorages.cpp index f703763af..8ed6d82cb 100644 --- a/src/game/SQLStorages.cpp +++ b/src/game/SQLStorages.cpp @@ -17,9 +17,6 @@ */ #include "SQLStorages.h" -#include "Database/SQLStorage.h" -#include "Database/SQLStorageImpl.h" -#include "Database/DatabaseEnv.h" const char CreatureInfosrcfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiis"; const char CreatureInfodstfmt[]="iiiiiiiiiisssiiiiiiiiiiifffiffiifiiiiiiiiiiffiiiiiiiiiiiiiiiiiiisiiffliiiiiiiliiiiiii"; diff --git a/src/game/ScriptMgr.cpp b/src/game/ScriptMgr.cpp index fa3e78852..51a647d5d 100644 --- a/src/game/ScriptMgr.cpp +++ b/src/game/ScriptMgr.cpp @@ -27,6 +27,7 @@ #include "GridNotifiersImpl.h" #include "Cell.h" #include "CellImpl.h" +#include "SQLStorages.h" #include "revision_nr.h" diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp index 107f486eb..db6432ce5 100644 --- a/src/game/SpellMgr.cpp +++ b/src/game/SpellMgr.cpp @@ -28,6 +28,18 @@ #include "MapManager.h" #include "Unit.h" +bool IsPrimaryProfessionSkill(uint32 skill) +{ + SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(skill); + if(!pSkill) + return false; + + if(pSkill->categoryId != SKILL_CATEGORY_PROFESSION) + return false; + + return true; +} + SpellMgr::SpellMgr() { } diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h index 0a2630511..6315e9ed8 100644 --- a/src/game/SpellMgr.h +++ b/src/game/SpellMgr.h @@ -830,17 +830,7 @@ struct PetDefaultSpellsEntry typedef std::map PetDefaultSpellsMap; -inline bool IsPrimaryProfessionSkill(uint32 skill) -{ - SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(skill); - if(!pSkill) - return false; - - if(pSkill->categoryId != SKILL_CATEGORY_PROFESSION) - return false; - - return true; -} +bool IsPrimaryProfessionSkill(uint32 skill); inline bool IsProfessionSkill(uint32 skill) { diff --git a/src/shared/Database/SQLStorage.cpp b/src/shared/Database/SQLStorage.cpp index bb7805733..c78e27474 100644 --- a/src/shared/Database/SQLStorage.cpp +++ b/src/shared/Database/SQLStorage.cpp @@ -17,7 +17,6 @@ */ #include "SQLStorage.h" -#include "SQLStorageImpl.h" void SQLStorage::EraseEntry(uint32 id) { diff --git a/src/shared/Database/SQLStorage.h b/src/shared/Database/SQLStorage.h index 182b23198..9884a5c2e 100644 --- a/src/shared/Database/SQLStorage.h +++ b/src/shared/Database/SQLStorage.h @@ -124,4 +124,6 @@ struct SQLStorageLoader : public SQLStorageLoaderBase { }; +#include "SQLStorageImpl.h" + #endif diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index dfccecccc..45906e2fc 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "12056" + #define REVISION_NR "12057" #endif // __REVISION_NR_H__