mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[12057] Add some static wrappers for Lookup access to SQLStorages
This commit is contained in:
parent
4e117d1ee8
commit
f24fa870c5
12 changed files with 76 additions and 83 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue