[12057] Add some static wrappers for Lookup access to SQLStorages

This commit is contained in:
Schmoozerd 2012-07-19 01:13:26 +02:00
parent 4e117d1ee8
commit f24fa870c5
12 changed files with 76 additions and 83 deletions

View file

@ -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.

View file

@ -22,6 +22,7 @@
#include "WorldPacket.h"
#include "Database/DatabaseEnv.h"
#include "ItemEnchantmentMgr.h"
#include "SQLStorages.h"
void AddItemsSetItem(Player* player, Item* item)
{

View file

@ -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<CreatureInfo>(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<EquipmentInfo>(entry);
}
void ObjectMgr::LoadEquipmentTemplates()
{
sEquipmentStorage.Load();
@ -881,31 +870,26 @@ void ObjectMgr::LoadEquipmentTemplates()
sLog.outString();
}
CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid)
{
return sCreatureModelStorage.LookupEntry<CreatureModelInfo>(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<GameObjectInfo>(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<CreatureInfo>(id); }
CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid) { return sCreatureModelStorage.LookupEntry<CreatureModelInfo>(modelid); }
EquipmentInfo const* ObjectMgr::GetEquipmentInfo(uint32 entry) { return sEquipmentStorage.LookupEntry<EquipmentInfo>(entry); }
CreatureDataAddon const* ObjectMgr::GetCreatureAddon(uint32 lowguid) { return sCreatureDataAddonStorage.LookupEntry<CreatureDataAddon>(lowguid); }
CreatureDataAddon const* ObjectMgr::GetCreatureTemplateAddon(uint32 entry) { return sCreatureInfoAddonStorage.LookupEntry<CreatureDataAddon>(entry); }
ItemPrototype const* ObjectMgr::GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry<ItemPrototype>(id); }
InstanceTemplate const* ObjectMgr::GetInstanceTemplate(uint32 map) { return sInstanceTemplate.LookupEntry<InstanceTemplate>(map); }
WorldTemplate const* ObjectMgr::GetWorldTemplate(uint32 map) { return sWorldTemplate.LookupEntry<WorldTemplate>(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<PlayerCondition>(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)

View file

@ -36,7 +36,6 @@
#include "ObjectAccessor.h"
#include "ObjectGuid.h"
#include "Policies/Singleton.h"
#include "SQLStorages.h"
#include <string>
#include <map>
@ -45,6 +44,7 @@
class Group;
class ArenaTeam;
class Item;
class SQLStorage;
struct GameTele
{
@ -487,11 +487,6 @@ class ObjectMgr
typedef UNORDERED_MAP<uint32, WeatherZoneChances> 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<GameObjectInfo>(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<CreatureDataAddon>(lowguid);
}
static CreatureDataAddon const *GetCreatureTemplateAddon( uint32 entry )
{
return sCreatureInfoAddonStorage.LookupEntry<CreatureDataAddon>(entry);
}
static ItemPrototype const* GetItemPrototype(uint32 id) { return sItemStorage.LookupEntry<ItemPrototype>(id); }
static InstanceTemplate const* GetInstanceTemplate(uint32 map)
{
return sInstanceTemplate.LookupEntry<InstanceTemplate>(map);
}
static WorldTemplate const* GetWorldTemplate(uint32 map)
{
return sWorldTemplate.LookupEntry<WorldTemplate>(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<PlayerCondition>(conditionId))
return condition->Meets(pPlayer);
return false;
}
bool IsPlayerMeetToNEWCondition(Player const* pPlayer, uint16 conditionId) const;
GameTele const* GetGameTele(uint32 id) const
{

View file

@ -32,6 +32,7 @@
#include "NPCHandler.h"
#include "Pet.h"
#include "MapManager.h"
#include "SQLStorages.h"
void WorldSession::SendNameQueryOpcode(Player *p)
{

View file

@ -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";

View file

@ -27,6 +27,7 @@
#include "GridNotifiersImpl.h"
#include "Cell.h"
#include "CellImpl.h"
#include "SQLStorages.h"
#include "revision_nr.h"

View file

@ -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()
{
}

View file

@ -830,17 +830,7 @@ struct PetDefaultSpellsEntry
typedef std::map<int32, PetDefaultSpellsEntry> 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)
{

View file

@ -17,7 +17,6 @@
*/
#include "SQLStorage.h"
#include "SQLStorageImpl.h"
void SQLStorage::EraseEntry(uint32 id)
{

View file

@ -124,4 +124,6 @@ struct SQLStorageLoader : public SQLStorageLoaderBase<SQLStorageLoader>
{
};
#include "SQLStorageImpl.h"
#endif

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12056"
#define REVISION_NR "12057"
#endif // __REVISION_NR_H__