aboutsummaryrefslogtreecommitdiff
path: root/src/game/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/ObjectMgr.cpp')
-rw-r--r--src/game/ObjectMgr.cpp1463
1 files changed, 4 insertions, 1459 deletions
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 588722213cb..3c6a361ff9e 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -17,13 +17,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
#include "Common.h"
#include "Database/DatabaseEnv.h"
#include "Database/SQLStorage.h"
#include "Database/SQLStorageImpl.h"
#include "Policies/SingletonImp.h"
-
#include "Log.h"
#include "MapManager.h"
#include "ObjectMgr.h"
@@ -45,37 +43,28 @@
#include "Util.h"
#include "WaypointManager.h"
#include "InstanceData.h" //for condition_instance_data
-
INSTANTIATE_SINGLETON_1(ObjectMgr);
-
ScriptMapMap sQuestEndScripts;
ScriptMapMap sQuestStartScripts;
ScriptMapMap sSpellScripts;
ScriptMapMap sGameObjectScripts;
ScriptMapMap sEventScripts;
ScriptMapMap sWaypointScripts;
-
bool normalizePlayerName(std::string& name)
{
if(name.empty())
return false;
-
wchar_t wstr_buf[MAX_INTERNAL_PLAYER_NAME+1];
size_t wstr_len = MAX_INTERNAL_PLAYER_NAME;
-
if(!Utf8toWStr(name,&wstr_buf[0],wstr_len))
return false;
-
wstr_buf[0] = wcharToUpper(wstr_buf[0]);
for(size_t i = 1; i < wstr_len; ++i)
wstr_buf[i] = wcharToLower(wstr_buf[i]);
-
if(!WStrToUtf8(wstr_buf,wstr_len,name))
return false;
-
return true;
}
-
LanguageDesc lang_description[LANGUAGES_COUNT] =
{
{ LANG_ADDON, 0, 0 },
@@ -98,7 +87,6 @@ LanguageDesc lang_description[LANGUAGES_COUNT] =
{ LANG_GNOMISH_BINARY, 0, 0 },
{ LANG_GOBLIN_BINARY, 0, 0 }
};
-
LanguageDesc const* GetLanguageDescByID(uint32 lang)
{
for(uint8 i = 0; i < LANGUAGES_COUNT; ++i)
@@ -106,10 +94,8 @@ LanguageDesc const* GetLanguageDescByID(uint32 lang)
if(uint32(lang_description[i].lang_id) == lang)
return &lang_description[i];
}
-
return NULL;
}
-
bool SpellClickInfo::IsFitToRequirements(Player const* player, Creature const * clickNpc) const
{
if(questStart)
@@ -118,29 +104,24 @@ bool SpellClickInfo::IsFitToRequirements(Player const* player, Creature const *
if (!player || ((!questStartCanActive || !player->IsActiveQuest(questStart)) && !player->GetQuestRewardStatus(questStart)))
return false;
}
-
if(questEnd)
{
// not in expected forbidden quest state
if(!player || player->GetQuestRewardStatus(questEnd))
return false;
}
-
if (auraRequired)
if (!player->HasAura(auraRequired))
return false;
-
if (auraForbidden)
if (player->HasAura(auraForbidden))
return false;
-
Unit const * summoner = NULL;
// Check summoners for party
if (clickNpc->isSummon())
summoner = ((TempSummon*)clickNpc)->GetSummoner();
if (!summoner)
summoner = clickNpc;
-
switch (userType)
{
case SPELL_CLICK_USER_FRIEND:
@@ -156,10 +137,8 @@ bool SpellClickInfo::IsFitToRequirements(Player const* player, Creature const *
return false;
break;
}
-
return true;
}
-
ObjectMgr::ObjectMgr()
{
m_hiCharGuid = 1;
@@ -177,48 +156,36 @@ ObjectMgr::ObjectMgr()
m_guildId = 1;
m_arenaTeamId = 1;
m_auctionid = 1;
-
// Only zero condition left, others will be added while loading DB tables
mConditions.resize(1);
}
-
ObjectMgr::~ObjectMgr()
{
for( QuestMap::iterator i = mQuestTemplates.begin( ); i != mQuestTemplates.end( ); ++i )
delete i->second;
-
for(PetLevelInfoMap::iterator i = petInfo.begin( ); i != petInfo.end( ); ++i )
delete[] i->second;
-
// free only if loaded
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
delete[] playerClassInfo[class_].levelInfo;
-
for (int race = 0; race < MAX_RACES; ++race)
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
delete[] playerInfo[race][class_].levelInfo;
-
// free group and guild objects
for (GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
delete (*itr);
-
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
delete itr->second;
mGuildMap.clear();
-
for (CachePlayerInfoMap::iterator itr = m_mPlayerInfoMap.begin(); itr != m_mPlayerInfoMap.end(); ++itr)
delete itr->second;
-
for (ArenaTeamMap::iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
delete itr->second;
-
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
itr->second.Clear();
-
for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr)
itr->second.Clear();
}
-
void ObjectMgr::LoadPlayerInfoInCache()
{
QueryResult *result = CharacterDatabase.PQuery("SELECT guid, name, data, class FROM characters");
@@ -227,7 +194,6 @@ void ObjectMgr::LoadPlayerInfoInCache()
sLog.outError( "Loading Player Cache failed.");
return;
}
-
PCachePlayerInfo pPPlayerInfo = NULL;
Field *fields = NULL;
Tokens tdata;
@@ -237,33 +203,25 @@ void ObjectMgr::LoadPlayerInfoInCache()
bar.step();
fields = result->Fetch();
pPPlayerInfo = new CachePlayerInfo();
-
pPPlayerInfo->sPlayerName = fields[1].GetString();
-
tdata.clear();
tdata = StrSplit(fields[2].GetCppString(), " ");
-
pPPlayerInfo->unLevel = Player::GetUInt32ValueFromArray(tdata,UNIT_FIELD_LEVEL);
pPPlayerInfo->unfield = Player::GetUInt32ValueFromArray(tdata,UNIT_FIELD_BYTES_0);
-
pPPlayerInfo->unArenaInfoId0 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6);
pPPlayerInfo->unArenaInfoId1 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6);
pPPlayerInfo->unArenaInfoId2 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6);
-
pPPlayerInfo->unArenaInfoSlot0 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 0 * 6 + 5);
pPPlayerInfo->unArenaInfoSlot1 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 1 * 6 + 5);
pPPlayerInfo->unArenaInfoSlot2 = Player::GetUInt32ValueFromArray(tdata,PLAYER_FIELD_ARENA_TEAM_INFO_1_1 + 2 * 6 + 5);
-
pPPlayerInfo->unClass = (uint32)fields[3].GetUInt32();
m_mPlayerInfoMap[fields[0].GetUInt32()] = pPPlayerInfo;
}
while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded info about %d players", m_mPlayerInfoMap.size());
}
-
PCachePlayerInfo ObjectMgr::GetPlayerInfoFromCache(uint32 unPlayerGuid) const
{
//Now m_mPlayerInfoMap is using only for search, but when dinamic inserting/removing
@@ -273,132 +231,101 @@ PCachePlayerInfo ObjectMgr::GetPlayerInfoFromCache(uint32 unPlayerGuid) const
CachePlayerInfoMap::const_iterator ipos = m_mPlayerInfoMap.find(unPlayerGuid);
return ipos == m_mPlayerInfoMap.end() ? NULL : ipos->second;
}
-
Group * ObjectMgr::GetGroupByLeader(const uint64 &guid) const
{
for(GroupSet::const_iterator itr = mGroupSet.begin(); itr != mGroupSet.end(); ++itr)
if ((*itr)->GetLeaderGUID() == guid)
return *itr;
-
return NULL;
}
-
Guild * ObjectMgr::GetGuildById(uint32 GuildId) const
{
GuildMap::const_iterator itr = mGuildMap.find(GuildId);
if (itr != mGuildMap.end())
return itr->second;
-
return NULL;
}
-
Guild * ObjectMgr::GetGuildByName(const std::string& guildname) const
{
for(GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
if (itr->second->GetName() == guildname)
return itr->second;
-
return NULL;
}
-
std::string ObjectMgr::GetGuildNameById(uint32 GuildId) const
{
GuildMap::const_iterator itr = mGuildMap.find(GuildId);
if (itr != mGuildMap.end())
return itr->second->GetName();
-
return "";
}
-
Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const
{
for(GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
if (itr->second->GetLeader() == guid)
return itr->second;
-
return NULL;
}
-
void ObjectMgr::AddGuild(Guild* guild)
{
mGuildMap[guild->GetId()] = guild;
}
-
void ObjectMgr::RemoveGuild(uint32 Id)
{
mGuildMap.erase(Id);
}
-
ArenaTeam* ObjectMgr::GetArenaTeamById(uint32 arenateamid) const
{
ArenaTeamMap::const_iterator itr = mArenaTeamMap.find(arenateamid);
if (itr != mArenaTeamMap.end())
return itr->second;
-
return NULL;
}
-
ArenaTeam* ObjectMgr::GetArenaTeamByName(const std::string& arenateamname) const
{
for(ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
if (itr->second->GetName() == arenateamname)
return itr->second;
-
return NULL;
}
-
ArenaTeam* ObjectMgr::GetArenaTeamByCaptain(uint64 const& guid) const
{
for(ArenaTeamMap::const_iterator itr = mArenaTeamMap.begin(); itr != mArenaTeamMap.end(); ++itr)
if (itr->second->GetCaptain() == guid)
return itr->second;
-
return NULL;
}
-
void ObjectMgr::AddArenaTeam(ArenaTeam* arenaTeam)
{
mArenaTeamMap[arenaTeam->GetId()] = arenaTeam;
}
-
void ObjectMgr::RemoveArenaTeam(uint32 Id)
{
mArenaTeamMap.erase(Id);
}
-
CreatureInfo const* ObjectMgr::GetCreatureTemplate(uint32 id)
{
return sCreatureStorage.LookupEntry<CreatureInfo>(id);
}
-
void ObjectMgr::LoadCreatureLocales()
{
mCreatureLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,subname_loc1,name_loc2,subname_loc2,name_loc3,subname_loc3,name_loc4,subname_loc4,name_loc5,subname_loc5,name_loc6,subname_loc6,name_loc7,subname_loc7,name_loc8,subname_loc8 FROM locales_creature");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 creature locale strings. DB table `locales_creature` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
CreatureLocale& data = mCreatureLocaleMap[entry];
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[1+2*(i-1)].GetCppString();
@@ -409,7 +336,6 @@ void ObjectMgr::LoadCreatureLocales()
{
if(data.Name.size() <= idx)
data.Name.resize(idx+1);
-
data.Name[idx] = str;
}
}
@@ -421,52 +347,39 @@ void ObjectMgr::LoadCreatureLocales()
{
if(data.SubName.size() <= idx)
data.SubName.resize(idx+1);
-
data.SubName[idx] = str;
}
}
}
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu creature locale strings", (unsigned long)mCreatureLocaleMap.size() );
}
-
void ObjectMgr::LoadNpcOptionLocales()
{
mNpcOptionLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,"
"option_text_loc1,box_text_loc1,option_text_loc2,box_text_loc2,"
"option_text_loc3,box_text_loc3,option_text_loc4,box_text_loc4,"
"option_text_loc5,box_text_loc5,option_text_loc6,box_text_loc6,"
"option_text_loc7,box_text_loc7,option_text_loc8,box_text_loc8 "
"FROM locales_npc_option");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 npc_option locale strings. DB table `locales_npc_option` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
NpcOptionLocale& data = mNpcOptionLocaleMap[entry];
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[1+2*(i-1)].GetCppString();
@@ -477,7 +390,6 @@ void ObjectMgr::LoadNpcOptionLocales()
{
if(data.OptionText.size() <= idx)
data.OptionText.resize(idx+1);
-
data.OptionText[idx] = str;
}
}
@@ -489,70 +401,52 @@ void ObjectMgr::LoadNpcOptionLocales()
{
if(data.BoxText.size() <= idx)
data.BoxText.resize(idx+1);
-
data.BoxText[idx] = str;
}
}
}
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu npc_option locale strings", (unsigned long)mNpcOptionLocaleMap.size() );
}
-
void ObjectMgr::LoadPointOfInterestLocales()
{
mPointOfInterestLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,icon_name_loc1,icon_name_loc2,icon_name_loc3,icon_name_loc4,icon_name_loc5,icon_name_loc6,icon_name_loc7,icon_name_loc8 FROM locales_points_of_interest");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 points_of_interest locale strings. DB table `locales_points_of_interest` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
PointOfInterestLocale& data = mPointOfInterestLocaleMap[entry];
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
if(str.empty())
continue;
-
int idx = GetOrNewIndexForLocale(LocaleConstant(i));
if(idx >= 0)
{
if(data.IconName.size() <= idx)
data.IconName.resize(idx+1);
-
data.IconName[idx] = str;
}
}
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu points_of_interest locale strings", (unsigned long)mPointOfInterestLocaleMap.size() );
}
-
struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader>
{
template<class D>
@@ -561,25 +455,20 @@ struct SQLCreatureLoader : public SQLStorageLoaderBase<SQLCreatureLoader>
dst = D(objmgr.GetScriptId(src));
}
};
-
void ObjectMgr::LoadCreatureTemplates()
{
SQLCreatureLoader loader;
loader.Load(sCreatureStorage);
-
sLog.outString( ">> Loaded %u creature definitions", sCreatureStorage.RecordCount );
sLog.outString();
-
std::set<uint32> heroicEntries; // already loaded heroic value in creatures
std::set<uint32> hasHeroicEntries; // already loaded creatures with heroic entry values
-
// check data correctness
for(uint32 i = 1; i < sCreatureStorage.MaxEntry; ++i)
{
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i);
if (!cInfo)
continue;
-
if (cInfo->HeroicEntry)
{
CreatureInfo const* heroicInfo = GetCreatureTemplate(cInfo->HeroicEntry);
@@ -588,88 +477,72 @@ void ObjectMgr::LoadCreatureTemplates()
sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u not exist.", i, cInfo->HeroicEntry, cInfo->HeroicEntry);
continue;
}
-
if (heroicEntries.find(i)!=heroicEntries.end())
{
sLog.outErrorDb("Creature (Entry: %u) listed as heroic but have value in `heroic_entry`.",i);
continue;
}
-
if (heroicEntries.find(cInfo->HeroicEntry)!=heroicEntries.end())
{
sLog.outErrorDb("Creature (Entry: %u) already listed as heroic for another entry.",cInfo->HeroicEntry);
continue;
}
-
if (hasHeroicEntries.find(cInfo->HeroicEntry)!=hasHeroicEntries.end())
{
sLog.outErrorDb("Creature (Entry: %u) have `heroic_entry`=%u but creature entry %u have heroic entry also.",i,cInfo->HeroicEntry,cInfo->HeroicEntry);
continue;
}
-
if (cInfo->unit_class != heroicInfo->unit_class)
{
sLog.outErrorDb("Creature (Entry: %u, class %u) has different `unit_class` in heroic mode (Entry: %u, class %u).",i, cInfo->unit_class, cInfo->HeroicEntry, heroicInfo->unit_class);
continue;
}
-
if (cInfo->npcflag != heroicInfo->npcflag)
{
sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `npcflag` in heroic mode.",i);
continue;
}
-
if (cInfo->trainer_class != heroicInfo->trainer_class)
{
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_class` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry);
continue;
}
-
if (cInfo->trainer_race != heroicInfo->trainer_race)
{
sLog.outErrorDb("Creature (Entry: %u) has different `trainer_race` in heroic mode (Entry: %u).",i,cInfo->HeroicEntry);
continue;
}
-
if (cInfo->trainer_type != heroicInfo->trainer_type)
{
sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_type` in heroic mode.",i);
continue;
}
-
if (cInfo->trainer_spell != heroicInfo->trainer_spell)
{
sLog.outErrorDb("Creature (Entry: %u) listed in `creature_template_substitution` has different `trainer_spell` in heroic mode.",i);
continue;
}
-
if (heroicInfo->AIName && *heroicInfo->AIName)
{
sLog.outErrorDb("Heroic mode creature (Entry: %u) has `AIName`, but in any case will used normal mode creature (Entry: %u) AIName.",cInfo->HeroicEntry,i);
continue;
}
-
if (heroicInfo->ScriptID)
{
sLog.outErrorDb("Heroic mode creature (Entry: %u) has `ScriptName`, but in any case will used normal mode creature (Entry: %u) ScriptName.",cInfo->HeroicEntry,i);
continue;
}
-
hasHeroicEntries.insert(i);
heroicEntries.insert(cInfo->HeroicEntry);
}
-
FactionTemplateEntry const* factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_A);
if (!factionTemplate)
sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_A template (%u)", cInfo->Entry, cInfo->faction_A);
-
factionTemplate = sFactionTemplateStore.LookupEntry(cInfo->faction_H);
if (!factionTemplate)
sLog.outErrorDb("Creature (Entry: %u) has non-existing faction_H template (%u)", cInfo->Entry, cInfo->faction_H);
-
// used later for scale
CreatureDisplayInfoEntry const* displayScaleEntry = NULL;
-
if (cInfo->Modelid1)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid1);
@@ -680,12 +553,10 @@ void ObjectMgr::LoadCreatureTemplates()
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
-
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid1);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) not has model data for Modelid1 (%u)", cInfo->Entry, cInfo->Modelid1);
}
-
if (cInfo->Modelid2)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid2);
@@ -696,12 +567,10 @@ void ObjectMgr::LoadCreatureTemplates()
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
-
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid2);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) not has model data for Modelid2 (%u)", cInfo->Entry, cInfo->Modelid2);
}
-
if (cInfo->Modelid3)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid3);
@@ -712,12 +581,10 @@ void ObjectMgr::LoadCreatureTemplates()
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
-
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid3);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) not has model data for Modelid3 (%u)", cInfo->Entry, cInfo->Modelid3);
}
-
if (cInfo->Modelid4)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid4);
@@ -728,15 +595,12 @@ void ObjectMgr::LoadCreatureTemplates()
}
else if(!displayScaleEntry)
displayScaleEntry = displayEntry;
-
CreatureModelInfo const* minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(cInfo->Modelid4);
if (!minfo)
sLog.outErrorDb("Creature (Entry: %u) not has model data for Modelid4 (%u)", cInfo->Entry, cInfo->Modelid4);
}
-
if (!displayScaleEntry)
sLog.outErrorDb("Creature (Entry: %u) not has any existed display id in Modelid1/Modelid2/Modelid3/Modelid4", cInfo->Entry);
-
for(int k = 0; k < MAX_KILL_CREDIT; ++k)
{
if(cInfo->KillCredit[k])
@@ -748,57 +612,46 @@ void ObjectMgr::LoadCreatureTemplates()
}
}
}
-
if (cInfo->unit_class && ((1 << (cInfo->unit_class-1)) & CLASSMASK_ALL_CREATURES) == 0)
sLog.outErrorDb("Creature (Entry: %u) has invalid unit_class(%u) for creature_template", cInfo->Entry, cInfo->unit_class);
-
if(cInfo->dmgschool >= MAX_SPELL_SCHOOL)
{
sLog.outErrorDb("Creature (Entry: %u) has invalid spell school value (%u) in `dmgschool`",cInfo->Entry,cInfo->dmgschool);
const_cast<CreatureInfo*>(cInfo)->dmgschool = SPELL_SCHOOL_NORMAL;
}
-
if(cInfo->baseattacktime == 0)
const_cast<CreatureInfo*>(cInfo)->baseattacktime = BASE_ATTACK_TIME;
-
if(cInfo->rangeattacktime == 0)
const_cast<CreatureInfo*>(cInfo)->rangeattacktime = BASE_ATTACK_TIME;
-
if(cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK)
{
sLog.outErrorDb("Creature (Entry: %u) has dynamic flag UNIT_NPC_FLAG_SPELLCLICK (%u) set, it expect to be set by code base at `npc_spellclick_spells` content.",cInfo->Entry,UNIT_NPC_FLAG_SPELLCLICK);
const_cast<CreatureInfo*>(cInfo)->npcflag &= ~UNIT_NPC_FLAG_SPELLCLICK;
}
-
if((cInfo->npcflag & UNIT_NPC_FLAG_TRAINER) && cInfo->trainer_type >= MAX_TRAINER_TYPE)
sLog.outErrorDb("Creature (Entry: %u) has wrong trainer type %u",cInfo->Entry,cInfo->trainer_type);
-
if(cInfo->type && !sCreatureTypeStore.LookupEntry(cInfo->type))
{
sLog.outErrorDb("Creature (Entry: %u) has invalid creature type (%u) in `type`",cInfo->Entry,cInfo->type);
const_cast<CreatureInfo*>(cInfo)->type = CREATURE_TYPE_HUMANOID;
}
-
// must exist or used hidden but used in data horse case
if(cInfo->family && !sCreatureFamilyStore.LookupEntry(cInfo->family) && cInfo->family != CREATURE_FAMILY_HORSE_CUSTOM )
{
sLog.outErrorDb("Creature (Entry: %u) has invalid creature family (%u) in `family`",cInfo->Entry,cInfo->family);
const_cast<CreatureInfo*>(cInfo)->family = 0;
}
-
if(cInfo->InhabitType <= 0 || cInfo->InhabitType > INHABIT_ANYWHERE)
{
sLog.outErrorDb("Creature (Entry: %u) has wrong value (%u) in `InhabitType`, creature will not correctly walk/swim/fly",cInfo->Entry,cInfo->InhabitType);
const_cast<CreatureInfo*>(cInfo)->InhabitType = INHABIT_ANYWHERE;
}
-
if(cInfo->PetSpellDataId)
{
CreatureSpellDataEntry const* spellDataId = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId);
if(!spellDataId)
sLog.outErrorDb("Creature (Entry: %u) has non-existing PetSpellDataId (%u)", cInfo->Entry, cInfo->PetSpellDataId);
}
-
for(uint8 j = 0; j < CREATURE_MAX_SPELLS; ++j)
{
if(cInfo->spells[j] && !sSpellStore.LookupEntry(cInfo->spells[j]))
@@ -807,13 +660,11 @@ void ObjectMgr::LoadCreatureTemplates()
const_cast<CreatureInfo*>(cInfo)->spells[j] = 0;
}
}
-
if(cInfo->MovementType >= MAX_DB_MOTION_TYPE)
{
sLog.outErrorDb("Creature (Entry: %u) has wrong movement generator type (%u), ignore and set to IDLE.",cInfo->Entry,cInfo->MovementType);
const_cast<CreatureInfo*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
}
-
if(cInfo->equipmentId > 0) // 0 no equipment
{
if(!GetEquipmentInfo(cInfo->equipmentId))
@@ -822,7 +673,6 @@ void ObjectMgr::LoadCreatureTemplates()
const_cast<CreatureInfo*>(cInfo)->equipmentId = 0;
}
}
-
/// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc
if(cInfo->scale <= 0.0f)
{
@@ -831,11 +681,9 @@ void ObjectMgr::LoadCreatureTemplates()
else
const_cast<CreatureInfo*>(cInfo)->scale = 1.0f;
}
-
const_cast<CreatureInfo*>(cInfo)->dmg_multiplier *= Creature::_GetDamageMod(cInfo->rank);
}
}
-
void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const* table, char const* guidEntryStr)
{
// Now add the auras, format "spellid effectindex spellid effectindex..."
@@ -855,10 +703,8 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
}
if (p!=s)
val.push_back(atoi(s));
-
// free char* loaded memory
delete[] (char*)reinterpret_cast<char const*>(addon->auras);
-
// wrong list
if (val.size()%2)
{
@@ -867,17 +713,14 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
return;
}
}
-
// empty list
if(val.empty())
{
addon->auras = NULL;
return;
}
-
// replace by new structures array
const_cast<CreatureDataAddonAura*&>(addon->auras) = new CreatureDataAddonAura[val.size()/2+1];
-
uint32 i=0;
for(uint32 j = 0; j < val.size()/2;++j)
{
@@ -895,36 +738,29 @@ void ObjectMgr::ConvertCreatureAddonAuras(CreatureDataAddon* addon, char const*
sLog.outErrorDb("Creature (%s: %u) has wrong spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.spell_id,table);
continue;
}
-
if (!AdditionalSpellInfo->Effect[cAura.effect_idx] || !AdditionalSpellInfo->EffectApplyAuraName[cAura.effect_idx])
{
sLog.outErrorDb("Creature (%s: %u) has not aura effect %u of spell %u defined in `auras` field in `%s`.",guidEntryStr,addon->guidOrEntry,cAura.effect_idx,cAura.spell_id,table);
continue;
}
-
++i;
}
-
// fill terminator element (after last added)
CreatureDataAddonAura& endAura = const_cast<CreatureDataAddonAura&>(addon->auras[i]);
endAura.spell_id = 0;
endAura.effect_idx = 0;
}
-
void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entryName, char const* comment)
{
creatureaddons.Load();
-
sLog.outString(">> Loaded %u %s", creatureaddons.RecordCount, comment);
sLog.outString();
-
// check data correctness and convert 'auras'
for(uint32 i = 1; i < creatureaddons.MaxEntry; ++i)
{
CreatureDataAddon const* addon = creatureaddons.LookupEntry<CreatureDataAddon>(i);
if(!addon)
continue;
-
if (addon->mount)
{
if (!sCreatureDisplayInfoStore.LookupEntry(addon->mount))
@@ -933,69 +769,54 @@ void ObjectMgr::LoadCreatureAddons(SQLStorage& creatureaddons, char const* entry
const_cast<CreatureDataAddon*>(addon)->mount = 0;
}
}
-
if (!sEmotesStore.LookupEntry(addon->emote))
sLog.outErrorDb("Creature (%s %u) have invalid emote (%u) defined in `%s`.", entryName, addon->guidOrEntry, addon->emote, creatureaddons.GetTableName());
-
/*if (addon->move_flags & (MONSTER_MOVE_UNK1|MONSTER_MOVE_UNK4))
{
sLog.outErrorDb("Creature (%s %u) movement flags mask defined in `%s` include forbidden flags (" I32FMT ") that can crash client, cleanup at load.", entryName, addon->guidOrEntry, creatureaddons.GetTableName(), (MONSTER_MOVE_UNK1|MONSTER_MOVE_UNK4));
const_cast<CreatureDataAddon*>(addon)->move_flags &= ~(MONSTER_MOVE_UNK1|MONSTER_MOVE_UNK4);
}*/
-
ConvertCreatureAddonAuras(const_cast<CreatureDataAddon*>(addon), creatureaddons.GetTableName(), entryName);
}
}
-
void ObjectMgr::LoadCreatureAddons()
{
LoadCreatureAddons(sCreatureInfoAddonStorage,"Entry","creature template addons");
-
// check entry ids
for(uint32 i = 1; i < sCreatureInfoAddonStorage.MaxEntry; ++i)
if(CreatureDataAddon const* addon = sCreatureInfoAddonStorage.LookupEntry<CreatureDataAddon>(i))
if(!sCreatureStorage.LookupEntry<CreatureInfo>(addon->guidOrEntry))
sLog.outErrorDb("Creature (Entry: %u) does not exist but has a record in `%s`",addon->guidOrEntry, sCreatureInfoAddonStorage.GetTableName());
-
LoadCreatureAddons(sCreatureDataAddonStorage,"GUID","creature addons");
-
// check entry ids
for(uint32 i = 1; i < sCreatureDataAddonStorage.MaxEntry; ++i)
if(CreatureDataAddon const* addon = sCreatureDataAddonStorage.LookupEntry<CreatureDataAddon>(i))
if(mCreatureDataMap.find(addon->guidOrEntry)==mCreatureDataMap.end())
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();
-
for(uint32 i=0; i< sEquipmentStorage.MaxEntry; ++i)
{
EquipmentInfo const* eqInfo = sEquipmentStorage.LookupEntry<EquipmentInfo>(i);
-
if(!eqInfo)
continue;
-
for(uint8 j=0; j<3; j++)
{
if(!eqInfo->equipentry[j])
continue;
-
ItemEntry const *dbcitem = sItemStore.LookupEntry(eqInfo->equipentry[j]);
-
if(!dbcitem)
{
sLog.outErrorDb("Unknown item (entry=%u) in creature_equip_template.equipentry%u for entry = %u, forced to 0.", eqInfo->equipentry[j], j+1, i);
const_cast<EquipmentInfo*>(eqInfo)->equipentry[j] = 0;
continue;
}
-
if(dbcitem->InventoryType != INVTYPE_WEAPON &&
dbcitem->InventoryType != INVTYPE_SHIELD &&
dbcitem->InventoryType != INVTYPE_RANGED &&
@@ -1014,24 +835,20 @@ void ObjectMgr::LoadEquipmentTemplates()
sLog.outString( ">> Loaded %u equipment template", sEquipmentStorage.RecordCount );
sLog.outString();
}
-
CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelid)
{
return sCreatureModelStorage.LookupEntry<CreatureModelInfo>(modelid);
}
-
uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const CreatureData *data /*= NULL*/)
{
// Load creature model (display id)
uint32 display_id = 0;
-
if (!data || data->displayid == 0)
{
display_id = cinfo->GetRandomValidModelId();
}
else
return data->displayid;
-
/*if(!team)
{
switch(cinfo->Entry)
@@ -1049,16 +866,13 @@ uint32 ObjectMgr::ChooseDisplayId(uint32 team, const CreatureInfo *cinfo, const
return cinfo->GetRandomValidModelId();
}
}*/
-
return display_id;
}
-
CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_id)
{
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)
{
@@ -1074,44 +888,36 @@ CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32 display_
else
return minfo;
}
-
void ObjectMgr::LoadCreatureModelInfo()
{
sCreatureModelStorage.Load();
-
// post processing
for(uint32 i = 1; i < sCreatureModelStorage.MaxEntry; ++i)
{
CreatureModelInfo const *minfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(i);
if (!minfo)
continue;
-
if (!sCreatureDisplayInfoStore.LookupEntry(minfo->modelid))
sLog.outErrorDb("Table `creature_model_info` has model for not existed display id (%u).", minfo->modelid);
-
if (minfo->gender > GENDER_NONE)
{
sLog.outErrorDb("Table `creature_model_info` has wrong gender (%u) for display id (%u).", uint32(minfo->gender), minfo->modelid);
const_cast<CreatureModelInfo*>(minfo)->gender = GENDER_MALE;
}
-
if (minfo->modelid_other_gender && !sCreatureDisplayInfoStore.LookupEntry(minfo->modelid_other_gender))
{
sLog.outErrorDb("Table `creature_model_info` has not existed alt.gender model (%u) for existed display id (%u).", minfo->modelid_other_gender, minfo->modelid);
const_cast<CreatureModelInfo*>(minfo)->modelid_other_gender = 0;
}
}
-
sLog.outString( ">> Loaded %u creature model based info", sCreatureModelStorage.RecordCount );
sLog.outString();
-
// check if combat_reach is valid
for(uint32 i = 1; i < sCreatureModelStorage.MaxEntry; ++i)
{
CreatureModelInfo const* mInfo = sCreatureModelStorage.LookupEntry<CreatureModelInfo>(i);
if(!mInfo)
continue;
-
if(mInfo->combat_reach < 0.1f)
{
//sLog.outErrorDb("Creature model (Entry: %u) has invalid combat reach (%f), setting it to 0.5", mInfo->modelid, mInfo->combat_reach);
@@ -1119,86 +925,66 @@ void ObjectMgr::LoadCreatureModelInfo()
}
}
}
-
bool ObjectMgr::CheckCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid) const
{
const CreatureData* const slave = GetCreatureData(guid);
const CreatureData* const master = GetCreatureData(linkedGuid);
-
if(!slave || !master) // they must have a corresponding entry in db
{
sLog.outError("LinkedRespawn: Creature '%u' linking to '%u' which doesn't exist",guid,linkedGuid);
return false;
}
-
const MapEntry* const map = sMapStore.LookupEntry(master->mapid);
-
if(master->mapid != slave->mapid // link only to same map
&& (!map || map->Instanceable())) // or to unistanced world
{
sLog.outError("LinkedRespawn: Creature '%u' linking to '%u' on an unpermitted map",guid,linkedGuid);
return false;
}
-
if(!(master->spawnMask & slave->spawnMask) // they must have a possibility to meet (normal/heroic difficulty)
&& (!map || map->Instanceable()))
{
sLog.outError("LinkedRespawn: Creature '%u' linking to '%u' with not corresponding spawnMask",guid,linkedGuid);
return false;
}
-
return true;
}
-
void ObjectMgr::LoadCreatureLinkedRespawn()
{
mCreatureLinkedRespawnMap.clear();
QueryResult *result = WorldDatabase.Query("SELECT guid, linkedGuid FROM creature_linked_respawn ORDER BY guid ASC");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString("");
sLog.outErrorDb(">> Loaded 0 linked respawns. DB table `creature_linked_respawn` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 guid = fields[0].GetUInt32();
uint32 linkedGuid = fields[1].GetUInt32();
-
if(CheckCreatureLinkedRespawn(guid,linkedGuid))
mCreatureLinkedRespawnMap[guid] = linkedGuid;
-
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u linked respawns", mCreatureLinkedRespawnMap.size() );
}
-
bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid)
{
if(!guid)
return false;
-
if(!linkedGuid) // we're removing the linking
{
mCreatureLinkedRespawnMap.erase(guid);
WorldDatabase.DirectPExecute("DELETE FROM creature_linked_respawn WHERE guid = '%u'",guid);
return true;
}
-
if(CheckCreatureLinkedRespawn(guid,linkedGuid)) // we add/change linking
{
mCreatureLinkedRespawnMap[guid] = linkedGuid;
@@ -1207,7 +993,6 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guid, uint32 linkedGuid)
}
return false;
}
-
void ObjectMgr::LoadCreatures()
{
uint32 count = 0;
@@ -1219,47 +1004,36 @@ void ObjectMgr::LoadCreatures()
"curhealth, curmana, DeathState, MovementType, spawnMask, phaseMask, event, pool_entry "
"FROM creature LEFT OUTER JOIN game_event_creature ON creature.guid = game_event_creature.guid "
"LEFT OUTER JOIN pool_creature ON creature.guid = pool_creature.guid");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 creature. DB table `creature` is empty.");
return;
}
-
// build single time for check creature data
std::set<uint32> heroicCreatures;
for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i)
if(CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i))
if(cInfo->HeroicEntry)
heroicCreatures.insert(cInfo->HeroicEntry);
-
//TODO: remove this
//gameeventmgr.mGameEventCreatureGuids.resize(52*2-1);
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 guid = fields[ 0].GetUInt32();
uint32 entry = fields[ 1].GetUInt32();
-
CreatureInfo const* cInfo = GetCreatureTemplate(entry);
if(!cInfo)
{
sLog.outErrorDb("Table `creature` has creature (GUID: %u) with non existing creature entry %u, skipped.", guid, entry);
continue;
}
-
CreatureData& data = mCreatureDataMap[guid];
-
data.id = entry;
data.mapid = fields[ 2].GetUInt32();
data.displayid = fields[ 3].GetUInt32();
@@ -1279,13 +1053,11 @@ void ObjectMgr::LoadCreatures()
data.phaseMask = fields[17].GetUInt16();
int16 gameEvent = fields[18].GetInt16();
int16 PoolId = fields[19].GetInt16();
-
if(heroicCreatures.find(data.id)!=heroicCreatures.end())
{
sLog.outErrorDb("Table `creature` have creature (GUID: %u) that listed as heroic template (entry: %u) in `creature_template_substitution`, skipped.",guid,data.id );
continue;
}
-
// I do not know why but in db most display id are not zero
/*if(data.displayid == 11686 || data.displayid == 24719)
{
@@ -1295,7 +1067,6 @@ void ObjectMgr::LoadCreatures()
|| data.displayid == cInfo->DisplayID_H || data.displayid == cInfo->DisplayID_H2)
data.displayid = 0;
*/
-
if(data.equipmentId > 0) // -1 no equipment, 0 use default
{
if(!GetEquipmentInfo(data.equipmentId))
@@ -1304,26 +1075,22 @@ void ObjectMgr::LoadCreatures()
data.equipmentId = -1;
}
}
-
if(cInfo->RegenHealth && data.curhealth < cInfo->minhealth)
{
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`RegenHealth`=1 and low current health (%u), `creature_template`.`minhealth`=%u.",guid,data.id,data.curhealth, cInfo->minhealth );
data.curhealth = cInfo->minhealth;
}
-
if(cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
{
MapEntry const* map = sMapStore.LookupEntry(data.mapid);
if(!map || !map->IsDungeon())
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.",guid,data.id);
}
-
if(data.curmana < cInfo->minmana)
{
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with low current mana (%u), `creature_template`.`minmana`=%u.",guid,data.id,data.curmana, cInfo->minmana );
data.curmana = cInfo->minmana;
}
-
if(data.spawndist < 0.0f)
{
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.",guid,data.id );
@@ -1347,13 +1114,11 @@ void ObjectMgr::LoadCreatures()
data.spawndist = 0.0f;
}
}
-
if(data.phaseMask==0)
{
sLog.outErrorDb("Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id );
data.phaseMask = 1;
}
-
//if(entry == 32307 || entry == 32308)
/*if(entry == 30739 || entry == 30740)
{
@@ -1367,20 +1132,14 @@ void ObjectMgr::LoadCreatures()
gameeventmgr.mGameEventCreatureGuids[51+51].push_back(guid);
gameeventmgr.mGameEventCreatureGuids[51+50].push_back(guid2);
}*/
-
if (gameEvent==0 && PoolId==0) // if not this is to be managed by GameEvent System or Pool system
AddCreatureToGrid(guid, &data);
-
++count;
-
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu creatures", (unsigned long)mCreatureDataMap.size() );
}
-
void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data)
{
uint8 mask = data->spawnMask;
@@ -1390,13 +1149,11 @@ void ObjectMgr::AddCreatureToGrid(uint32 guid, CreatureData const* data)
{
CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
-
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id];
cell_guids.creatures.insert(guid);
}
}
}
-
void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data)
{
uint8 mask = data->spawnMask;
@@ -1406,23 +1163,19 @@ void ObjectMgr::RemoveCreatureFromGrid(uint32 guid, CreatureData const* data)
{
CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
-
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id];
cell_guids.creatures.erase(guid);
}
}
}
-
uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay, float rotation0, float rotation1, float rotation2, float rotation3)
{
GameObjectInfo const* goinfo = GetGameObjectInfo(entry);
if (!goinfo)
return 0;
-
Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId));
if(!map)
return 0;
-
uint32 guid = GenerateLowGuid(HIGHGUID_GAMEOBJECT);
GameObjectData& data = NewGOData(guid);
data.id = entry;
@@ -1442,9 +1195,7 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
data.phaseMask = PHASEMASK_NORMAL;
data.artKit = goinfo->type == GAMEOBJECT_TYPE_CAPTURE_POINT ? 21 : 0;
data.dbData = false;
-
AddGameobjectToGrid(guid, &data);
-
// Spawn if necessary (loaded grids only)
// We use spawn coords to spawn
if(!map->Instanceable() && !map->IsRemovalGrid(x, y))
@@ -1458,18 +1209,14 @@ uint32 ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, float y, float
}
map->Add(go);
}
-
sLog.outDebug("AddGOData: dbguid %u entry %u map %u x %f y %f z %f o %f", guid, entry, mapId, x, y, z, o);
-
return guid;
}
-
uint32 ObjectMgr::AddCreData(uint32 entry, uint32 team, uint32 mapId, float x, float y, float z, float o, uint32 spawntimedelay)
{
CreatureInfo const *cInfo = GetCreatureTemplate(entry);
if(!cInfo)
return 0;
-
uint32 guid = GenerateLowGuid(HIGHGUID_UNIT);
CreatureData& data = NewOrExistCreatureData(guid);
data.id = entry;
@@ -1490,9 +1237,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 team, uint32 mapId, float x, f
data.spawnMask = 1;
data.phaseMask = PHASEMASK_NORMAL;
data.dbData = false;
-
AddCreatureToGrid(guid, &data);
-
// Spawn if necessary (loaded grids only)
if(Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId)))
{
@@ -1509,57 +1254,44 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 team, uint32 mapId, float x, f
map->Add(creature);
}
}
-
- return guid;
+ return guid;
}
-
void ObjectMgr::LoadGameobjects()
{
uint32 count = 0;
-
// 0 1 2 3 4 5 6
QueryResult *result = WorldDatabase.Query("SELECT gameobject.guid, id, map, position_x, position_y, position_z, orientation,"
// 7 8 9 10 11 12 13 14 15 16 17
"rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state, spawnMask, phaseMask, event, pool_entry "
"FROM gameobject LEFT OUTER JOIN game_event_gameobject ON gameobject.guid = game_event_gameobject.guid "
"LEFT OUTER JOIN pool_gameobject ON gameobject.guid = pool_gameobject.guid");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 gameobjects. DB table `gameobject` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 guid = fields[ 0].GetUInt32();
uint32 entry = fields[ 1].GetUInt32();
-
GameObjectInfo const* gInfo = GetGameObjectInfo(entry);
if (!gInfo)
{
sLog.outErrorDb("Table `gameobject` has gameobject (GUID: %u) with non existing gameobject entry %u, skipped.", guid, entry);
continue;
}
-
if (gInfo->displayId && !sGameObjectDisplayInfoStore.LookupEntry(gInfo->displayId))
{
sLog.outErrorDb("Gameobject (GUID: %u Entry %u GoType: %u) have invalid displayId (%u), not loaded.",guid, entry, gInfo->type, gInfo->displayId);
continue;
}
-
GameObjectData& data = mGameObjectDataMap[guid];
-
data.id = entry;
data.mapid = fields[ 2].GetUInt32();
data.posX = fields[ 3].GetFloat();
@@ -1571,15 +1303,12 @@ void ObjectMgr::LoadGameobjects()
data.rotation2 = fields[ 9].GetFloat();
data.rotation3 = fields[10].GetFloat();
data.spawntimesecs = fields[11].GetInt32();
-
if (data.spawntimesecs==0 && gInfo->IsDespawnAtAction())
{
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with `spawntimesecs` (0) value, but gameobejct marked as despawnable at action.",guid,data.id);
}
-
data.animprogress = fields[12].GetUInt32();
data.artKit = 0;
-
uint32 go_state = fields[13].GetUInt32();
if (go_state >= MAX_GO_STATE)
{
@@ -1587,48 +1316,38 @@ void ObjectMgr::LoadGameobjects()
continue;
}
data.go_state = GOState(go_state);
-
data.spawnMask = fields[14].GetUInt8();
data.phaseMask = fields[15].GetUInt16();
int16 gameEvent = fields[16].GetInt16();
int16 PoolId = fields[17].GetInt16();
-
if (data.rotation2 < -1.0f || data.rotation2 > 1.0f)
{
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation2 (%f) value, skip",guid,data.id,data.rotation2 );
continue;
}
-
if (data.rotation3 < -1.0f || data.rotation3 > 1.0f)
{
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid rotation3 (%f) value, skip",guid,data.id,data.rotation3 );
continue;
}
-
if (!MapManager::IsValidMapCoord(data.mapid,data.posX,data.posY,data.posZ,data.orientation))
{
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with invalid coordinates, skip",guid,data.id );
continue;
}
-
if (data.phaseMask==0)
{
sLog.outErrorDb("Table `gameobject` have gameobject (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.",guid,data.id );
data.phaseMask = 1;
}
-
if (gameEvent==0 && PoolId==0) // if not this is to be managed by GameEvent System or Pool system
AddGameobjectToGrid(guid, &data);
++count;
-
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu gameobjects", (unsigned long)mGameObjectDataMap.size());
}
-
void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data)
{
uint8 mask = data->spawnMask;
@@ -1638,13 +1357,11 @@ void ObjectMgr::AddGameobjectToGrid(uint32 guid, GameObjectData const* data)
{
CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
-
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id];
cell_guids.gameobjects.insert(guid);
}
}
}
-
void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data)
{
uint8 mask = data->spawnMask;
@@ -1654,113 +1371,81 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data
{
CellPair cell_pair = Trinity::ComputeCellPair(data->posX, data->posY);
uint32 cell_id = (cell_pair.y_coord*TOTAL_NUMBER_OF_CELLS_PER_MAP) + cell_pair.x_coord;
-
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(data->mapid,i)][cell_id];
cell_guids.gameobjects.erase(guid);
}
}
}
-
void ObjectMgr::LoadCreatureRespawnTimes()
{
uint32 count = 0;
-
QueryResult *result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM creature_respawn");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 creature respawn time.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 loguid = fields[0].GetUInt32();
uint64 respawn_time = fields[1].GetUInt64();
uint32 instance = fields[2].GetUInt32();
-
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time);
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString( ">> Loaded %lu creature respawn times", (unsigned long)mCreatureRespawnTimes.size() );
sLog.outString();
}
-
void ObjectMgr::LoadGameobjectRespawnTimes()
{
// remove outdated data
WorldDatabase.DirectExecute("DELETE FROM gameobject_respawn WHERE respawntime <= UNIX_TIMESTAMP(NOW())");
-
uint32 count = 0;
-
QueryResult *result = WorldDatabase.Query("SELECT guid,respawntime,instance FROM gameobject_respawn");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 gameobject respawn time.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 loguid = fields[0].GetUInt32();
uint64 respawn_time = fields[1].GetUInt64();
uint32 instance = fields[2].GetUInt32();
-
mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = time_t(respawn_time);
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString( ">> Loaded %lu gameobject respawn times", (unsigned long)mGORespawnTimes.size() );
sLog.outString();
}
-
// name must be checked to correctness (if received) before call this function
uint64 ObjectMgr::GetPlayerGUIDByName(std::string name) const
{
uint64 guid = 0;
-
CharacterDatabase.escape_string(name);
-
// Player name safe to sending to DB (checked at login) and this function using
QueryResult *result = CharacterDatabase.PQuery("SELECT guid FROM characters WHERE name = '%s'", name.c_str());
if(result)
{
guid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
-
delete result;
}
-
return guid;
}
-
bool ObjectMgr::GetPlayerNameByGUID(const uint64 &guid, std::string &name) const
{
// prevent DB access for online player
@@ -1769,40 +1454,32 @@ bool ObjectMgr::GetPlayerNameByGUID(const uint64 &guid, std::string &name) const
name = player->GetName();
return true;
}
-
PCachePlayerInfo pInfo = GetPlayerInfoFromCache(GUID_LOPART(guid));
if(pInfo)
{
name = pInfo->sPlayerName.c_str();
return true;
}
-
QueryResult *result = CharacterDatabase.PQuery("SELECT name FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
-
if(result)
{
name = (*result)[0].GetCppString();
delete result;
return true;
}
-
return false;
}
-
uint32 ObjectMgr::GetPlayerTeamByGUID(const uint64 &guid) const
{
QueryResult *result = CharacterDatabase.PQuery("SELECT race FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
-
if(result)
{
uint8 race = (*result)[0].GetUInt8();
delete result;
return Player::TeamForRace(race);
}
-
return 0;
}
-
uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const
{
QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE guid = '%u'", GUID_LOPART(guid));
@@ -1812,10 +1489,8 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(const uint64 &guid) const
delete result;
return acc;
}
-
return 0;
}
-
uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(const std::string& name) const
{
QueryResult *result = CharacterDatabase.PQuery("SELECT account FROM characters WHERE name = '%s'", name.c_str());
@@ -1825,38 +1500,27 @@ uint32 ObjectMgr::GetPlayerAccountIdByPlayerName(const std::string& name) const
delete result;
return acc;
}
-
return 0;
}
-
void ObjectMgr::LoadItemLocales()
{
mItemLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,name_loc1,description_loc1,name_loc2,description_loc2,name_loc3,description_loc3,name_loc4,description_loc4,name_loc5,description_loc5,name_loc6,description_loc6,name_loc7,description_loc7,name_loc8,description_loc8 FROM locales_item");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 Item locale strings. DB table `locales_item` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
ItemLocale& data = mItemLocaleMap[entry];
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[1+2*(i-1)].GetCppString();
@@ -1867,11 +1531,9 @@ void ObjectMgr::LoadItemLocales()
{
if(data.Name.size() <= idx)
data.Name.resize(idx+1);
-
data.Name[idx] = str;
}
}
-
str = fields[1+2*(i-1)+1].GetCppString();
if(!str.empty())
{
@@ -1880,19 +1542,15 @@ void ObjectMgr::LoadItemLocales()
{
if(data.Description.size() <= idx)
data.Description.resize(idx+1);
-
data.Description[idx] = str;
}
}
}
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu Item locale strings", (unsigned long)mItemLocaleMap.size() );
}
-
struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader>
{
template<class D>
@@ -1901,14 +1559,12 @@ struct SQLItemLoader : public SQLStorageLoaderBase<SQLItemLoader>
dst = D(objmgr.GetScriptId(src));
}
};
-
void ObjectMgr::LoadItemPrototypes()
{
SQLItemLoader loader;
loader.Load(sItemStorage);
sLog.outString( ">> Loaded %u item prototypes", sItemStorage.RecordCount );
sLog.outString();
-
// check data correctness
for(uint32 i = 1; i < sItemStorage.MaxEntry; ++i)
{
@@ -1922,7 +1578,6 @@ void ObjectMgr::LoadItemPrototypes()
*/
continue;
}
-
if(dbcitem)
{
if(proto->Class != dbcitem->Class)
@@ -1938,25 +1593,21 @@ void ObjectMgr::LoadItemPrototypes()
// It safe let use Subclass from DB
}
*/
-
if(proto->Unk0 != dbcitem->Unk0)
{
sLog.outErrorDb("Item (Entry: %u) not correct %i Unk0, must be %i (still using DB value).",i,proto->Unk0,dbcitem->Unk0);
// It safe let use Unk0 from DB
}
-
if(proto->Material != dbcitem->Material)
{
sLog.outErrorDb("Item (Entry: %u) not correct %i material, must be %i (still using DB value).",i,proto->Material,dbcitem->Material);
// It safe let use Material from DB
}
-
if(proto->InventoryType != dbcitem->InventoryType)
{
sLog.outErrorDb("Item (Entry: %u) not correct %u inventory type, must be %u (still using DB value).",i,proto->InventoryType,dbcitem->InventoryType);
// It safe let use InventoryType from DB
}
-
if(proto->DisplayInfoID != dbcitem->DisplayId)
{
sLog.outErrorDb("Item (Entry: %u) not correct %u display id, must be %u (using it).",i,proto->DisplayInfoID,dbcitem->DisplayId);
@@ -1972,43 +1623,36 @@ void ObjectMgr::LoadItemPrototypes()
{
sLog.outErrorDb("Item (Entry: %u) not correct (not listed in list of existed items).",i);
}
-
if(proto->Class >= MAX_ITEM_CLASS)
{
sLog.outErrorDb("Item (Entry: %u) has wrong Class value (%u)",i,proto->Class);
const_cast<ItemPrototype*>(proto)->Class = ITEM_CLASS_MISC;
}
-
if(proto->SubClass >= MaxItemSubclassValues[proto->Class])
{
sLog.outErrorDb("Item (Entry: %u) has wrong Subclass value (%u) for class %u",i,proto->SubClass,proto->Class);
const_cast<ItemPrototype*>(proto)->SubClass = 0;// exist for all item classes
}
-
if(proto->Quality >= MAX_ITEM_QUALITY)
{
sLog.outErrorDb("Item (Entry: %u) has wrong Quality value (%u)",i,proto->Quality);
const_cast<ItemPrototype*>(proto)->Quality = ITEM_QUALITY_NORMAL;
}
-
if(proto->BuyCount <= 0)
{
sLog.outErrorDb("Item (Entry: %u) has wrong BuyCount value (%u), set to default(1).",i,proto->BuyCount);
const_cast<ItemPrototype*>(proto)->BuyCount = 1;
}
-
if(proto->InventoryType >= MAX_INVTYPE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong InventoryType value (%u)",i,proto->InventoryType);
const_cast<ItemPrototype*>(proto)->InventoryType = INVTYPE_NON_EQUIP;
}
-
if(proto->RequiredSkill >= MAX_SKILL_TYPE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong RequiredSkill value (%u)",i,proto->RequiredSkill);
const_cast<ItemPrototype*>(proto)->RequiredSkill = 0;
}
-
{
// can be used in equip slot, as page read use in inventory, or spell casting at use
bool req = proto->InventoryType!=INVTYPE_NON_EQUIP || proto->PageText;
@@ -2023,26 +1667,21 @@ void ObjectMgr::LoadItemPrototypes()
}
}
}
-
if(req)
{
if(!(proto->AllowableClass & CLASSMASK_ALL_PLAYABLE))
sLog.outErrorDb("Item (Entry: %u) not have in `AllowableClass` any playable classes (%u) and can't be equipped or use.",i,proto->AllowableClass);
-
if(!(proto->AllowableRace & RACEMASK_ALL_PLAYABLE))
sLog.outErrorDb("Item (Entry: %u) not have in `AllowableRace` any playable races (%u) and can't be equipped or use.",i,proto->AllowableRace);
}
}
-
if(proto->RequiredSpell && !sSpellStore.LookupEntry(proto->RequiredSpell))
{
sLog.outErrorDb("Item (Entry: %u) have wrong (non-existed) spell in RequiredSpell (%u)",i,proto->RequiredSpell);
const_cast<ItemPrototype*>(proto)->RequiredSpell = 0;
}
-
if(proto->RequiredReputationRank >= MAX_REPUTATION_RANK)
sLog.outErrorDb("Item (Entry: %u) has wrong reputation rank in RequiredReputationRank (%u), item can't be used.",i,proto->RequiredReputationRank);
-
if(proto->RequiredReputationFaction)
{
if(!sFactionStore.LookupEntry(proto->RequiredReputationFaction))
@@ -2050,17 +1689,14 @@ void ObjectMgr::LoadItemPrototypes()
sLog.outErrorDb("Item (Entry: %u) has wrong (not existing) faction in RequiredReputationFaction (%u)",i,proto->RequiredReputationFaction);
const_cast<ItemPrototype*>(proto)->RequiredReputationFaction = 0;
}
-
if(proto->RequiredReputationRank == MIN_REPUTATION_RANK)
sLog.outErrorDb("Item (Entry: %u) has min. reputation rank in RequiredReputationRank (0) but RequiredReputationFaction > 0, faction setting is useless.",i);
}
-
if(proto->MaxCount < -1)
{
sLog.outErrorDb("Item (Entry: %u) has too large negative in maxcount (%i), replace by value (-1) no storing limits.",i,proto->MaxCount);
const_cast<ItemPrototype*>(proto)->MaxCount = -1;
}
-
if(proto->Stackable == 0)
{
sLog.outErrorDb("Item (Entry: %u) has wrong value in stackable (%i), replace by default 1.",i,proto->Stackable);
@@ -2076,19 +1712,16 @@ void ObjectMgr::LoadItemPrototypes()
sLog.outErrorDb("Item (Entry: %u) has too large value in stackable (%u), replace by hardcoded upper limit (1000).",i,proto->Stackable);
const_cast<ItemPrototype*>(proto)->Stackable = 1000;
}
-
if(proto->ContainerSlots > MAX_BAG_SIZE)
{
sLog.outErrorDb("Item (Entry: %u) has too large value in ContainerSlots (%u), replace by hardcoded limit (%u).",i,proto->ContainerSlots,MAX_BAG_SIZE);
const_cast<ItemPrototype*>(proto)->ContainerSlots = MAX_BAG_SIZE;
}
-
if(proto->StatsCount > MAX_ITEM_PROTO_STATS)
{
sLog.outErrorDb("Item (Entry: %u) has too large value in statscount (%u), replace by hardcoded limit (%u).",i,proto->StatsCount,MAX_ITEM_PROTO_STATS);
const_cast<ItemPrototype*>(proto)->StatsCount = MAX_ITEM_PROTO_STATS;
}
-
for (int j = 0; j < MAX_ITEM_PROTO_STATS; ++j)
{
// for ItemStatValue != 0
@@ -2097,7 +1730,6 @@ void ObjectMgr::LoadItemPrototypes()
sLog.outErrorDb("Item (Entry: %u) has wrong stat_type%d (%u)",i,j+1,proto->ItemStat[j].ItemStatType);
const_cast<ItemPrototype*>(proto)->ItemStat[j].ItemStatType = 0;
}
-
switch(proto->ItemStat[j].ItemStatType)
{
case ITEM_MOD_SPELL_HEALING_DONE:
@@ -2108,7 +1740,6 @@ void ObjectMgr::LoadItemPrototypes()
break;
}
}
-
for (int j = 0; j < MAX_ITEM_PROTO_DAMAGES; ++j)
{
if(proto->Damage[j].DamageType >= MAX_SPELL_SCHOOL)
@@ -2117,7 +1748,6 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->Damage[j].DamageType = 0;
}
}
-
// special format
if((proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN) || (proto->Spells[0].SpellId == SPELL_ID_GENERIC_LEARN_PET))
{
@@ -2130,7 +1760,6 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->Spells[1].SpellId = 0;
const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
}
-
// spell_2 have learning spell
if(proto->Spells[1].SpellTrigger != ITEM_SPELLTRIGGER_LEARN_SPELL_ID)
{
@@ -2164,7 +1793,6 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->Spells[1].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
}
}
-
// spell_3*,spell_4*,spell_5* is empty
for (int j = 2; j < MAX_ITEM_PROTO_SPELLS; ++j)
{
@@ -2192,7 +1820,6 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->Spells[j].SpellId = 0;
const_cast<ItemPrototype*>(proto)->Spells[j].SpellTrigger = ITEM_SPELLTRIGGER_ON_USE;
}
-
if(proto->Spells[j].SpellId)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(proto->Spells[j].SpellId);
@@ -2210,46 +1837,36 @@ void ObjectMgr::LoadItemPrototypes()
}
}
}
-
if(proto->Bonding >= MAX_BIND_TYPE)
sLog.outErrorDb("Item (Entry: %u) has wrong Bonding value (%u)",i,proto->Bonding);
-
if(proto->PageText && !sPageTextStore.LookupEntry<PageText>(proto->PageText))
sLog.outErrorDb("Item (Entry: %u) has non existing first page (Id:%u)", i,proto->PageText);
-
if(proto->LockID && !sLockStore.LookupEntry(proto->LockID))
sLog.outErrorDb("Item (Entry: %u) has wrong LockID (%u)",i,proto->LockID);
-
if(proto->Sheath >= MAX_SHEATHETYPE)
{
sLog.outErrorDb("Item (Entry: %u) has wrong Sheath (%u)",i,proto->Sheath);
const_cast<ItemPrototype*>(proto)->Sheath = SHEATHETYPE_NONE;
}
-
if(proto->RandomProperty && !sItemRandomPropertiesStore.LookupEntry(GetItemEnchantMod(proto->RandomProperty)))
{
sLog.outErrorDb("Item (Entry: %u) has unknown (wrong or not listed in `item_enchantment_template`) RandomProperty (%u)",i,proto->RandomProperty);
const_cast<ItemPrototype*>(proto)->RandomProperty = 0;
}
-
if(proto->RandomSuffix && !sItemRandomSuffixStore.LookupEntry(GetItemEnchantMod(proto->RandomSuffix)))
{
sLog.outErrorDb("Item (Entry: %u) has wrong RandomSuffix (%u)",i,proto->RandomSuffix);
const_cast<ItemPrototype*>(proto)->RandomSuffix = 0;
}
-
if(proto->ItemSet && !sItemSetStore.LookupEntry(proto->ItemSet))
{
sLog.outErrorDb("Item (Entry: %u) have wrong ItemSet (%u)",i,proto->ItemSet);
const_cast<ItemPrototype*>(proto)->ItemSet = 0;
}
-
if(proto->Area && !GetAreaEntryByAreaID(proto->Area))
sLog.outErrorDb("Item (Entry: %u) has wrong Area (%u)",i,proto->Area);
-
if(proto->Map && !sMapStore.LookupEntry(proto->Map))
sLog.outErrorDb("Item (Entry: %u) has wrong Map (%u)",i,proto->Map);
-
if(proto->BagFamily)
{
// check bits
@@ -2258,7 +1875,6 @@ void ObjectMgr::LoadItemPrototypes()
uint32 mask = 1 << j;
if((proto->BagFamily & mask)==0)
continue;
-
ItemBagFamilyEntry const* bf = sItemBagFamilyStore.LookupEntry(j+1);
if(!bf)
{
@@ -2266,7 +1882,6 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->BagFamily &= ~mask;
continue;
}
-
if(BAG_FAMILY_MASK_CURRENCY_TOKENS & mask)
{
CurrencyTypesEntry const* ctEntry = sCurrencyTypesStore.LookupEntry(proto->ItemId);
@@ -2278,10 +1893,8 @@ void ObjectMgr::LoadItemPrototypes()
}
}
}
-
if(proto->TotemCategory && !sTotemCategoryStore.LookupEntry(proto->TotemCategory))
sLog.outErrorDb("Item (Entry: %u) has wrong TotemCategory (%u)",i,proto->TotemCategory);
-
for (int j = 0; j < MAX_ITEM_PROTO_SOCKETS; ++j)
{
if(proto->Socket[j].Color && (proto->Socket[j].Color & SOCKET_COLOR_ALL) != proto->Socket[j].Color)
@@ -2290,22 +1903,18 @@ void ObjectMgr::LoadItemPrototypes()
const_cast<ItemPrototype*>(proto)->Socket[j].Color = 0;
}
}
-
if(proto->GemProperties && !sGemPropertiesStore.LookupEntry(proto->GemProperties))
sLog.outErrorDb("Item (Entry: %u) has wrong GemProperties (%u)",i,proto->GemProperties);
-
if(proto->FoodType >= MAX_PET_DIET)
{
sLog.outErrorDb("Item (Entry: %u) has wrong FoodType value (%u)",i,proto->FoodType);
const_cast<ItemPrototype*>(proto)->FoodType = 0;
}
-
if(proto->ItemLimitCategory && !sItemLimitCategoryStore.LookupEntry(proto->ItemLimitCategory))
{
sLog.outErrorDb("Item (Entry: %u) has wrong LimitCategory value (%u)",i,proto->ItemLimitCategory);
const_cast<ItemPrototype*>(proto)->ItemLimitCategory = 0;
}
-
if(proto->HolidayId && !sHolidaysStore.LookupEntry(proto->HolidayId))
{
sLog.outErrorDb("Item (Entry: %u) has wrong HolidayId value (%u)", i, proto->HolidayId);
@@ -2313,47 +1922,34 @@ void ObjectMgr::LoadItemPrototypes()
}
}
}
-
void ObjectMgr::LoadItemRequiredTarget()
{
m_ItemRequiredTarget.clear(); // needed for reload case
-
uint32 count = 0;
-
QueryResult *result = WorldDatabase.Query("SELECT entry,type,targetEntry FROM item_required_target");
-
if (!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 ItemRequiredTarget. DB table `item_required_target` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 uiItemId = fields[0].GetUInt32();
uint32 uiType = fields[1].GetUInt32();
uint32 uiTargetEntry = fields[2].GetUInt32();
-
ItemPrototype const* pItemProto = sItemStorage.LookupEntry<ItemPrototype>(uiItemId);
-
if (!pItemProto)
{
sLog.outErrorDb("Table `item_required_target`: Entry %u listed for TargetEntry %u does not exist in `item_template`.",uiItemId,uiTargetEntry);
continue;
}
-
bool bIsItemSpellValid = false;
-
for(uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
{
if (SpellEntry const* pSpellInfo = sSpellStore.LookupEntry(pItemProto->Spells[i].SpellId))
@@ -2364,7 +1960,6 @@ void ObjectMgr::LoadItemRequiredTarget()
SpellScriptTargetBounds bounds = spellmgr.GetSpellScriptTargetBounds(pSpellInfo->Id);
if (bounds.first != bounds.second)
break;
-
for (int j = 0; j < 3; ++j)
{
if (pSpellInfo->EffectImplicitTargetA[i] == TARGET_UNIT_TARGET_ENEMY ||
@@ -2381,74 +1976,58 @@ void ObjectMgr::LoadItemRequiredTarget()
}
}
}
-
if (!bIsItemSpellValid)
{
sLog.outErrorDb("Table `item_required_target`: Spell used by item %u does not have implicit target TARGET_CHAIN_DAMAGE(6), TARGET_DUELVSPLAYER(25), already listed in `spell_script_target` or doesn't have item spelltrigger.",uiItemId);
continue;
}
-
if (!uiType || uiType > MAX_ITEM_REQ_TARGET_TYPE)
{
sLog.outErrorDb("Table `item_required_target`: Type %u for TargetEntry %u is incorrect.",uiType,uiTargetEntry);
continue;
}
-
if (!uiTargetEntry)
{
sLog.outErrorDb("Table `item_required_target`: TargetEntry == 0 for Type (%u).",uiType);
continue;
}
-
if (!sCreatureStorage.LookupEntry<CreatureInfo>(uiTargetEntry))
{
sLog.outErrorDb("Table `item_required_target`: creature template entry %u does not exist.",uiTargetEntry);
continue;
}
-
m_ItemRequiredTarget.insert(ItemRequiredTargetMap::value_type(uiItemId,ItemRequiredTarget(ItemRequiredTargetType(uiType),uiTargetEntry)));
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString(">> Loaded %u Item required targets", count);
}
-
void ObjectMgr::LoadPetLevelInfo()
{
// Loading levels data
{
// 0 1 2 3 4 5 6 7 8 9
QueryResult *result = WorldDatabase.Query("SELECT creature_entry, level, hp, mana, str, agi, sta, inte, spi, armor FROM pet_levelstats");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
sLog.outString();
sLog.outString( ">> Loaded %u level pet stats definitions", count );
sLog.outErrorDb( "Error loading `pet_levelstats` table or empty table.");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 creature_id = fields[0].GetUInt32();
if(!sCreatureStorage.LookupEntry<CreatureInfo>(creature_id))
{
sLog.outErrorDb("Wrong creature id %u in `pet_levelstats` table, ignoring.",creature_id);
continue;
}
-
uint32 current_level = fields[1].GetUInt32();
if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
@@ -2466,47 +2045,36 @@ void ObjectMgr::LoadPetLevelInfo()
sLog.outErrorDb("Wrong (<1) level %u in `pet_levelstats` table, ignoring.",current_level);
continue;
}
-
PetLevelInfo*& pInfoMapEntry = petInfo[creature_id];
-
if(pInfoMapEntry==NULL)
pInfoMapEntry = new PetLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)];
-
// data for level 1 stored in [0] array element, ...
PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level-1];
-
pLevelInfo->health = fields[2].GetUInt16();
pLevelInfo->mana = fields[3].GetUInt16();
pLevelInfo->armor = fields[9].GetUInt16();
-
for (int i = 0; i < MAX_STATS; i++)
{
pLevelInfo->stats[i] = fields[i+4].GetUInt16();
}
-
bar.step();
++count;
}
while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u level pet stats definitions", count );
}
-
// Fill gaps and check integrity
for (PetLevelInfoMap::iterator itr = petInfo.begin(); itr != petInfo.end(); ++itr)
{
PetLevelInfo* pInfo = itr->second;
-
// fatal error if no level 1 data
if(!pInfo || pInfo[0].health == 0 )
{
sLog.outErrorDb("Creature %u does not have pet stats data for Level 1!",itr->first);
exit(1);
}
-
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
@@ -2518,44 +2086,34 @@ void ObjectMgr::LoadPetLevelInfo()
}
}
}
-
PetLevelInfo const* ObjectMgr::GetPetLevelInfo(uint32 creature_id, uint32 level) const
{
if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL);
-
PetLevelInfoMap::const_iterator itr = petInfo.find(creature_id);
if(itr == petInfo.end())
return NULL;
-
return &itr->second[level-1]; // data for level 1 stored in [0] array element, ...
}
-
void ObjectMgr::LoadPlayerInfo()
{
// Load playercreate
{
// 0 1 2 3 4 5 6
QueryResult *result = WorldDatabase.Query("SELECT race, class, map, zone, position_x, position_y, position_z FROM playercreateinfo");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
sLog.outString();
sLog.outString( ">> Loaded %u player create definitions", count );
sLog.outErrorDb( "Error loading `playercreateinfo` table or empty table.");
exit(1);
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 current_race = fields[0].GetUInt32();
uint32 current_class = fields[1].GetUInt32();
uint32 mapId = fields[2].GetUInt32();
@@ -2563,152 +2121,118 @@ void ObjectMgr::LoadPlayerInfo()
float positionX = fields[4].GetFloat();
float positionY = fields[5].GetFloat();
float positionZ = fields[6].GetFloat();
-
if(current_race >= MAX_RACES)
{
sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race);
continue;
}
-
ChrRacesEntry const* rEntry = sChrRacesStore.LookupEntry(current_race);
if(!rEntry)
{
sLog.outErrorDb("Wrong race %u in `playercreateinfo` table, ignoring.",current_race);
continue;
}
-
if(current_class >= MAX_CLASSES)
{
sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class);
continue;
}
-
if(!sChrClassesStore.LookupEntry(current_class))
{
sLog.outErrorDb("Wrong class %u in `playercreateinfo` table, ignoring.",current_class);
continue;
}
-
// accept DB data only for valid position (and non instanceable)
if( !MapManager::IsValidMapCoord(mapId,positionX,positionY,positionZ) )
{
sLog.outErrorDb("Wrong home position for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race);
continue;
}
-
if( sMapStore.LookupEntry(mapId)->Instanceable() )
{
sLog.outErrorDb("Home position in instanceable map for class %u race %u pair in `playercreateinfo` table, ignoring.",current_class,current_race);
continue;
}
-
PlayerInfo* pInfo = &playerInfo[current_race][current_class];
-
pInfo->mapId = mapId;
pInfo->zoneId = zoneId;
pInfo->positionX = positionX;
pInfo->positionY = positionY;
pInfo->positionZ = positionZ;
-
pInfo->displayId_m = rEntry->model_m;
pInfo->displayId_f = rEntry->model_f;
-
bar.step();
++count;
}
while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u player create definitions", count );
}
-
// Load playercreate items
{
// 0 1 2 3
QueryResult *result = WorldDatabase.Query("SELECT race, class, itemid, amount FROM playercreateinfo_item");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u custom player create items", count );
}
else
{
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES)
{
sLog.outErrorDb("Wrong race %u in `playercreateinfo_item` table, ignoring.",current_race);
continue;
}
-
uint32 current_class = fields[1].GetUInt32();
if(current_class >= MAX_CLASSES)
{
sLog.outErrorDb("Wrong class %u in `playercreateinfo_item` table, ignoring.",current_class);
continue;
}
-
PlayerInfo* pInfo = &playerInfo[current_race][current_class];
-
uint32 item_id = fields[2].GetUInt32();
-
if(!GetItemPrototype(item_id))
{
sLog.outErrorDb("Item id %u (race %u class %u) in `playercreateinfo_item` table but not listed in `item_template`, ignoring.",item_id,current_race,current_class);
continue;
}
-
uint32 amount = fields[3].GetUInt32();
-
if(!amount)
{
sLog.outErrorDb("Item id %u (class %u race %u) have amount==0 in `playercreateinfo_item` table, ignoring.",item_id,current_race,current_class);
continue;
}
-
pInfo->item.push_back(PlayerCreateInfoItem( item_id, amount));
-
bar.step();
++count;
}
while(result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u custom player create items", count );
}
}
-
// Load playercreate spells
{
-
QueryResult *result = NULL;
if(sWorld.getConfig(CONFIG_START_ALL_SPELLS))
result = WorldDatabase.Query("SELECT race, class, Spell, Active FROM playercreateinfo_spell_custom");
else
result = WorldDatabase.Query("SELECT race, class, Spell FROM playercreateinfo_spell");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
sLog.outString();
sLog.outString( ">> Loaded %u player create spells", count );
sLog.outErrorDb( "Error loading player starting spells or empty table.");
@@ -2716,25 +2240,21 @@ void ObjectMgr::LoadPlayerInfo()
else
{
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES)
{
sLog.outErrorDb("Wrong race %u in `playercreateinfo_spell` table, ignoring.",current_race);
continue;
}
-
uint32 current_class = fields[1].GetUInt32();
if(current_class >= MAX_CLASSES)
{
sLog.outErrorDb("Wrong class %u in `playercreateinfo_spell` table, ignoring.",current_class);
continue;
}
-
if(!current_race || !current_class)
{
uint32 min_race = current_race ? current_race : 1;
@@ -2747,30 +2267,23 @@ void ObjectMgr::LoadPlayerInfo()
}
else
playerInfo[current_race][current_class].spell.push_back(fields[2].GetUInt32());
-
bar.step();
++count;
}
while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u player create spells", count );
}
}
-
// Load playercreate actions
{
// 0 1 2 3 4
QueryResult *result = WorldDatabase.Query("SELECT race, class, button, action, type FROM playercreateinfo_action");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
sLog.outString();
sLog.outString( ">> Loaded %u player create actions", count );
sLog.outErrorDb( "Error loading `playercreateinfo_action` table or empty table.");
@@ -2778,70 +2291,55 @@ void ObjectMgr::LoadPlayerInfo()
else
{
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES)
{
sLog.outErrorDb("Wrong race %u in `playercreateinfo_action` table, ignoring.",current_race);
continue;
}
-
uint32 current_class = fields[1].GetUInt32();
if(current_class >= MAX_CLASSES)
{
sLog.outErrorDb("Wrong class %u in `playercreateinfo_action` table, ignoring.",current_class);
continue;
}
-
PlayerInfo* pInfo = &playerInfo[current_race][current_class];
pInfo->action.push_back(PlayerCreateInfoAction(fields[2].GetUInt8(),fields[3].GetUInt32(),fields[4].GetUInt8()));
-
bar.step();
++count;
}
while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u player create actions", count );
}
}
-
// Loading levels data (class only dependent)
{
// 0 1 2 3
QueryResult *result = WorldDatabase.Query("SELECT class, level, basehp, basemana FROM player_classlevelstats");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
sLog.outString();
sLog.outString( ">> Loaded %u level health/mana definitions", count );
sLog.outErrorDb( "Error loading `player_classlevelstats` table or empty table.");
exit(1);
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 current_class = fields[0].GetUInt32();
if(current_class >= MAX_CLASSES)
{
sLog.outErrorDb("Wrong class %u in `player_classlevelstats` table, ignoring.",current_class);
continue;
}
-
uint32 current_level = fields[1].GetUInt32();
if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
@@ -2854,44 +2352,33 @@ void ObjectMgr::LoadPlayerInfo()
}
continue;
}
-
PlayerClassInfo* pClassInfo = &playerClassInfo[current_class];
-
if(!pClassInfo->levelInfo)
pClassInfo->levelInfo = new PlayerClassLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)];
-
PlayerClassLevelInfo* pClassLevelInfo = &pClassInfo->levelInfo[current_level-1];
-
pClassLevelInfo->basehealth = fields[2].GetUInt16();
pClassLevelInfo->basemana = fields[3].GetUInt16();
-
bar.step();
++count;
}
while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u level health/mana definitions", count );
}
-
// Fill gaps and check integrity
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
{
// skip non existed classes
if(!sChrClassesStore.LookupEntry(class_))
continue;
-
PlayerClassInfo* pClassInfo = &playerClassInfo[class_];
-
// fatal error if no level 1 data
if(!pClassInfo->levelInfo || pClassInfo->levelInfo[0].basehealth == 0 )
{
sLog.outErrorDb("Class %i Level 1 does not have health/mana data!",class_);
exit(1);
}
-
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
@@ -2902,44 +2389,35 @@ void ObjectMgr::LoadPlayerInfo()
}
}
}
-
// Loading levels data (class/race dependent)
{
// 0 1 2 3 4 5 6 7
QueryResult *result = WorldDatabase.Query("SELECT race, class, level, str, agi, sta, inte, spi FROM player_levelstats");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
sLog.outString();
sLog.outString( ">> Loaded %u level stats definitions", count );
sLog.outErrorDb( "Error loading `player_levelstats` table or empty table.");
exit(1);
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 current_race = fields[0].GetUInt32();
if(current_race >= MAX_RACES)
{
sLog.outErrorDb("Wrong race %u in `player_levelstats` table, ignoring.",current_race);
continue;
}
-
uint32 current_class = fields[1].GetUInt32();
if(current_class >= MAX_CLASSES)
{
sLog.outErrorDb("Wrong class %u in `player_levelstats` table, ignoring.",current_class);
continue;
}
-
uint32 current_level = fields[2].GetUInt32();
if(current_level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
@@ -2952,64 +2430,49 @@ void ObjectMgr::LoadPlayerInfo()
}
continue;
}
-
PlayerInfo* pInfo = &playerInfo[current_race][current_class];
-
if(!pInfo->levelInfo)
pInfo->levelInfo = new PlayerLevelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)];
-
PlayerLevelInfo* pLevelInfo = &pInfo->levelInfo[current_level-1];
-
for (int i = 0; i < MAX_STATS; i++)
{
pLevelInfo->stats[i] = fields[i+3].GetUInt8();
}
-
bar.step();
++count;
}
while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u level stats definitions", count );
}
-
// Fill gaps and check integrity
for (int race = 0; race < MAX_RACES; ++race)
{
// skip non existed races
if(!sChrRacesStore.LookupEntry(race))
continue;
-
for (int class_ = 0; class_ < MAX_CLASSES; ++class_)
{
// skip non existed classes
if(!sChrClassesStore.LookupEntry(class_))
continue;
-
PlayerInfo* pInfo = &playerInfo[race][class_];
-
// skip non loaded combinations
if(!pInfo->displayId_m || !pInfo->displayId_f)
continue;
-
// skip expansion races if not playing with expansion
if (sWorld.getConfig(CONFIG_EXPANSION) < 1 && (race == RACE_BLOODELF || race == RACE_DRAENEI))
continue;
-
// skip expansion classes if not playing with expansion
if (sWorld.getConfig(CONFIG_EXPANSION) < 2 && class_ == CLASS_DEATH_KNIGHT)
continue;
-
// fatal error if no level 1 data
if(!pInfo->levelInfo || pInfo->levelInfo[0].stats[0] == 0 )
{
sLog.outErrorDb("Race %i Class %i Level 1 does not have stats data!",race,class_);
exit(1);
}
-
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
@@ -3021,37 +2484,28 @@ void ObjectMgr::LoadPlayerInfo()
}
}
}
-
// Loading xp per level data
{
mPlayerXPperLevel.resize(sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));
for (uint32 level = 0; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
mPlayerXPperLevel[level] = 0;
-
// 0 1
QueryResult *result = WorldDatabase.Query("SELECT lvl, xp_for_next_level FROM player_xp_for_level");
-
uint32 count = 0;
-
if (!result)
{
barGoLink bar( 1 );
-
sLog.outString();
sLog.outString( ">> Loaded %u xp for level definitions", count );
sLog.outErrorDb( "Error loading `player_xp_for_level` table or empty table.");
exit(1);
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field* fields = result->Fetch();
-
uint32 current_level = fields[0].GetUInt32();
uint32 current_xp = fields[1].GetUInt32();
-
if(current_level >= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
{
if(current_level > STRONG_MAX_LEVEL) // hardcoded level maximum
@@ -3069,13 +2523,10 @@ void ObjectMgr::LoadPlayerInfo()
++count;
}
while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u xp for level definitions", count );
}
-
// fill level gaps
for (uint32 level = 1; level < sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL); ++level)
{
@@ -3086,40 +2537,31 @@ void ObjectMgr::LoadPlayerInfo()
}
}
}
-
void ObjectMgr::GetPlayerClassLevelInfo(uint32 class_, uint32 level, PlayerClassLevelInfo* info) const
{
if(level < 1 || class_ >= MAX_CLASSES)
return;
-
PlayerClassInfo const* pInfo = &playerClassInfo[class_];
-
if(level > sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
level = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL);
-
*info = pInfo->levelInfo[level-1];
}
-
void ObjectMgr::GetPlayerLevelInfo(uint32 race, uint32 class_, uint32 level, PlayerLevelInfo* info) const
{
if(level < 1 || race >= MAX_RACES || class_ >= MAX_CLASSES)
return;
-
PlayerInfo const* pInfo = &playerInfo[race][class_];
if(pInfo->displayId_m==0 || pInfo->displayId_f==0)
return;
-
if(level <= sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL))
*info = pInfo->levelInfo[level-1];
else
BuildPlayerLevelInfo(race,class_,level,info);
}
-
void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, PlayerLevelInfo* info) const
{
// base data (last known level)
*info = playerInfo[race][_class].levelInfo[sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)-1];
-
// if conversion from uint32 to uint8 causes unexpected behaviour, change lvl to uint32
for(uint8 lvl = sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL)-1; lvl < level; ++lvl)
{
@@ -3190,35 +2632,25 @@ void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, Play
}
}
}
-
void ObjectMgr::LoadGuilds()
{
Guild *newguild;
uint32 count = 0;
-
QueryResult *result = CharacterDatabase.Query( "SELECT guildid FROM guild" );
-
if( !result )
{
-
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u guild definitions", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field *fields = result->Fetch();
-
bar.step();
++count;
-
newguild = new Guild;
if(!newguild->LoadGuildFromDB(fields[0].GetUInt32()))
{
@@ -3227,47 +2659,33 @@ void ObjectMgr::LoadGuilds()
continue;
}
AddGuild(newguild);
-
}while( result->NextRow() );
-
delete result;
-
//delete unused LogGuid records in guild_eventlog and guild_bank_eventlog table
//you can comment these lines if you don't plan to change CONFIG_GUILD_EVENT_LOG_COUNT and CONFIG_GUILD_BANK_EVENT_LOG_COUNT
CharacterDatabase.PQuery("DELETE FROM guild_eventlog WHERE LogGuid > '%u'", sWorld.getConfig(CONFIG_GUILD_EVENT_LOG_COUNT));
CharacterDatabase.PQuery("DELETE FROM guild_bank_eventlog WHERE LogGuid > '%u'", sWorld.getConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT));
-
sLog.outString();
sLog.outString( ">> Loaded %u guild definitions", count );
}
-
void ObjectMgr::LoadArenaTeams()
{
uint32 count = 0;
-
QueryResult *result = CharacterDatabase.Query( "SELECT arenateamid FROM arena_team" );
-
if( !result )
{
-
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u arenateam definitions", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field *fields = result->Fetch();
-
bar.step();
++count;
-
ArenaTeam *newarenateam = new ArenaTeam;
if(!newarenateam->LoadArenaTeamFromDB(fields[0].GetUInt32()))
{
@@ -3276,13 +2694,10 @@ void ObjectMgr::LoadArenaTeams()
}
AddArenaTeam(newarenateam);
}while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u arenateam definitions", count );
}
-
void ObjectMgr::LoadGroups()
{
// -- loading groups --
@@ -3291,27 +2706,21 @@ void ObjectMgr::LoadGroups()
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
QueryResult *result = CharacterDatabase.Query("SELECT mainTank, mainAssistant, lootMethod, looterGuid, lootThreshold, icon1, icon2, icon3, icon4, icon5, icon6, icon7, icon8, isRaid, difficulty, leaderGuid FROM groups");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u group definitions", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
bar.step();
Field *fields = result->Fetch();
++count;
leaderGuid = MAKE_NEW_GUID(fields[15].GetUInt32(),0,HIGHGUID_PLAYER);
-
group = new Group;
if(!group->LoadGroupFromDB(leaderGuid, result, false))
{
@@ -3321,12 +2730,9 @@ void ObjectMgr::LoadGroups()
}
AddGroup(group);
}while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u group definitions", count );
-
// -- loading members --
count = 0;
group = NULL;
@@ -3357,7 +2763,6 @@ void ObjectMgr::LoadGroups()
continue;
}
}
-
if(!group->LoadMemberFromDB(fields[0].GetUInt32(), fields[2].GetUInt8(), fields[1].GetBool()))
{
sLog.outErrorDb("Incorrect entry in group_member table : member %d cannot be added to player %d's group!", fields[0].GetUInt32(), fields[3].GetUInt32());
@@ -3366,7 +2771,6 @@ void ObjectMgr::LoadGroups()
}while( result->NextRow() );
delete result;
}
-
// clean groups
// TODO: maybe delete from the DB before loading in this case
for(GroupSet::iterator itr = mGroupSet.begin(); itr != mGroupSet.end();)
@@ -3380,7 +2784,6 @@ void ObjectMgr::LoadGroups()
else
++itr;
}
-
// -- loading instances --
count = 0;
group = NULL;
@@ -3392,7 +2795,6 @@ void ObjectMgr::LoadGroups()
"(SELECT COUNT(*) FROM character_instance WHERE guid = leaderGuid AND instance = group_instance.instance AND permanent = 1 LIMIT 1) "
"FROM group_instance LEFT JOIN instance ON instance = id ORDER BY leaderGuid"
);
-
if(!result)
{
barGoLink bar2( 1 );
@@ -3416,36 +2818,29 @@ void ObjectMgr::LoadGroups()
continue;
}
}
-
MapEntry const* mapEntry = sMapStore.LookupEntry(fields[1].GetUInt32());
if(!mapEntry || !mapEntry->IsDungeon())
{
sLog.outErrorDb("Incorrect entry in group_instance table : no dungeon map %d", fields[1].GetUInt32());
continue;
}
-
InstanceSave *save = sInstanceSaveManager.AddInstanceSave(mapEntry->MapID, fields[2].GetUInt32(), fields[4].GetUInt8(), (time_t)fields[5].GetUInt64(), (fields[6].GetUInt32() == 0), true);
group->BindToInstance(save, fields[3].GetBool(), true);
}while( result->NextRow() );
delete result;
}
-
sLog.outString();
sLog.outString( ">> Loaded %u group-instance binds total", count );
-
sLog.outString();
sLog.outString( ">> Loaded %u group members total", count );
}
-
void ObjectMgr::LoadQuests()
{
// For reload case
for(QuestMap::const_iterator itr=mQuestTemplates.begin(); itr != mQuestTemplates.end(); ++itr)
delete itr->second;
mQuestTemplates.clear();
-
mExclusiveQuestGroups.clear();
-
// 0 1 2 3 4 5 6 7 8
QueryResult *result = WorldDatabase.Query("SELECT entry, Method, ZoneOrSort, SkillOrClass, MinLevel, QuestLevel, Type, RequiredRaces, RequiredSkillValue,"
// 9 10 11 12 13 14 15 16
@@ -3485,13 +2880,11 @@ void ObjectMgr::LoadQuests()
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded 0 quests definitions" );
sLog.outErrorDb("`quest_template` table is empty!");
return;
}
-
// create multimap previous quest for each existed quest
// some quests can have many previous maps set by NextQuestId in previous quest
// for example set of race quests can lead to single not race specific quest
@@ -3500,32 +2893,25 @@ void ObjectMgr::LoadQuests()
{
bar.step();
Field *fields = result->Fetch();
-
Quest * newQuest = new Quest(fields);
mQuestTemplates[newQuest->GetQuestId()] = newQuest;
} while( result->NextRow() );
-
delete result;
-
// Post processing
for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); ++iter)
{
Quest * qinfo = iter->second;
-
// additional quest integrity checks (GO, creature_template and item_template must be loaded already)
-
if( qinfo->GetQuestMethod() >= 3 )
{
sLog.outErrorDb("Quest %u has `Method` = %u, expected values are 0, 1 or 2.",qinfo->GetQuestId(),qinfo->GetQuestMethod());
}
-
if (qinfo->QuestFlags & ~QUEST_TRINITY_FLAGS_DB_ALLOWED)
{
sLog.outErrorDb("Quest %u has `SpecialFlags` = %u > max allowed value. Correct `SpecialFlags` to value <= %u",
qinfo->GetQuestId(),qinfo->QuestFlags,QUEST_TRINITY_FLAGS_DB_ALLOWED >> 16);
qinfo->QuestFlags &= QUEST_TRINITY_FLAGS_DB_ALLOWED;
}
-
if(qinfo->QuestFlags & (QUEST_FLAGS_DAILY | QUEST_FLAGS_WEEKLY))
{
if(!(qinfo->QuestFlags & QUEST_TRINITY_FLAGS_REPEATABLE))
@@ -3534,7 +2920,6 @@ void ObjectMgr::LoadQuests()
qinfo->QuestFlags |= QUEST_TRINITY_FLAGS_REPEATABLE;
}
}
-
if(qinfo->QuestFlags & QUEST_FLAGS_AUTO_REWARDED)
{
// at auto-reward can be rewarded only RewChoiceItemId[0]
@@ -3548,7 +2933,6 @@ void ObjectMgr::LoadQuests()
}
}
}
-
// client quest log visual (area case)
if( qinfo->ZoneOrSort > 0 )
{
@@ -3591,7 +2975,6 @@ void ObjectMgr::LoadQuests()
}
}
}
-
// SkillOrClass (class case)
if( qinfo->SkillOrClass < 0 )
{
@@ -3610,7 +2993,6 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),qinfo->SkillOrClass,qinfo->SkillOrClass);
}
}
-
if( qinfo->RequiredSkillValue )
{
if( qinfo->RequiredSkillValue > sWorld.GetConfigMaxSkillValue() )
@@ -3619,7 +3001,6 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),qinfo->RequiredSkillValue,sWorld.GetConfigMaxSkillValue());
// no changes, quest can't be done for this requirement
}
-
if( qinfo->SkillOrClass <= 0 )
{
sLog.outErrorDb("Quest %u has `RequiredSkillValue` = %u but `SkillOrClass` = %i (class case), value ignored.",
@@ -3628,63 +3009,54 @@ void ObjectMgr::LoadQuests()
}
}
// else Skill quests can have 0 skill level, this is ok
-
if(qinfo->RepObjectiveFaction && !sFactionStore.LookupEntry(qinfo->RepObjectiveFaction))
{
sLog.outErrorDb("Quest %u has `RepObjectiveFaction` = %u but faction template %u does not exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->RepObjectiveFaction,qinfo->RepObjectiveFaction);
// no changes, quest can't be done for this requirement
}
-
if(qinfo->RequiredMinRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMinRepFaction))
{
sLog.outErrorDb("Quest %u has `RequiredMinRepFaction` = %u but faction template %u does not exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMinRepFaction,qinfo->RequiredMinRepFaction);
// no changes, quest can't be done for this requirement
}
-
if(qinfo->RequiredMaxRepFaction && !sFactionStore.LookupEntry(qinfo->RequiredMaxRepFaction))
{
sLog.outErrorDb("Quest %u has `RequiredMaxRepFaction` = %u but faction template %u does not exist, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMaxRepFaction,qinfo->RequiredMaxRepFaction);
// no changes, quest can't be done for this requirement
}
-
if(qinfo->RequiredMinRepValue && qinfo->RequiredMinRepValue > ReputationMgr::Reputation_Cap)
{
sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but max reputation is %u, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMinRepValue,ReputationMgr::Reputation_Cap);
// no changes, quest can't be done for this requirement
}
-
if(qinfo->RequiredMinRepValue && qinfo->RequiredMaxRepValue && qinfo->RequiredMaxRepValue <= qinfo->RequiredMinRepValue)
{
sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d and `RequiredMinRepValue` = %d, quest can't be done.",
qinfo->GetQuestId(),qinfo->RequiredMaxRepValue,qinfo->RequiredMinRepValue);
// no changes, quest can't be done for this requirement
}
-
if(!qinfo->RepObjectiveFaction && qinfo->RepObjectiveValue > 0 )
{
sLog.outErrorDb("Quest %u has `RepObjectiveValue` = %d but `RepObjectiveFaction` is 0, value has no effect",
qinfo->GetQuestId(),qinfo->RepObjectiveValue);
// warning
}
-
if(!qinfo->RequiredMinRepFaction && qinfo->RequiredMinRepValue > 0 )
{
sLog.outErrorDb("Quest %u has `RequiredMinRepValue` = %d but `RequiredMinRepFaction` is 0, value has no effect",
qinfo->GetQuestId(),qinfo->RequiredMinRepValue);
// warning
}
-
if(!qinfo->RequiredMaxRepFaction && qinfo->RequiredMaxRepValue > 0 )
{
sLog.outErrorDb("Quest %u has `RequiredMaxRepValue` = %d but `RequiredMaxRepFaction` is 0, value has no effect",
qinfo->GetQuestId(),qinfo->RequiredMaxRepValue);
// warning
}
-
if(qinfo->CharTitleId && !sCharTitlesStore.LookupEntry(qinfo->CharTitleId))
{
sLog.outErrorDb("Quest %u has `CharTitleId` = %u but CharTitle Id %u does not exist, quest can't be rewarded with title.",
@@ -3692,7 +3064,6 @@ void ObjectMgr::LoadQuests()
qinfo->CharTitleId = 0;
// quest can't reward this title
}
-
if(qinfo->SrcItemId)
{
if(!sItemStorage.LookupEntry<ItemPrototype>(qinfo->SrcItemId))
@@ -3714,7 +3085,6 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),qinfo->SrcItemCount);
qinfo->SrcItemCount=0; // no quest work changes in fact
}
-
if(qinfo->SrcSpell)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->SrcSpell);
@@ -3731,7 +3101,6 @@ void ObjectMgr::LoadQuests()
qinfo->SrcSpell = 0; // quest can't be done for this requirement
}
}
-
for(uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j )
{
uint32 id = qinfo->ReqItemId[j];
@@ -3743,9 +3112,7 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),j+1,id,j+1);
// no changes, quest can't be done for this requirement
}
-
qinfo->SetFlag(QUEST_TRINITY_FLAGS_DELIVER);
-
if(!sItemStorage.LookupEntry<ItemPrototype>(id))
{
sLog.outErrorDb("Quest %u has `ReqItemId%d` = %u but item with entry %u does not exist, quest can't be done.",
@@ -3760,7 +3127,6 @@ void ObjectMgr::LoadQuests()
qinfo->ReqItemCount[j] = 0; // prevent incorrect work of quest
}
}
-
for(uint8 j = 0; j < QUEST_SOURCE_ITEM_IDS_COUNT; ++j )
{
uint32 id = qinfo->ReqSourceId[j];
@@ -3783,7 +3149,6 @@ void ObjectMgr::LoadQuests()
}
}
}
-
for(uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j )
{
uint32 id = qinfo->ReqSpell[j];
@@ -3796,7 +3161,6 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),j+1,id,id);
continue;
}
-
if(!qinfo->ReqCreatureOrGOId[j])
{
bool found = false;
@@ -3809,13 +3173,11 @@ void ObjectMgr::LoadQuests()
break;
}
}
-
if(found)
{
if(!qinfo->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT))
{
sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE or SPELL_EFFECT_SEND_EVENT for quest %u and ReqCreatureOrGOId%d = 0, but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT. Quest flags or ReqCreatureOrGOId%d must be fixed, quest modified to enable objective.",spellInfo->Id,qinfo->QuestId,j+1,j+1);
-
// this will prevent quest completing without objective
const_cast<Quest*>(qinfo)->SetFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT);
}
@@ -3829,7 +3191,6 @@ void ObjectMgr::LoadQuests()
}
}
}
-
for(uint8 j = 0; j < QUEST_OBJECTIVES_COUNT; ++j )
{
int32 id = qinfo->ReqCreatureOrGOId[j];
@@ -3839,20 +3200,16 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),j+1,id,uint32(-id));
qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement
}
-
if(id > 0 && !sCreatureStorage.LookupEntry<CreatureInfo>(id))
{
sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %i but creature with entry %u does not exist, quest can't be done.",
qinfo->GetQuestId(),j+1,id,uint32(id));
qinfo->ReqCreatureOrGOId[j] = 0; // quest can't be done for this requirement
}
-
if(id)
{
// In fact SpeakTo and Kill are quite same: either you can speak to mob:SpeakTo or you can't:Kill/Cast
-
qinfo->SetFlag(QUEST_TRINITY_FLAGS_KILL_OR_CAST | QUEST_TRINITY_FLAGS_SPEAKTO);
-
if(!qinfo->ReqCreatureOrGOCount[j])
{
sLog.outErrorDb("Quest %u has `ReqCreatureOrGOId%d` = %u but `ReqCreatureOrGOCount%d` = 0, quest can't be done.",
@@ -3867,7 +3224,6 @@ void ObjectMgr::LoadQuests()
// no changes, quest ignore this data
}
}
-
for(uint8 j = 0; j < QUEST_REWARD_CHOICES_COUNT; ++j )
{
uint32 id = qinfo->RewChoiceItemId[j];
@@ -3879,7 +3235,6 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),j+1,id,id);
qinfo->RewChoiceItemId[j] = 0; // no changes, quest will not reward this
}
-
if(!qinfo->RewChoiceItemCount[j])
{
sLog.outErrorDb("Quest %u has `RewChoiceItemId%d` = %u but `RewChoiceItemCount%d` = 0, quest can't be done.",
@@ -3894,7 +3249,6 @@ void ObjectMgr::LoadQuests()
// no changes, quest ignore this data
}
}
-
for(uint8 j = 0; j < QUEST_REWARDS_COUNT; ++j )
{
uint32 id = qinfo->RewItemId[j];
@@ -3906,7 +3260,6 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),j+1,id,id);
qinfo->RewItemId[j] = 0; // no changes, quest will not reward this item
}
-
if(!qinfo->RewItemCount[j])
{
sLog.outErrorDb("Quest %u has `RewItemId%d` = %u but `RewItemCount%d` = 0, quest will not reward this item.",
@@ -3921,7 +3274,6 @@ void ObjectMgr::LoadQuests()
// no changes, quest ignore this data
}
}
-
for(uint8 j = 0; j < QUEST_REPUTATIONS_COUNT; ++j)
{
if(qinfo->RewRepFaction[j])
@@ -3932,7 +3284,6 @@ void ObjectMgr::LoadQuests()
qinfo->GetQuestId(),j+1,qinfo->RewRepValue[j],j+1);
// no changes
}
-
if(!sFactionStore.LookupEntry(qinfo->RewRepFaction[j]))
{
sLog.outErrorDb("Quest %u has `RewRepFaction%d` = %u but raw faction (faction.dbc) %u does not exist, quest will not reward reputation for this faction.",
@@ -3947,25 +3298,21 @@ void ObjectMgr::LoadQuests()
// no changes, quest ignore this data
}
}
-
if(qinfo->RewSpell)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpell);
-
if(!spellInfo)
{
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u does not exist, spell removed as display reward.",
qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell);
qinfo->RewSpell = 0; // no spell reward will display for this quest
}
-
else if(!SpellMgr::IsSpellValid(spellInfo))
{
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is broken, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpell,qinfo->RewSpell);
qinfo->RewSpell = 0; // no spell reward will display for this quest
}
-
else if(GetTalentSpellCost(qinfo->RewSpell))
{
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.",
@@ -3973,25 +3320,21 @@ void ObjectMgr::LoadQuests()
qinfo->RewSpell = 0; // no spell reward will display for this quest
}
}
-
if(qinfo->RewSpellCast)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(qinfo->RewSpellCast);
-
if(!spellInfo)
{
sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u does not exist, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast);
qinfo->RewSpellCast = 0; // no spell will be casted on player
}
-
else if(!SpellMgr::IsSpellValid(spellInfo))
{
sLog.outErrorDb("Quest %u has `RewSpellCast` = %u but spell %u is broken, quest will not have a spell reward.",
qinfo->GetQuestId(),qinfo->RewSpellCast,qinfo->RewSpellCast);
qinfo->RewSpellCast = 0; // no spell will be casted on player
}
-
else if(GetTalentSpellCost(qinfo->RewSpellCast))
{
sLog.outErrorDb("Quest %u has `RewSpell` = %u but spell %u is talent, quest will not have a spell reward.",
@@ -3999,7 +3342,6 @@ void ObjectMgr::LoadQuests()
qinfo->RewSpellCast = 0; // no spell will be casted on player
}
}
-
if(qinfo->RewMailTemplateId)
{
if(!sMailTemplateStore.LookupEntry(qinfo->RewMailTemplateId))
@@ -4010,7 +3352,6 @@ void ObjectMgr::LoadQuests()
qinfo->RewMailDelaySecs = 0; // no mail will send to player
}
}
-
if(qinfo->NextQuestInChain)
{
QuestMap::iterator qNextItr = mQuestTemplates.find(qinfo->NextQuestInChain);
@@ -4023,7 +3364,6 @@ void ObjectMgr::LoadQuests()
else
qNextItr->second->prevChainQuests.push_back(qinfo->GetQuestId());
}
-
// fill additional data stores
if(qinfo->PrevQuestId)
{
@@ -4036,7 +3376,6 @@ void ObjectMgr::LoadQuests()
qinfo->prevQuests.push_back(qinfo->PrevQuestId);
}
}
-
if(qinfo->NextQuestId)
{
QuestMap::iterator qNextItr = mQuestTemplates.find(abs(qinfo->GetNextQuestId()));
@@ -4050,51 +3389,40 @@ void ObjectMgr::LoadQuests()
qNextItr->second->prevQuests.push_back(signedQuestId);
}
}
-
if(qinfo->ExclusiveGroup)
mExclusiveQuestGroups.insert(std::pair<int32, uint32>(qinfo->ExclusiveGroup, qinfo->GetQuestId()));
if(qinfo->LimitTime)
qinfo->SetFlag(QUEST_TRINITY_FLAGS_TIMED);
}
-
// check QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT for spell with SPELL_EFFECT_QUEST_COMPLETE
for (uint32 i = 0; i < sSpellStore.GetNumRows(); ++i)
{
SpellEntry const *spellInfo = sSpellStore.LookupEntry(i);
if(!spellInfo)
continue;
-
for(uint8 j = 0; j < 3; ++j)
{
if(spellInfo->Effect[j] != SPELL_EFFECT_QUEST_COMPLETE)
continue;
-
uint32 quest_id = spellInfo->EffectMiscValue[j];
-
Quest const* quest = GetQuestTemplate(quest_id);
-
// some quest referenced in spells not exist (outdated spells)
if(!quest)
continue;
-
if(!quest->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT))
{
sLog.outErrorDb("Spell (id: %u) have SPELL_EFFECT_QUEST_COMPLETE for quest %u , but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT. Quest flags must be fixed, quest modified to enable objective.",spellInfo->Id,quest_id);
-
// this will prevent quest completing without objective
const_cast<Quest*>(quest)->SetFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT);
}
}
}
-
sLog.outString();
sLog.outString( ">> Loaded %lu quests definitions", (unsigned long)mQuestTemplates.size() );
}
-
void ObjectMgr::LoadQuestLocales()
{
mQuestLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,"
"Title_loc1,Details_loc1,Objectives_loc1,OfferRewardText_loc1,RequestItemsText_loc1,EndText_loc1,ObjectiveText1_loc1,ObjectiveText2_loc1,ObjectiveText3_loc1,ObjectiveText4_loc1,"
"Title_loc2,Details_loc2,Objectives_loc2,OfferRewardText_loc2,RequestItemsText_loc2,EndText_loc2,ObjectiveText1_loc2,ObjectiveText2_loc2,ObjectiveText3_loc2,ObjectiveText4_loc2,"
@@ -4106,29 +3434,21 @@ void ObjectMgr::LoadQuestLocales()
"Title_loc8,Details_loc8,Objectives_loc8,OfferRewardText_loc8,RequestItemsText_loc8,EndText_loc8,ObjectiveText1_loc8,ObjectiveText2_loc8,ObjectiveText3_loc8,ObjectiveText4_loc8"
" FROM locales_quest"
);
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 Quest locale strings. DB table `locales_quest` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
QuestLocale& data = mQuestLocaleMap[entry];
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[1+10*(i-1)].GetCppString();
@@ -4139,7 +3459,6 @@ void ObjectMgr::LoadQuestLocales()
{
if(data.Title.size() <= idx)
data.Title.resize(idx+1);
-
data.Title[idx] = str;
}
}
@@ -4151,7 +3470,6 @@ void ObjectMgr::LoadQuestLocales()
{
if(data.Details.size() <= idx)
data.Details.resize(idx+1);
-
data.Details[idx] = str;
}
}
@@ -4163,7 +3481,6 @@ void ObjectMgr::LoadQuestLocales()
{
if(data.Objectives.size() <= idx)
data.Objectives.resize(idx+1);
-
data.Objectives[idx] = str;
}
}
@@ -4175,7 +3492,6 @@ void ObjectMgr::LoadQuestLocales()
{
if(data.OfferRewardText.size() <= idx)
data.OfferRewardText.resize(idx+1);
-
data.OfferRewardText[idx] = str;
}
}
@@ -4187,7 +3503,6 @@ void ObjectMgr::LoadQuestLocales()
{
if(data.RequestItemsText.size() <= idx)
data.RequestItemsText.resize(idx+1);
-
data.RequestItemsText[idx] = str;
}
}
@@ -4199,7 +3514,6 @@ void ObjectMgr::LoadQuestLocales()
{
if(data.EndText.size() <= idx)
data.EndText.resize(idx+1);
-
data.EndText[idx] = str;
}
}
@@ -4213,49 +3527,36 @@ void ObjectMgr::LoadQuestLocales()
{
if(data.ObjectiveText[k].size() <= idx)
data.ObjectiveText[k].resize(idx+1);
-
data.ObjectiveText[k][idx] = str;
}
}
}
}
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu Quest locale strings", (unsigned long)mQuestLocaleMap.size() );
}
-
void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
{
if(sWorld.IsScriptScheduled()) // function don't must be called in time scripts use.
return;
-
sLog.outString( "%s :", tablename);
-
scripts.clear(); // need for reload support
-
QueryResult *result = WorldDatabase.PQuery( "SELECT id,delay,command,datalong,datalong2,dataint, x, y, z, o FROM %s", tablename );
-
uint32 count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u script definitions", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
bar.step();
-
Field *fields = result->Fetch();
ScriptInfo tmp;
tmp.id = fields[0].GetUInt32();
@@ -4268,7 +3569,6 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
tmp.y = fields[7].GetFloat();
tmp.z = fields[8].GetFloat();
tmp.o = fields[9].GetFloat();
-
// generic command args check
switch(tmp.command)
{
@@ -4289,11 +3589,9 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
sLog.outErrorDb("Table `%s` has out of range text id (dataint = %i expected %u-%u) in SCRIPT_COMMAND_TALK for script id %u",tablename,tmp.dataint,MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID,tmp.id);
continue;
}
-
// if(!objmgr.GetMangosStringLocale(tmp.dataint)) will checked after db_script_string loading
break;
}
-
case SCRIPT_COMMAND_EMOTE:
{
if(!sEmotesStore.LookupEntry(tmp.datalong))
@@ -4303,7 +3601,6 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
}
break;
}
-
case SCRIPT_COMMAND_TELEPORT_TO:
{
if(!sMapStore.LookupEntry(tmp.datalong))
@@ -4311,7 +3608,6 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
sLog.outErrorDb("Table `%s` has invalid map (Id: %u) in SCRIPT_COMMAND_TELEPORT_TO for script id %u",tablename,tmp.datalong,tmp.id);
continue;
}
-
if(!Trinity::IsValidMapCoord(tmp.x,tmp.y,tmp.z,tmp.o))
{
sLog.outErrorDb("Table `%s` has invalid coordinates (X: %f Y: %f) in SCRIPT_COMMAND_TELEPORT_TO for script id %u",tablename,tmp.x,tmp.y,tmp.id);
@@ -4319,7 +3615,6 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
}
break;
}
-
case SCRIPT_COMMAND_TEMP_SUMMON_CREATURE:
{
if(!Trinity::IsValidMapCoord(tmp.x,tmp.y,tmp.z,tmp.o))
@@ -4327,7 +3622,6 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
sLog.outErrorDb("Table `%s` has invalid coordinates (X: %f Y: %f) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id %u",tablename,tmp.x,tmp.y,tmp.id);
continue;
}
-
if(!GetCreatureTemplate(tmp.datalong))
{
sLog.outErrorDb("Table `%s` has invalid creature (Entry: %u) in SCRIPT_COMMAND_TEMP_SUMMON_CREATURE for script id %u",tablename,tmp.datalong,tmp.id);
@@ -4335,7 +3629,6 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
}
break;
}
-
case SCRIPT_COMMAND_RESPAWN_GAMEOBJECT:
{
GameObjectData const* data = GetGOData(tmp.datalong);
@@ -4344,14 +3637,12 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
sLog.outErrorDb("Table `%s` has invalid gameobject (GUID: %u) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,tmp.datalong,tmp.id);
continue;
}
-
GameObjectInfo const* info = GetGameObjectInfo(data->id);
if(!info)
{
sLog.outErrorDb("Table `%s` has gameobject with invalid entry (GUID: %u Entry: %u) in SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",tablename,tmp.datalong,data->id,tmp.id);
continue;
}
-
if( info->type==GAMEOBJECT_TYPE_FISHINGNODE ||
info->type==GAMEOBJECT_TYPE_FISHINGHOLE ||
info->type==GAMEOBJECT_TYPE_DOOR ||
@@ -4372,20 +3663,17 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
sLog.outErrorDb("Table `%s` has invalid gameobject (GUID: %u) in %s for script id %u",tablename,tmp.datalong,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id);
continue;
}
-
GameObjectInfo const* info = GetGameObjectInfo(data->id);
if(!info)
{
sLog.outErrorDb("Table `%s` has gameobject with invalid entry (GUID: %u Entry: %u) in %s for script id %u",tablename,tmp.datalong,data->id,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id);
continue;
}
-
if( info->type!=GAMEOBJECT_TYPE_DOOR)
{
sLog.outErrorDb("Table `%s` has gameobject type (%u) non supported by command %s for script id %u",tablename,info->id,(tmp.command==SCRIPT_COMMAND_OPEN_DOOR ? "SCRIPT_COMMAND_OPEN_DOOR" : "SCRIPT_COMMAND_CLOSE_DOOR"),tmp.id);
continue;
}
-
break;
}
case SCRIPT_COMMAND_QUEST_EXPLORED:
@@ -4396,41 +3684,33 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
sLog.outErrorDb("Table `%s` has invalid quest (ID: %u) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",tablename,tmp.datalong,tmp.id);
continue;
}
-
if(!quest->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT))
{
sLog.outErrorDb("Table `%s` has quest (ID: %u) in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT in quest flags. Script command or quest flags wrong. Quest modified to require objective.",tablename,tmp.datalong,tmp.id);
-
// this will prevent quest completing without objective
const_cast<Quest*>(quest)->SetFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT);
-
// continue; - quest objective requirement set and command can be allowed
}
-
if(float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE)
{
sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u",
tablename,tmp.datalong2,tmp.id);
continue;
}
-
if(tmp.datalong2 && float(tmp.datalong2) > DEFAULT_VISIBILITY_DISTANCE)
{
sLog.outErrorDb("Table `%s` has too large distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, max distance is %f or 0 for disable distance check",
tablename,tmp.datalong2,tmp.id,DEFAULT_VISIBILITY_DISTANCE);
continue;
}
-
if(tmp.datalong2 && float(tmp.datalong2) < INTERACTION_DISTANCE)
{
sLog.outErrorDb("Table `%s` has too small distance (%u) for exploring objective complete in `datalong2` in SCRIPT_COMMAND_QUEST_EXPLORED in `datalong` for script id %u, min distance is %f or 0 for disable distance check",
tablename,tmp.datalong2,tmp.id,INTERACTION_DISTANCE);
continue;
}
-
break;
}
-
case SCRIPT_COMMAND_REMOVE_AURA:
{
if(!sSpellStore.LookupEntry(tmp.datalong))
@@ -4464,27 +3744,21 @@ void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
break;
}
}
-
if (scripts.find(tmp.id) == scripts.end())
{
ScriptMap emptyMap;
scripts[tmp.id] = emptyMap;
}
scripts[tmp.id].insert(std::pair<uint32, ScriptInfo>(tmp.delay, tmp));
-
++count;
} while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u script definitions", count );
}
-
void ObjectMgr::LoadGameObjectScripts()
{
LoadScripts(sGameObjectScripts, "gameobject_scripts");
-
// check ids
for(ScriptMapMap::const_iterator itr = sGameObjectScripts.begin(); itr != sGameObjectScripts.end(); ++itr)
{
@@ -4492,11 +3766,9 @@ void ObjectMgr::LoadGameObjectScripts()
sLog.outErrorDb("Table `gameobject_scripts` has not existing gameobject (GUID: %u) as script id",itr->first);
}
}
-
void ObjectMgr::LoadQuestEndScripts()
{
LoadScripts(sQuestEndScripts, "quest_end_scripts");
-
// check ids
for(ScriptMapMap::const_iterator itr = sQuestEndScripts.begin(); itr != sQuestEndScripts.end(); ++itr)
{
@@ -4504,11 +3776,9 @@ void ObjectMgr::LoadQuestEndScripts()
sLog.outErrorDb("Table `quest_end_scripts` has not existing quest (Id: %u) as script id",itr->first);
}
}
-
void ObjectMgr::LoadQuestStartScripts()
{
LoadScripts(sQuestStartScripts,"quest_start_scripts");
-
// check ids
for(ScriptMapMap::const_iterator itr = sQuestStartScripts.begin(); itr != sQuestStartScripts.end(); ++itr)
{
@@ -4516,22 +3786,18 @@ void ObjectMgr::LoadQuestStartScripts()
sLog.outErrorDb("Table `quest_start_scripts` has not existing quest (Id: %u) as script id",itr->first);
}
}
-
void ObjectMgr::LoadSpellScripts()
{
LoadScripts(sSpellScripts, "spell_scripts");
-
// check ids
for(ScriptMapMap::const_iterator itr = sSpellScripts.begin(); itr != sSpellScripts.end(); ++itr)
{
SpellEntry const* spellInfo = sSpellStore.LookupEntry(itr->first);
-
if(!spellInfo)
{
sLog.outErrorDb("Table `spell_scripts` has not existing spell (Id: %u) as script id",itr->first);
continue;
}
-
//check for correct spellEffect
bool found = false;
for(uint8 i=0; i<3; ++i)
@@ -4539,23 +3805,19 @@ void ObjectMgr::LoadSpellScripts()
// skip empty effects
if( !spellInfo->Effect[i] )
continue;
-
if( spellInfo->Effect[i] == SPELL_EFFECT_SCRIPT_EFFECT )
{
found = true;
break;
}
}
-
if(!found)
sLog.outErrorDb("Table `spell_scripts` has unsupported spell (Id: %u) without SPELL_EFFECT_SCRIPT_EFFECT (%u) spell effect",itr->first,SPELL_EFFECT_SCRIPT_EFFECT);
}
}
-
void ObjectMgr::LoadEventScripts()
{
LoadScripts(sEventScripts, "event_scripts");
-
std::set<uint32> evt_scripts;
// Load all possible script entries from gameobjects
for(uint32 i = 1; i < sGOStorage.MaxEntry; ++i)
@@ -4606,12 +3868,10 @@ void ObjectMgr::LoadEventScripts()
itr->first, SPELL_EFFECT_SEND_EVENT);
}
}
-
//Load WP Scripts
void ObjectMgr::LoadWaypointScripts()
{
LoadScripts(sWaypointScripts, "waypoint_scripts");
-
for(ScriptMapMap::const_iterator itr = sWaypointScripts.begin(); itr != sWaypointScripts.end(); ++itr)
{
QueryResult *query = WorldDatabase.PQuery("SELECT * FROM waypoint_scripts WHERE id = %u", itr->first);
@@ -4619,65 +3879,48 @@ void ObjectMgr::LoadWaypointScripts()
sLog.outErrorDb("There is no waypoint which links to the waypoint script %u", itr->first);
}
}
-
void ObjectMgr::LoadItemTexts()
{
QueryResult *result = CharacterDatabase.Query("SELECT id, text FROM item_text");
-
uint32 count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u item pages", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
Field* fields;
do
{
bar.step();
-
fields = result->Fetch();
-
mItemTexts[ fields[0].GetUInt32() ] = fields[1].GetCppString();
-
++count;
-
} while ( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u item texts", count );
}
-
void ObjectMgr::LoadPageTexts()
{
sPageTextStore.Free(); // for reload case
-
sPageTextStore.Load();
sLog.outString( ">> Loaded %u page texts", sPageTextStore.RecordCount );
sLog.outString();
-
for(uint32 i = 1; i < sPageTextStore.MaxEntry; ++i)
{
// check data correctness
PageText const* page = sPageTextStore.LookupEntry<PageText>(i);
if(!page)
continue;
-
if(page->Next_Page && !sPageTextStore.LookupEntry<PageText>(page->Next_Page))
{
sLog.outErrorDb("Page text (Id: %u) has not existing next page (Id:%u)", i,page->Next_Page);
continue;
}
-
// detect circular reference
std::set<uint32> checkedPages;
for(PageText const* pageItr = page; pageItr; pageItr = sPageTextStore.LookupEntry<PageText>(pageItr->Next_Page))
@@ -4700,59 +3943,43 @@ void ObjectMgr::LoadPageTexts()
}
}
}
-
void ObjectMgr::LoadPageTextLocales()
{
mPageTextLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,text_loc1,text_loc2,text_loc3,text_loc4,text_loc5,text_loc6,text_loc7,text_loc8 FROM locales_page_text");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 PageText locale strings. DB table `locales_page_text` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
PageTextLocale& data = mPageTextLocaleMap[entry];
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
if(str.empty())
continue;
-
int idx = GetOrNewIndexForLocale(LocaleConstant(i));
if(idx >= 0)
{
if(data.Text.size() <= idx)
data.Text.resize(idx+1);
-
data.Text[idx] = str;
}
}
-
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu PageText locale strings", (unsigned long)mPageTextLocaleMap.size() );
}
-
struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader>
{
template<class D>
@@ -4761,12 +3988,10 @@ struct SQLInstanceLoader : public SQLStorageLoaderBase<SQLInstanceLoader>
dst = D(objmgr.GetScriptId(src));
}
};
-
void ObjectMgr::LoadInstanceTemplate()
{
SQLInstanceLoader loader;
loader.Load(sInstanceTemplate);
-
for(uint32 i = 0; i < sInstanceTemplate.MaxEntry; i++)
{
InstanceTemplate* temp = (InstanceTemplate*)GetInstanceTemplate(i);
@@ -4779,7 +4004,6 @@ void ObjectMgr::LoadInstanceTemplate()
}
else if(!entry->HasResetTime())
continue;
-
//FIXME: now exist heroic instance, normal/heroic raid instances
// entry->resetTimeHeroic store reset time for both heroic mode instance (raid and non-raid)
// entry->resetTimeRaid store reset time for normal raid only
@@ -4798,15 +4022,12 @@ void ObjectMgr::LoadInstanceTemplate()
temp->reset_delay = entry->resetTimeRaid / DAY;
}
}
-
// the reset_delay must be at least one day
temp->reset_delay = std::max((uint32)1, (uint32)(temp->reset_delay * sWorld.getRate(RATE_INSTANCE_RESET_TIME)));
}
-
sLog.outString( ">> Loaded %u Instance Template definitions", sInstanceTemplate.RecordCount );
sLog.outString();
}
-
GossipText const *ObjectMgr::GetGossipText(uint32 Text_ID) const
{
GossipTextMap::const_iterator itr = mGossipText.find(Text_ID);
@@ -4814,52 +4035,39 @@ GossipText const *ObjectMgr::GetGossipText(uint32 Text_ID) const
return &itr->second;
return NULL;
}
-
void ObjectMgr::LoadGossipText()
{
QueryResult *result = WorldDatabase.Query( "SELECT * FROM npc_text" );
-
int count = 0;
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u npc texts", count );
return;
}
-
int cic;
-
barGoLink bar( result->GetRowCount() );
-
do
{
++count;
cic = 0;
-
Field *fields = result->Fetch();
-
bar.step();
-
uint32 Text_ID = fields[cic++].GetUInt32();
if(!Text_ID)
{
sLog.outErrorDb("Table `npc_text` has record wit reserved id 0, ignore.");
continue;
}
-
GossipText& gText = mGossipText[Text_ID];
-
for (int i=0; i< 8; i++)
{
gText.Options[i].Text_0 = fields[cic++].GetCppString();
gText.Options[i].Text_1 = fields[cic++].GetCppString();
-
gText.Options[i].Language = fields[cic++].GetUInt32();
gText.Options[i].Probability = fields[cic++].GetFloat();
-
for(uint8 j=0; j < 3; ++j)
{
gText.Options[i].Emotes[j]._Delay = fields[cic++].GetUInt32();
@@ -4867,16 +4075,13 @@ void ObjectMgr::LoadGossipText()
}
}
} while( result->NextRow() );
-
sLog.outString();
sLog.outString( ">> Loaded %u npc texts", count );
delete result;
}
-
void ObjectMgr::LoadNpcTextLocales()
{
mNpcTextLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,"
"Text0_0_loc1,Text0_1_loc1,Text1_0_loc1,Text1_1_loc1,Text2_0_loc1,Text2_1_loc1,Text3_0_loc1,Text3_1_loc1,Text4_0_loc1,Text4_1_loc1,Text5_0_loc1,Text5_1_loc1,Text6_0_loc1,Text6_1_loc1,Text7_0_loc1,Text7_1_loc1,"
"Text0_0_loc2,Text0_1_loc2,Text1_0_loc2,Text1_1_loc2,Text2_0_loc2,Text2_1_loc2,Text3_0_loc2,Text3_1_loc1,Text4_0_loc2,Text4_1_loc2,Text5_0_loc2,Text5_1_loc2,Text6_0_loc2,Text6_1_loc2,Text7_0_loc2,Text7_1_loc2,"
@@ -4887,29 +4092,21 @@ void ObjectMgr::LoadNpcTextLocales()
"Text0_0_loc7,Text0_1_loc7,Text1_0_loc7,Text1_1_loc7,Text2_0_loc7,Text2_1_loc7,Text3_0_loc7,Text3_1_loc1,Text4_0_loc7,Text4_1_loc7,Text5_0_loc7,Text5_1_loc7,Text6_0_loc7,Text6_1_loc7,Text7_0_loc7,Text7_1_loc7, "
"Text0_0_loc8,Text0_1_loc8,Text1_0_loc8,Text1_1_loc8,Text2_0_loc8,Text2_1_loc8,Text3_0_loc8,Text3_1_loc1,Text4_0_loc8,Text4_1_loc8,Text5_0_loc8,Text5_1_loc8,Text6_0_loc8,Text6_1_loc8,Text7_0_loc8,Text7_1_loc8 "
" FROM locales_npc_text");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 NpcText locale strings. DB table `locales_npc_text` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
NpcTextLocale& data = mNpcTextLocaleMap[entry];
-
for(uint8 i=1; i<MAX_LOCALE; ++i)
{
for(uint8 j=0; j<8; ++j)
@@ -4922,7 +4119,6 @@ void ObjectMgr::LoadNpcTextLocales()
{
if(data.Text_0[j].size() <= idx)
data.Text_0[j].resize(idx+1);
-
data.Text_0[j][idx] = str0;
}
}
@@ -4934,20 +4130,16 @@ void ObjectMgr::LoadNpcTextLocales()
{
if(data.Text_1[j].size() <= idx)
data.Text_1[j].resize(idx+1);
-
data.Text_1[j][idx] = str1;
}
}
}
}
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu NpcText locale strings", (unsigned long)mNpcTextLocaleMap.size() );
}
-
//not very fast function but it is called only once a day, or on starting-up
void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
{
@@ -4966,20 +4158,16 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
sLog.outString(">> Only expired mails (need to be return or delete) or DB table `mail` is empty.");
return; // any mails need to be returned or deleted
}
-
//std::ostringstream delitems, delmails; //will be here for optimization
//bool deletemail = false, deleteitem = false;
//delitems << "DELETE FROM item_instance WHERE guid IN ( ";
//delmails << "DELETE FROM mail WHERE id IN ( "
-
barGoLink bar( result->GetRowCount() );
uint32 count = 0;
Field *fields;
-
do
{
bar.step();
-
fields = result->Fetch();
Mail *m = new Mail;
m->messageID = fields[0].GetUInt32();
@@ -4993,7 +4181,6 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
m->COD = fields[7].GetUInt32();
m->checked = fields[8].GetUInt32();
m->mailTemplateId = fields[9].GetInt16();
-
Player *pl = 0;
if (serverUp)
pl = GetPlayer((uint64)m->receiver);
@@ -5012,14 +4199,11 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
do
{
Field *fields2 = resultItems->Fetch();
-
uint32 item_guid_low = fields2[0].GetUInt32();
uint32 item_template = fields2[1].GetUInt32();
-
m->AddItem(item_guid_low, item_template);
}
while (resultItems->NextRow());
-
delete resultItems;
}
//if it is mail from AH, it shouldn't be returned, but deleted
@@ -5037,10 +4221,8 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
continue;
}
}
-
if (m->itemTextId)
CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", m->itemTextId);
-
//deletemail = true;
//delmails << m->messageID << ", ";
CharacterDatabase.PExecute("DELETE FROM mail WHERE id = '%u'", m->messageID);
@@ -5048,150 +4230,108 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
++count;
} while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u mails", count );
}
-
void ObjectMgr::LoadQuestAreaTriggers()
{
mQuestAreaTriggerMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query( "SELECT id,quest FROM areatrigger_involvedrelation" );
-
uint32 count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u quest trigger points", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
++count;
bar.step();
-
Field *fields = result->Fetch();
-
uint32 trigger_ID = fields[0].GetUInt32();
uint32 quest_ID = fields[1].GetUInt32();
-
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(trigger_ID);
if(!atEntry)
{
sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",trigger_ID);
continue;
}
-
Quest const* quest = GetQuestTemplate(quest_ID);
-
if(!quest)
{
sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not existing quest %u",trigger_ID,quest_ID);
continue;
}
-
if(!quest->HasFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT))
{
sLog.outErrorDb("Table `areatrigger_involvedrelation` has record (id: %u) for not quest %u, but quest not have flag QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT. Trigger or quest flags must be fixed, quest modified to require objective.",trigger_ID,quest_ID);
-
// this will prevent quest completing without objective
const_cast<Quest*>(quest)->SetFlag(QUEST_TRINITY_FLAGS_EXPLORATION_OR_EVENT);
-
// continue; - quest modified to required objective and trigger can be allowed.
}
-
mQuestAreaTriggerMap[trigger_ID] = quest_ID;
-
} while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u quest trigger points", count );
}
-
void ObjectMgr::LoadTavernAreaTriggers()
{
mTavernAreaTriggerSet.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT id FROM areatrigger_tavern");
-
uint32 count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u tavern triggers", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
++count;
bar.step();
-
Field *fields = result->Fetch();
-
uint32 Trigger_ID = fields[0].GetUInt32();
-
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
if(!atEntry)
{
sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID);
continue;
}
-
mTavernAreaTriggerSet.insert(Trigger_ID);
} while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u tavern triggers", count );
}
-
void ObjectMgr::LoadAreaTriggerScripts()
{
mAreaTriggerScripts.clear(); // need for reload case
QueryResult *result = WorldDatabase.Query("SELECT entry, ScriptName FROM areatrigger_scripts");
-
uint32 count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u areatrigger scripts", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
++count;
bar.step();
-
Field *fields = result->Fetch();
-
uint32 Trigger_ID = fields[0].GetUInt32();
const char *scriptName = fields[1].GetString();
-
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
if(!atEntry)
{
@@ -5200,32 +4340,25 @@ void ObjectMgr::LoadAreaTriggerScripts()
}
mAreaTriggerScripts[Trigger_ID] = GetScriptId(scriptName);
} while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u areatrigger scripts", count );
}
-
uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid, uint32 team )
{
bool found = false;
float dist;
uint32 id = 0;
-
for(uint32 i = 1; i < sTaxiNodesStore.GetNumRows(); ++i)
{
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(i);
if(!node || node->map_id != mapid || !node->MountCreatureID[team == ALLIANCE ? 1 : 0] && node->MountCreatureID[0] != 32981) // dk flight
continue;
-
uint8 field = (uint8)((i - 1) / 32);
uint32 submask = 1<<((i-1)%32);
-
// skip not taxi network nodes
if((sTaxiNodesMask[field] & submask)==0)
continue;
-
float dist2 = (node->x - x)*(node->x - x)+(node->y - y)*(node->y - y)+(node->z - z)*(node->z - z);
if(found)
{
@@ -5242,10 +4375,8 @@ uint32 ObjectMgr::GetNearestTaxiNode( float x, float y, float z, uint32 mapid, u
id = i;
}
}
-
return id;
}
-
void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, uint32 &cost)
{
TaxiPathSetBySource::iterator src_i = sTaxiPathSetBySource.find(source);
@@ -5255,9 +4386,7 @@ void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, ui
cost = 0;
return;
}
-
TaxiPathSetForSource& pathSet = src_i->second;
-
TaxiPathSetForSource::iterator dest_i = pathSet.find(destination);
if(dest_i==pathSet.end())
{
@@ -5265,16 +4394,13 @@ void ObjectMgr::GetTaxiPath( uint32 source, uint32 destination, uint32 &path, ui
cost = 0;
return;
}
-
cost = dest_i->second.price;
path = dest_i->second.ID;
}
-
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)
@@ -5283,7 +4409,6 @@ uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_al
mount_entry = node->MountCreatureID[1];
else
mount_entry = node->MountCreatureID[0];
-
// Fix for Alliance not being able to use Acherus taxi
// only one mount type for both sides
if (mount_entry == 0 && allowed_alt_team)
@@ -5292,7 +4417,6 @@ uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_al
// have a valid mount ID to choose
mount_entry = (team == ALLIANCE) ? node->MountCreatureID[0] : node->MountCreatureID[1];
}
-
CreatureInfo const *mount_info = GetCreatureTemplate(mount_entry);
if (mount_info)
{
@@ -5303,43 +4427,32 @@ uint32 ObjectMgr::GetTaxiMountDisplayId( uint32 id, uint32 team, bool allowed_al
}
}
}
-
CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(mount_id);
if (minfo)
mount_id = minfo->modelid;
-
return mount_id;
}
-
void ObjectMgr::GetTaxiPathNodes( uint32 path, Path &pathnodes, std::vector<uint32>& mapIds)
{
if(path >= sTaxiPathNodesByPath.size())
return;
-
TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path];
-
pathnodes.Resize(nodeList.size());
mapIds.resize(nodeList.size());
-
for(size_t i = 0; i < nodeList.size(); ++i)
{
pathnodes[ i ].x = nodeList[i].x;
pathnodes[ i ].y = nodeList[i].y;
pathnodes[ i ].z = nodeList[i].z;
-
mapIds[i] = nodeList[i].mapid;
}
}
-
void ObjectMgr::GetTransportPathNodes( uint32 path, TransportPath &pathnodes )
{
if(path >= sTaxiPathNodesByPath.size())
return;
-
TaxiPathNodeList& nodeList = sTaxiPathNodesByPath[path];
-
pathnodes.Resize(nodeList.size());
-
for(size_t i = 0; i < nodeList.size(); ++i)
{
pathnodes[ i ].mapid = nodeList[i].mapid;
@@ -5350,79 +4463,61 @@ void ObjectMgr::GetTransportPathNodes( uint32 path, TransportPath &pathnodes )
pathnodes[ i ].delay = nodeList[i].delay;
}
}
-
void ObjectMgr::LoadGraveyardZones()
{
mGraveYardMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT id,ghost_zone,faction FROM game_graveyard_zone");
-
uint32 count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u graveyard-zone links", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
++count;
bar.step();
-
Field *fields = result->Fetch();
-
uint32 safeLocId = fields[0].GetUInt32();
uint32 zoneId = fields[1].GetUInt32();
uint32 team = fields[2].GetUInt32();
-
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(safeLocId);
if(!entry)
{
sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",safeLocId);
continue;
}
-
AreaTableEntry const *areaEntry = GetAreaEntryByAreaID(zoneId);
if(!areaEntry)
{
sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing zone id (%u), skipped.",zoneId);
continue;
}
-
if(areaEntry->zone != 0)
{
sLog.outErrorDb("Table `game_graveyard_zone` has record subzone id (%u) instead of zone, skipped.",zoneId);
continue;
}
-
if(team!=0 && team!=HORDE && team!=ALLIANCE)
{
sLog.outErrorDb("Table `game_graveyard_zone` has record for non player faction (%u), skipped.",team);
continue;
}
-
if(!AddGraveYardLink(safeLocId,zoneId,team,false))
sLog.outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.",safeLocId,zoneId);
} while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u graveyard-zone links", count );
}
-
WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float z, uint32 MapId, uint32 team)
{
// search for zone associated closest graveyard
uint32 zoneId = MapManager::Instance().GetZoneId(MapId,x,y,z);
-
// Simulate std. algorithm:
// found some graveyard associated to (ghost_zone,ghost_map)
//
@@ -5434,44 +4529,35 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
GraveYardMap::const_iterator graveUp = mGraveYardMap.upper_bound(zoneId);
MapEntry const* map = sMapStore.LookupEntry(MapId);
// not need to check validity of map object; MapId _MUST_ be valid here
-
if(graveLow==graveUp && !map->IsBattleArena())
{
sLog.outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.",zoneId,team);
return NULL;
}
-
// at corpse map
bool foundNear = false;
float distNear;
WorldSafeLocsEntry const* entryNear = NULL;
-
// at entrance map for corpse map
bool foundEntr = false;
float distEntr;
WorldSafeLocsEntry const* entryEntr = NULL;
-
// some where other
WorldSafeLocsEntry const* entryFar = NULL;
-
MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);
-
for(GraveYardMap::const_iterator itr = graveLow; itr != graveUp; ++itr)
{
GraveYardData const& data = itr->second;
-
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(data.safeLocId);
if(!entry)
{
sLog.outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.",data.safeLocId);
continue;
}
-
// skip enemy faction graveyard
// team == 0 case can be at call from .neargrave
if(data.team != 0 && team != 0 && data.team != team)
continue;
-
// find now nearest graveyard at other map
if(MapId != entry->map_id)
{
@@ -5485,7 +4571,6 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
entryFar = entry;
continue;
}
-
// at entrance map calculate distance (2D);
float dist2 = (entry->x - mapEntry->entrance_x)*(entry->x - mapEntry->entrance_x)
+(entry->y - mapEntry->entrance_y)*(entry->y - mapEntry->entrance_y);
@@ -5524,52 +4609,40 @@ WorldSafeLocsEntry const *ObjectMgr::GetClosestGraveYard(float x, float y, float
}
}
}
-
if(entryNear)
return entryNear;
-
if(entryEntr)
return entryEntr;
-
return entryFar;
}
-
GraveYardData const* ObjectMgr::FindGraveYardData(uint32 id, uint32 zoneId)
{
GraveYardMap::const_iterator graveLow = mGraveYardMap.lower_bound(zoneId);
GraveYardMap::const_iterator graveUp = mGraveYardMap.upper_bound(zoneId);
-
for(GraveYardMap::const_iterator itr = graveLow; itr != graveUp; ++itr)
{
if(itr->second.safeLocId==id)
return &itr->second;
}
-
return NULL;
}
-
bool ObjectMgr::AddGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool inDB)
{
if(FindGraveYardData(id,zoneId))
return false;
-
// add link to loaded data
GraveYardData data;
data.safeLocId = id;
data.team = team;
-
mGraveYardMap.insert(GraveYardMap::value_type(zoneId,data));
-
// add link to DB
if(inDB)
{
WorldDatabase.PExecuteLog("INSERT INTO game_graveyard_zone ( id,ghost_zone,faction) "
"VALUES ('%u', '%u','%u')",id,zoneId,team);
}
-
return true;
}
-
void ObjectMgr::RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool inDB)
{
GraveYardMap::iterator graveLow = mGraveYardMap.lower_bound(zoneId);
@@ -5579,150 +4652,107 @@ void ObjectMgr::RemoveGraveYardLink(uint32 id, uint32 zoneId, uint32 team, bool
//sLog.outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.",zoneId,team);
return;
}
-
bool found = false;
-
GraveYardMap::iterator itr;
-
for(itr = graveLow; itr != graveUp; ++itr)
{
GraveYardData & data = itr->second;
-
// skip not matching safezone id
if(data.safeLocId != id)
continue;
-
// skip enemy faction graveyard at same map (normal area, city, or battleground)
// team == 0 case can be at call from .neargrave
if(data.team != 0 && team != 0 && data.team != team)
continue;
-
found = true;
break;
}
-
// no match, return
if(!found)
return;
-
// remove from links
mGraveYardMap.erase(itr);
-
// remove link from DB
if(inDB)
{
WorldDatabase.PExecute("DELETE FROM game_graveyard_zone WHERE id = '%u' AND ghost_zone = '%u' AND faction = '%u'",id,zoneId,team);
}
-
return;
}
-
void ObjectMgr::LoadAreaTriggerTeleports()
{
mAreaTriggers.clear(); // need for reload case
-
uint32 count = 0;
-
// 0 1 2 3 4 5 6
QueryResult *result = WorldDatabase.Query("SELECT id, access_id, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
if( !result )
{
-
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u area trigger teleport definitions", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field *fields = result->Fetch();
-
bar.step();
-
++count;
-
uint32 Trigger_ID = fields[0].GetUInt32();
-
AreaTrigger at;
-
at.access_id = fields[1].GetUInt32();
at.target_mapId = fields[2].GetUInt32();
at.target_X = fields[3].GetFloat();
at.target_Y = fields[4].GetFloat();
at.target_Z = fields[5].GetFloat();
at.target_Orientation = fields[6].GetFloat();
-
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
if(!atEntry)
{
sLog.outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.",Trigger_ID);
continue;
}
-
MapEntry const* mapEntry = sMapStore.LookupEntry(at.target_mapId);
if(!mapEntry)
{
sLog.outErrorDb("Area trigger (ID:%u) target map (ID: %u) does not exist in `Map.dbc`.",Trigger_ID,at.target_mapId);
continue;
}
-
if(at.target_X==0 && at.target_Y==0 && at.target_Z==0)
{
sLog.outErrorDb("Area trigger (ID:%u) target coordinates not provided.",Trigger_ID);
continue;
}
-
mAreaTriggers[Trigger_ID] = at;
-
} while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u area trigger teleport definitions", count );
}
-
void ObjectMgr::LoadAccessRequirements()
{
mAccessRequirements.clear(); // need for reload case
-
uint32 count = 0;
-
// 0 1 2 3 4 5 6 7 8 9 10 11
QueryResult *result = WorldDatabase.Query("SELECT id, level_min, level_max, item, item2, heroic_key, heroic_key2, quest_done, quest_failed_text, heroic_quest_done, heroic_quest_failed_text, heroic_level_min FROM access_requirement");
if( !result )
{
-
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u access requirement definitions", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
Field *fields = result->Fetch();
-
bar.step();
-
++count;
-
uint32 requiremt_ID = fields[0].GetUInt32();
-
AccessRequirement ar;
-
ar.levelMin = fields[1].GetUInt8();
ar.levelMax = fields[2].GetUInt8();
ar.heroicLevelMin = fields[11].GetUInt8();
@@ -5734,7 +4764,6 @@ void ObjectMgr::LoadAccessRequirements()
ar.questFailedText = fields[8].GetCppString();
ar.heroicQuest = fields[9].GetUInt32();
ar.heroicQuestFailedText = fields[10].GetCppString();
-
if(ar.item)
{
ItemPrototype const *pProto = GetItemPrototype(ar.item);
@@ -5744,7 +4773,6 @@ void ObjectMgr::LoadAccessRequirements()
ar.item = 0;
}
}
-
if(ar.item2)
{
ItemPrototype const *pProto = GetItemPrototype(ar.item2);
@@ -5754,7 +4782,6 @@ void ObjectMgr::LoadAccessRequirements()
ar.item2 = 0;
}
}
-
if(ar.heroicKey)
{
ItemPrototype const *pProto = GetItemPrototype(ar.heroicKey);
@@ -5764,7 +4791,6 @@ void ObjectMgr::LoadAccessRequirements()
ar.heroicKey = 0;
}
}
-
if(ar.heroicKey2)
{
ItemPrototype const *pProto = GetItemPrototype(ar.heroicKey2);
@@ -5774,7 +4800,6 @@ void ObjectMgr::LoadAccessRequirements()
ar.heroicKey2 = 0;
}
}
-
if(ar.heroicQuest)
{
QuestMap::iterator qReqItr = mQuestTemplates.find(ar.heroicQuest);
@@ -5784,7 +4809,6 @@ void ObjectMgr::LoadAccessRequirements()
ar.heroicQuest = 0;
}
}
-
if(ar.quest)
{
QuestMap::iterator qReqItr = mQuestTemplates.find(ar.quest);
@@ -5794,17 +4818,12 @@ void ObjectMgr::LoadAccessRequirements()
ar.quest = 0;
}
}
-
mAccessRequirements[requiremt_ID] = ar;
-
} while( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u access requirement definitions", count );
}
-
/*
* Searches for the areatrigger which teleports players out of the given map
*/
@@ -5823,7 +4842,6 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
}
return NULL;
}
-
/**
* Searches for the areatrigger which teleports players to the given map
*/
@@ -5840,7 +4858,6 @@ AreaTrigger const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const
}
return NULL;
}
-
void ObjectMgr::SetHighestGuids()
{
QueryResult *result = CharacterDatabase.Query( "SELECT MAX(guid) FROM characters" );
@@ -5849,76 +4866,65 @@ void ObjectMgr::SetHighestGuids()
m_hiCharGuid = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = WorldDatabase.Query( "SELECT MAX(guid) FROM creature" );
if( result )
{
m_hiCreatureGuid = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = CharacterDatabase.Query( "SELECT MAX(guid) FROM item_instance" );
if( result )
{
m_hiItemGuid = (*result)[0].GetUInt32()+1;
delete result;
}
-
// Cleanup other tables from not existed guids (>=m_hiItemGuid)
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", m_hiItemGuid);
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", m_hiItemGuid);
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", m_hiItemGuid);
CharacterDatabase.PExecute("DELETE FROM guild_bank_item WHERE item_guid >= '%u'", m_hiItemGuid);
-
result = WorldDatabase.Query("SELECT MAX(guid) FROM gameobject" );
if( result )
{
m_hiGoGuid = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = CharacterDatabase.Query("SELECT MAX(id) FROM auctionhouse" );
if( result )
{
m_auctionid = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = CharacterDatabase.Query( "SELECT MAX(id) FROM mail" );
if( result )
{
m_mailid = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = CharacterDatabase.Query( "SELECT MAX(id) FROM item_text" );
if( result )
{
m_ItemTextId = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = CharacterDatabase.Query( "SELECT MAX(guid) FROM corpse" );
if( result )
{
m_hiCorpseGuid = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = CharacterDatabase.Query("SELECT MAX(arenateamid) FROM arena_team");
if (result)
{
m_arenaTeamId = (*result)[0].GetUInt32()+1;
delete result;
}
-
result = CharacterDatabase.Query("SELECT MAX(setguid) FROM character_equipmentsets");
if (result)
{
m_equipmentSetGuid = (*result)[0].GetUInt64()+1;
delete result;
}
-
result = CharacterDatabase.Query( "SELECT MAX(guildid) FROM guild" );
if (result)
{
@@ -5926,7 +4932,6 @@ void ObjectMgr::SetHighestGuids()
delete result;
}
}
-
uint32 ObjectMgr::GenerateArenaTeamId()
{
if(m_arenaTeamId>=0xFFFFFFFE)
@@ -5936,7 +4941,6 @@ uint32 ObjectMgr::GenerateArenaTeamId()
}
return m_arenaTeamId++;
}
-
uint32 ObjectMgr::GenerateAuctionID()
{
if(m_auctionid>=0xFFFFFFFE)
@@ -5946,7 +4950,6 @@ uint32 ObjectMgr::GenerateAuctionID()
}
return m_auctionid++;
}
-
uint64 ObjectMgr::GenerateEquipmentSetGuid()
{
if(m_equipmentSetGuid>=0xFFFFFFFFFFFFFFFEll)
@@ -5956,7 +4959,6 @@ uint64 ObjectMgr::GenerateEquipmentSetGuid()
}
return m_equipmentSetGuid++;
}
-
uint32 ObjectMgr::GenerateGuildId()
{
if(m_guildId>=0xFFFFFFFE)
@@ -5966,7 +4968,6 @@ uint32 ObjectMgr::GenerateGuildId()
}
return m_guildId++;
}
-
uint32 ObjectMgr::GenerateMailID()
{
if(m_mailid>=0xFFFFFFFE)
@@ -5976,7 +4977,6 @@ uint32 ObjectMgr::GenerateMailID()
}
return m_mailid++;
}
-
uint32 ObjectMgr::GenerateItemTextID()
{
if(m_ItemTextId>=0xFFFFFFFE)
@@ -5986,7 +4986,6 @@ uint32 ObjectMgr::GenerateItemTextID()
}
return m_ItemTextId++;
}
-
uint32 ObjectMgr::CreateItemText(std::string text)
{
uint32 newItemTextId = GenerateItemTextID();
@@ -6000,7 +4999,6 @@ uint32 ObjectMgr::CreateItemText(std::string text)
CharacterDatabase.Execute(query.str().c_str()); //needs to be run this way, because mail body may be more than 1024 characters
return newItemTextId;
}
-
uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
{
switch(guidhigh)
@@ -6064,42 +5062,31 @@ uint32 ObjectMgr::GenerateLowGuid(HighGuid guidhigh)
default:
ASSERT(0);
}
-
ASSERT(0);
return 0;
}
-
void ObjectMgr::LoadGameObjectLocales()
{
mGameObjectLocaleMap.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT entry,"
"name_loc1,name_loc2,name_loc3,name_loc4,name_loc5,name_loc6,name_loc7,name_loc8,"
"castbarcaption_loc1,castbarcaption_loc2,castbarcaption_loc3,castbarcaption_loc4,"
"castbarcaption_loc5,castbarcaption_loc6,castbarcaption_loc7,castbarcaption_loc8 FROM locales_gameobject");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outString(">> Loaded 0 gameobject locale strings. DB table `locales_gameobject` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 entry = fields[0].GetUInt32();
-
GameObjectLocale& data = mGameObjectLocaleMap[entry];
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i].GetCppString();
@@ -6110,12 +5097,10 @@ void ObjectMgr::LoadGameObjectLocales()
{
if(data.Name.size() <= idx)
data.Name.resize(idx+1);
-
data.Name[idx] = str;
}
}
}
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i+(MAX_LOCALE-1)].GetCppString();
@@ -6126,20 +5111,15 @@ void ObjectMgr::LoadGameObjectLocales()
{
if(data.CastBarCaption.size() <= idx)
data.CastBarCaption.resize(idx+1);
-
data.CastBarCaption[idx] = str;
}
}
}
-
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %lu gameobject locale strings", (unsigned long)mGameObjectLocaleMap.size() );
}
-
struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader>
{
template<class D>
@@ -6148,16 +5128,13 @@ struct SQLGameObjectLoader : public SQLStorageLoaderBase<SQLGameObjectLoader>
dst = D(objmgr.GetScriptId(src));
}
};
-
inline void CheckGOLockId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N)
{
if (sLockStore.LookupEntry(dataN))
return;
-
sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but lock (Id: %u) not found.",
goInfo->id,goInfo->type,N,goInfo->door.lockId,goInfo->door.lockId);
}
-
inline void CheckGOLinkedTrapId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N)
{
if (GameObjectInfo const* trapInfo = sGOStorage.LookupEntry<GameObjectInfo>(dataN))
@@ -6172,62 +5149,49 @@ inline void CheckGOLinkedTrapId(GameObjectInfo const* goInfo,uint32 dataN,uint32
goInfo->id,goInfo->type,N,dataN,dataN);
*/
}
-
inline void CheckGOSpellId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N)
{
if (sSpellStore.LookupEntry(dataN))
return;
-
sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but Spell (Entry %u) not exist.",
goInfo->id,goInfo->type,N,dataN,dataN);
}
-
inline void CheckAndFixGOChairHeightId(GameObjectInfo const* goInfo,uint32 const& dataN,uint32 N)
{
if (dataN <= (UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR) )
return;
-
sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but correct chair height in range 0..%i.",
goInfo->id,goInfo->type,N,dataN,UNIT_STAND_STATE_SIT_HIGH_CHAIR-UNIT_STAND_STATE_SIT_LOW_CHAIR);
-
// prevent client and server unexpected work
const_cast<uint32&>(dataN) = 0;
}
-
inline void CheckGONoDamageImmuneId(GameObjectInfo const* goInfo,uint32 dataN,uint32 N)
{
// 0/1 correct values
if (dataN <= 1)
return;
-
sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but expected boolean (0/1) noDamageImmune field value.",
goInfo->id,goInfo->type,N,dataN);
}
-
inline void CheckGOConsumable(GameObjectInfo const* goInfo,uint32 dataN,uint32 N)
{
// 0/1 correct values
if (dataN <= 1)
return;
-
sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data%d=%u but expected boolean (0/1) consumable field value.",
goInfo->id,goInfo->type,N,dataN);
}
-
void ObjectMgr::LoadGameobjectInfo()
{
SQLGameObjectLoader loader;
loader.Load(sGOStorage);
-
// some checks
for(uint32 id = 1; id < sGOStorage.MaxEntry; id++)
{
GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(id);
if (!goInfo)
continue;
-
// some GO types have unused go template, check goInfo->displayId at GO spawn data loading or ignore
-
switch(goInfo->type)
{
case GAMEOBJECT_TYPE_DOOR: //0
@@ -6255,9 +5219,7 @@ void ObjectMgr::LoadGameobjectInfo()
{
if (goInfo->chest.lockId)
CheckGOLockId(goInfo,goInfo->chest.lockId,0);
-
CheckGOConsumable(goInfo,goInfo->chest.consumable,3);
-
if (goInfo->chest.linkedTrapId) // linked trap
CheckGOLinkedTrapId(goInfo,goInfo->chest.linkedTrapId,7);
break;
@@ -6283,7 +5245,6 @@ void ObjectMgr::LoadGameobjectInfo()
sLog.outErrorDb("Gameobject (Entry: %u GoType: %u) have data0=%u but SpellFocus (Id: %u) not exist.",
id,goInfo->type,goInfo->spellFocus.focusId,goInfo->spellFocus.focusId);
}
-
if (goInfo->spellFocus.linkedTrapId) // linked trap
CheckGOLinkedTrapId(goInfo,goInfo->spellFocus.linkedTrapId,2);
break;
@@ -6292,9 +5253,7 @@ void ObjectMgr::LoadGameobjectInfo()
{
if (goInfo->goober.lockId)
CheckGOLockId(goInfo,goInfo->goober.lockId,0);
-
CheckGOConsumable(goInfo,goInfo->goober.consumable,3);
-
if (goInfo->goober.pageId) // pageId
{
if (!sPageTextStore.LookupEntry<PageText>(goInfo->goober.pageId))
@@ -6371,33 +5330,25 @@ void ObjectMgr::LoadGameobjectInfo()
break;
}
}
-
sLog.outString( ">> Loaded %u game object templates", sGOStorage.RecordCount );
sLog.outString();
}
-
void ObjectMgr::LoadExplorationBaseXP()
{
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT level,basexp FROM exploration_basexp");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u BaseXP definitions", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
bar.step();
-
Field *fields = result->Fetch();
uint32 level = fields[0].GetUInt32();
uint32 basexp = fields[1].GetUInt32();
@@ -6405,47 +5356,36 @@ void ObjectMgr::LoadExplorationBaseXP()
++count;
}
while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u BaseXP definitions", count );
}
-
uint32 ObjectMgr::GetBaseXP(uint32 level)
{
return mBaseXPTable[level] ? mBaseXPTable[level] : 0;
}
-
uint32 ObjectMgr::GetXPForLevel(uint32 level)
{
if (level < mPlayerXPperLevel.size())
return mPlayerXPperLevel[level];
return 0;
}
-
void ObjectMgr::LoadPetNames()
{
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT word,entry,half FROM pet_name_generation");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u pet name parts", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
bar.step();
-
Field *fields = result->Fetch();
std::string word = fields[0].GetString();
uint32 entry = fields[1].GetUInt32();
@@ -6458,11 +5398,9 @@ void ObjectMgr::LoadPetNames()
}
while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u pet name parts", count );
}
-
void ObjectMgr::LoadPetNumber()
{
QueryResult* result = CharacterDatabase.Query("SELECT MAX(id) FROM character_pet");
@@ -6472,19 +5410,15 @@ void ObjectMgr::LoadPetNumber()
m_hiPetNumber = fields[0].GetUInt32()+1;
delete result;
}
-
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded the max pet number: %d", m_hiPetNumber-1);
}
-
std::string ObjectMgr::GeneratePetName(uint32 entry)
{
std::vector<std::string> & list0 = PetHalfName0[entry];
std::vector<std::string> & list1 = PetHalfName1[entry];
-
if(list0.empty() || list1.empty())
{
CreatureInfo const *cinfo = GetCreatureTemplate(entry);
@@ -6493,90 +5427,67 @@ std::string ObjectMgr::GeneratePetName(uint32 entry)
petname = cinfo->Name;
return std::string(petname);
}
-
return *(list0.begin()+urand(0, list0.size()-1)) + *(list1.begin()+urand(0, list1.size()-1));
}
-
uint32 ObjectMgr::GeneratePetNumber()
{
return ++m_hiPetNumber;
}
-
void ObjectMgr::LoadCorpses()
{
uint32 count = 0;
// 0 1 2 3 4 5 6 7 8 10
QueryResult *result = CharacterDatabase.Query("SELECT position_x, position_y, position_z, orientation, map, data, time, corpse_type, instance, guid FROM corpse WHERE corpse_type <> 0");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u corpses", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
bar.step();
-
Field *fields = result->Fetch();
-
uint32 guid = fields[result->GetFieldCount()-1].GetUInt32();
-
Corpse *corpse = new Corpse;
if(!corpse->LoadFromDB(guid,fields))
{
delete corpse;
continue;
}
-
ObjectAccessor::Instance().AddCorpse(corpse);
-
++count;
}
while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u corpses", count );
}
-
void ObjectMgr::LoadReputationOnKill()
{
uint32 count = 0;
-
// 0 1 2
QueryResult *result = WorldDatabase.Query("SELECT creature_id, RewOnKillRepFaction1, RewOnKillRepFaction2,"
// 3 4 5 6 7 8 9
"IsTeamAward1, MaxStanding1, RewOnKillRepValue1, IsTeamAward2, MaxStanding2, RewOnKillRepValue2, TeamDependent "
"FROM creature_onkill_reputation");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 creature award reputation definitions. DB table `creature_onkill_reputation` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 creature_id = fields[0].GetUInt32();
-
ReputationOnKillEntry repOnKill;
repOnKill.repfaction1 = fields[1].GetUInt32();
repOnKill.repfaction2 = fields[2].GetUInt32();
@@ -6587,13 +5498,11 @@ void ObjectMgr::LoadReputationOnKill()
repOnKill.reputation_max_cap2 = fields[7].GetUInt32();
repOnKill.repvalue2 = fields[8].GetInt32();
repOnKill.team_dependent = fields[9].GetUInt8();
-
if(!GetCreatureTemplate(creature_id))
{
sLog.outErrorDb("Table `creature_onkill_reputation` have data for not existed creature entry (%u), skipped",creature_id);
continue;
}
-
if(repOnKill.repfaction1)
{
FactionEntry const *factionEntry1 = sFactionStore.LookupEntry(repOnKill.repfaction1);
@@ -6603,7 +5512,6 @@ void ObjectMgr::LoadReputationOnKill()
continue;
}
}
-
if(repOnKill.repfaction2)
{
FactionEntry const *factionEntry2 = sFactionStore.LookupEntry(repOnKill.repfaction2);
@@ -6613,45 +5521,32 @@ void ObjectMgr::LoadReputationOnKill()
continue;
}
}
-
mRepOnKill[creature_id] = repOnKill;
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString(">> Loaded %u creature award reputation definitions", count);
}
-
void ObjectMgr::LoadPointsOfInterest()
{
uint32 count = 0;
-
// 0 1 2 3 4 5
QueryResult *result = WorldDatabase.Query("SELECT entry, x, y, icon, flags, data, icon_name FROM points_of_interest");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 Points of Interest definitions. DB table `points_of_interest` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 point_id = fields[0].GetUInt32();
-
PointOfInterest POI;
POI.x = fields[1].GetFloat();
POI.y = fields[2].GetFloat();
@@ -6659,50 +5554,37 @@ void ObjectMgr::LoadPointsOfInterest()
POI.flags = fields[4].GetUInt32();
POI.data = fields[5].GetUInt32();
POI.icon_name = fields[6].GetCppString();
-
if(!MaNGOS::IsValidMapCoord(POI.x,POI.y))
{
sLog.outErrorDb("Table `points_of_interest` (Entry: %u) have invalid coordinates (X: %f Y: %f), ignored.",point_id,POI.x,POI.y);
continue;
}
-
mPointsOfInterest[point_id] = POI;
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString(">> Loaded %u Points of Interest definitions", count);
}
-
void ObjectMgr::LoadNPCSpellClickSpells()
{
uint32 count = 0;
-
mSpellClickInfoMap.clear();
// 0 1 2 3 4 5 6 7 8
QueryResult *result = WorldDatabase.Query("SELECT npc_entry, spell_id, quest_start, quest_start_active, quest_end, cast_flags, aura_required, aura_forbidden, user_type FROM npc_spellclick_spells");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 spellclick spells. DB table `npc_spellclick_spells` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 npc_entry = fields[0].GetUInt32();
CreatureInfo const* cInfo = GetCreatureTemplate(npc_entry);
if (!cInfo)
@@ -6710,10 +5592,8 @@ void ObjectMgr::LoadNPCSpellClickSpells()
sLog.outErrorDb("Table npc_spellclick_spells references unknown creature_template %u. Skipping entry.", npc_entry);
continue;
}
-
if(!(cInfo->npcflag & UNIT_NPC_FLAG_SPELLCLICK))
const_cast<CreatureInfo*>(cInfo)->npcflag |= UNIT_NPC_FLAG_SPELLCLICK;
-
uint32 spellid = fields[1].GetUInt32();
SpellEntry const *spellinfo = sSpellStore.LookupEntry(spellid);
if (!spellinfo)
@@ -6721,7 +5601,6 @@ void ObjectMgr::LoadNPCSpellClickSpells()
sLog.outErrorDb("Table npc_spellclick_spells references unknown spellid %u. Skipping entry.", spellid);
continue;
}
-
uint32 auraRequired = fields[6].GetUInt32();
if (auraRequired)
{
@@ -6732,7 +5611,6 @@ void ObjectMgr::LoadNPCSpellClickSpells()
continue;
}
}
-
uint32 auraForbidden = fields[7].GetUInt32();
if (auraForbidden)
{
@@ -6743,9 +5621,7 @@ void ObjectMgr::LoadNPCSpellClickSpells()
continue;
}
}
-
uint32 quest_start = fields[2].GetUInt32();
-
// quest might be 0 to enable spellclick independent of any quest
if (quest_start)
{
@@ -6755,9 +5631,7 @@ void ObjectMgr::LoadNPCSpellClickSpells()
continue;
}
}
-
bool quest_start_active = fields[3].GetBool();
-
uint32 quest_end = fields[4].GetUInt32();
// quest might be 0 to enable spellclick active infinity after start quest
if (quest_end)
@@ -6768,11 +5642,9 @@ void ObjectMgr::LoadNPCSpellClickSpells()
continue;
}
}
-
uint8 userType = fields[8].GetUInt8();
if (userType >= SPELL_CLICK_USER_MAX)
sLog.outErrorDb("Table npc_spellclick_spells references unknown user type %u. Skipping entry.", uint32(userType));
-
uint8 castFlags = fields[5].GetUInt8();
SpellClickInfo info;
info.spellId = spellid;
@@ -6784,82 +5656,61 @@ void ObjectMgr::LoadNPCSpellClickSpells()
info.auraForbidden = auraForbidden;
info.userType = SpellClickUserTypes(userType);
mSpellClickInfoMap.insert(SpellClickInfoMap::value_type(npc_entry, info));
-
// mark creature template as spell clickable
const_cast<CreatureInfo*>(cInfo)->npcflag |= UNIT_NPC_FLAG_SPELLCLICK;
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString(">> Loaded %u spellclick definitions", count);
}
-
void ObjectMgr::LoadWeatherZoneChances()
{
uint32 count = 0;
-
// 0 1 2 3 4 5 6 7 8 9 10 11 12
QueryResult *result = WorldDatabase.Query("SELECT zone, spring_rain_chance, spring_snow_chance, spring_storm_chance, summer_rain_chance, summer_snow_chance, summer_storm_chance, fall_rain_chance, fall_snow_chance, fall_storm_chance, winter_rain_chance, winter_snow_chance, winter_storm_chance FROM game_weather");
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 weather definitions. DB table `game_weather` is empty.");
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 zone_id = fields[0].GetUInt32();
-
WeatherZoneChances& wzc = mWeatherZoneMap[zone_id];
-
for(uint8 season = 0; season < WEATHER_SEASONS; ++season)
{
wzc.data[season].rainChance = fields[season * (MAX_WEATHER_TYPE-1) + 1].GetUInt32();
wzc.data[season].snowChance = fields[season * (MAX_WEATHER_TYPE-1) + 2].GetUInt32();
wzc.data[season].stormChance = fields[season * (MAX_WEATHER_TYPE-1) + 3].GetUInt32();
-
if(wzc.data[season].rainChance > 100)
{
wzc.data[season].rainChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong rain chance > 100%%",zone_id,season);
}
-
if(wzc.data[season].snowChance > 100)
{
wzc.data[season].snowChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong snow chance > 100%%",zone_id,season);
}
-
if(wzc.data[season].stormChance > 100)
{
wzc.data[season].stormChance = 25;
sLog.outErrorDb("Weather for zone %u season %u has wrong storm chance > 100%%",zone_id,season);
}
}
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString(">> Loaded %u weather definitions", count);
}
-
void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t)
{
mCreatureRespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
@@ -6867,17 +5718,14 @@ void ObjectMgr::SaveCreatureRespawnTime(uint32 loguid, uint32 instance, time_t t
if(t)
WorldDatabase.PExecute("INSERT INTO creature_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance);
}
-
void ObjectMgr::DeleteCreatureData(uint32 guid)
{
// remove mapid*cellid -> guid_set map
CreatureData const* data = GetCreatureData(guid);
if(data)
RemoveCreatureFromGrid(guid, data);
-
mCreatureDataMap.erase(guid);
}
-
void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t)
{
mGORespawnTimes[MAKE_PAIR64(loguid,instance)] = t;
@@ -6885,107 +5733,81 @@ void ObjectMgr::SaveGORespawnTime(uint32 loguid, uint32 instance, time_t t)
if(t)
WorldDatabase.PExecute("INSERT INTO gameobject_respawn VALUES ( '%u', '" UI64FMTD "', '%u' )", loguid, uint64(t), instance);
}
-
void ObjectMgr::DeleteRespawnTimeForInstance(uint32 instance)
{
RespawnTimes::iterator next;
-
for(RespawnTimes::iterator itr = mGORespawnTimes.begin(); itr != mGORespawnTimes.end(); itr = next)
{
next = itr;
++next;
-
if(GUID_HIPART(itr->first)==instance)
mGORespawnTimes.erase(itr);
}
-
for(RespawnTimes::iterator itr = mCreatureRespawnTimes.begin(); itr != mCreatureRespawnTimes.end(); itr = next)
{
next = itr;
++next;
-
if(GUID_HIPART(itr->first)==instance)
mCreatureRespawnTimes.erase(itr);
}
-
WorldDatabase.PExecute("DELETE FROM creature_respawn WHERE instance = '%u'", instance);
WorldDatabase.PExecute("DELETE FROM gameobject_respawn WHERE instance = '%u'", instance);
}
-
void ObjectMgr::DeleteGOData(uint32 guid)
{
// remove mapid*cellid -> guid_set map
GameObjectData const* data = GetGOData(guid);
if(data)
RemoveGameobjectFromGrid(guid, data);
-
mGameObjectDataMap.erase(guid);
}
-
void ObjectMgr::AddCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid, uint32 instance)
{
// corpses are always added to spawn mode 0 and they are spawned by their instance id
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid];
cell_guids.corpses[player_guid] = instance;
}
-
void ObjectMgr::DeleteCorpseCellData(uint32 mapid, uint32 cellid, uint32 player_guid)
{
// corpses are always added to spawn mode 0 and they are spawned by their instance id
CellObjectGuids& cell_guids = mMapObjectGuids[MAKE_PAIR32(mapid,0)][cellid];
cell_guids.corpses.erase(player_guid);
}
-
void ObjectMgr::LoadQuestRelationsHelper(QuestRelations& map,char const* table)
{
map.clear(); // need for reload case
-
uint32 count = 0;
-
QueryResult *result = WorldDatabase.PQuery("SELECT id,quest FROM %s",table);
-
if(!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded 0 quest relations from %s. DB table `%s` is empty.",table,table);
return;
}
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
uint32 id = fields[0].GetUInt32();
uint32 quest = fields[1].GetUInt32();
-
if(mQuestTemplates.find(quest) == mQuestTemplates.end())
{
sLog.outErrorDb("Table `%s: Quest %u listed for entry %u does not exist.",table,quest,id);
continue;
}
-
map.insert(QuestRelations::value_type(id,quest));
-
++count;
} while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString(">> Loaded %u quest relations from %s", count,table);
}
-
void ObjectMgr::LoadGameobjectQuestRelations()
{
LoadQuestRelationsHelper(mGOQuestRelations,"gameobject_questrelation");
-
for(QuestRelations::iterator itr = mGOQuestRelations.begin(); itr != mGOQuestRelations.end(); ++itr)
{
GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first);
@@ -6995,11 +5817,9 @@ void ObjectMgr::LoadGameobjectQuestRelations()
sLog.outErrorDb("Table `gameobject_questrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second);
}
}
-
void ObjectMgr::LoadGameobjectInvolvedRelations()
{
LoadQuestRelationsHelper(mGOQuestInvolvedRelations,"gameobject_involvedrelation");
-
for(QuestRelations::iterator itr = mGOQuestInvolvedRelations.begin(); itr != mGOQuestInvolvedRelations.end(); ++itr)
{
GameObjectInfo const* goInfo = GetGameObjectInfo(itr->first);
@@ -7009,11 +5829,9 @@ void ObjectMgr::LoadGameobjectInvolvedRelations()
sLog.outErrorDb("Table `gameobject_involvedrelation` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER",itr->first,itr->second);
}
}
-
void ObjectMgr::LoadCreatureQuestRelations()
{
LoadQuestRelationsHelper(mCreatureQuestRelations,"creature_questrelation");
-
for(QuestRelations::iterator itr = mCreatureQuestRelations.begin(); itr != mCreatureQuestRelations.end(); ++itr)
{
CreatureInfo const* cInfo = GetCreatureTemplate(itr->first);
@@ -7023,11 +5841,9 @@ void ObjectMgr::LoadCreatureQuestRelations()
sLog.outErrorDb("Table `creature_questrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second);
}
}
-
void ObjectMgr::LoadCreatureInvolvedRelations()
{
LoadQuestRelationsHelper(mCreatureQuestInvolvedRelations,"creature_involvedrelation");
-
for(QuestRelations::iterator itr = mCreatureQuestInvolvedRelations.begin(); itr != mCreatureQuestInvolvedRelations.end(); ++itr)
{
CreatureInfo const* cInfo = GetCreatureTemplate(itr->first);
@@ -7037,64 +5853,48 @@ void ObjectMgr::LoadCreatureInvolvedRelations()
sLog.outErrorDb("Table `creature_involvedrelation` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER",itr->first,itr->second);
}
}
-
void ObjectMgr::LoadReservedPlayersNames()
{
m_ReservedNames.clear(); // need for reload case
-
QueryResult *result = WorldDatabase.Query("SELECT name FROM reserved_name");
-
uint32 count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u reserved player names", count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
Field* fields;
do
{
bar.step();
fields = result->Fetch();
std::string name= fields[0].GetCppString();
-
std::wstring wstr;
if(!Utf8toWStr (name,wstr))
{
sLog.outError("Table `reserved_name` have invalid name: %s", name.c_str() );
continue;
}
-
wstrToLower(wstr);
-
m_ReservedNames.insert(wstr);
++count;
} while ( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u reserved player names", count );
}
-
bool ObjectMgr::IsReservedName( const std::string& name ) const
{
std::wstring wstr;
if(!Utf8toWStr (name,wstr))
return false;
-
wstrToLower(wstr);
-
return m_ReservedNames.find(wstr) != m_ReservedNames.end();
}
-
enum LanguageType
{
LT_BASIC_LATIN = 0x0000,
@@ -7103,7 +5903,6 @@ enum LanguageType
LT_EAST_ASIA = 0x0004,
LT_ANY = 0xFFFF
};
-
static LanguageType GetRealmLanguageType(bool create)
{
switch(sWorld.getConfig(CONFIG_REALM_ZONE))
@@ -7131,7 +5930,6 @@ static LanguageType GetRealmLanguageType(bool create)
return create ? LT_BASIC_LATIN : LT_ANY; // basic-Latin at create, any at login
}
}
-
bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bool create = false)
{
if(strictMask==0) // any language, ignore realm
@@ -7144,7 +5942,6 @@ bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bo
return true;
return false;
}
-
if(strictMask & 0x2) // realm zone specific
{
LanguageType lt = GetRealmLanguageType(create);
@@ -7158,111 +5955,84 @@ bool isValidString(std::wstring wstr, uint32 strictMask, bool numericOrSpace, bo
if(isEastAsianString(wstr,numericOrSpace))
return true;
}
-
if(strictMask & 0x1) // basic Latin
{
if(isBasicLatinString(wstr,numericOrSpace))
return true;
}
-
return false;
}
-
uint8 ObjectMgr::CheckPlayerName( const std::string& name, bool create )
{
std::wstring wname;
if(!Utf8toWStr(name,wname))
return CHAR_NAME_INVALID_CHARACTER;
-
if(wname.size() > MAX_PLAYER_NAME)
return CHAR_NAME_TOO_LONG;
-
uint32 minName = sWorld.getConfig(CONFIG_MIN_PLAYER_NAME);
if(wname.size() < minName)
return CHAR_NAME_TOO_SHORT;
-
uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PLAYER_NAMES);
if(!isValidString(wname,strictMask,false,create))
return CHAR_NAME_MIXED_LANGUAGES;
-
return CHAR_NAME_SUCCESS;
}
-
bool ObjectMgr::IsValidCharterName( const std::string& name )
{
std::wstring wname;
if(!Utf8toWStr(name,wname))
return false;
-
if(wname.size() > MAX_CHARTER_NAME)
return false;
-
uint32 minName = sWorld.getConfig(CONFIG_MIN_CHARTER_NAME);
if(wname.size() < minName)
return false;
-
uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_CHARTER_NAMES);
-
return isValidString(wname,strictMask,true);
}
-
PetNameInvalidReason ObjectMgr::CheckPetName( const std::string& name )
{
std::wstring wname;
if(!Utf8toWStr(name,wname))
return PET_NAME_INVALID;
-
if(wname.size() > MAX_PET_NAME)
return PET_NAME_TOO_LONG;
-
uint32 minName = sWorld.getConfig(CONFIG_MIN_PET_NAME);
if(wname.size() < minName)
return PET_NAME_TOO_SHORT;
-
uint32 strictMask = sWorld.getConfig(CONFIG_STRICT_PET_NAMES);
if(!isValidString(wname,strictMask,false))
return PET_NAME_MIXED_LANGUAGES;
-
return PET_NAME_SUCCESS;
}
-
int ObjectMgr::GetIndexForLocale( LocaleConstant loc )
{
if(loc==LOCALE_enUS)
return -1;
-
for(size_t i=0;i < m_LocalForIndex.size(); ++i)
if(m_LocalForIndex[i]==loc)
return i;
-
return -1;
}
-
LocaleConstant ObjectMgr::GetLocaleForIndex(int i)
{
if (i<0 || i>=m_LocalForIndex.size())
return LOCALE_enUS;
-
return m_LocalForIndex[i];
}
-
int ObjectMgr::GetOrNewIndexForLocale( LocaleConstant loc )
{
if(loc==LOCALE_enUS)
return -1;
-
for(size_t i=0;i < m_LocalForIndex.size(); ++i)
if(m_LocalForIndex[i]==loc)
return i;
-
m_LocalForIndex.push_back(loc);
return m_LocalForIndex.size()-1;
}
-
void ObjectMgr::LoadGameObjectForQuests()
{
mGameObjectForQuestSet.clear(); // need for reload case
-
if( !sGOStorage.MaxEntry )
{
barGoLink bar( 1 );
@@ -7271,10 +6041,8 @@ void ObjectMgr::LoadGameObjectForQuests()
sLog.outString( ">> Loaded 0 GameObjects for quests" );
return;
}
-
barGoLink bar( sGOStorage.MaxEntry - 1 );
uint32 count = 0;
-
// collect GO entries for GO that must activated
for(uint32 go_entry = 1; go_entry < sGOStorage.MaxEntry; ++go_entry)
{
@@ -7282,14 +6050,12 @@ void ObjectMgr::LoadGameObjectForQuests()
GameObjectInfo const* goInfo = sGOStorage.LookupEntry<GameObjectInfo>(go_entry);
if(!goInfo)
continue;
-
switch(goInfo->type)
{
// scan GO chest with loot including quest items
case GAMEOBJECT_TYPE_CHEST:
{
uint32 loot_id = goInfo->GetLootId();
-
// find quest loot for GO
if(LootTemplates_Gameobject.HaveQuestLootFor(loot_id))
{
@@ -7311,11 +6077,9 @@ void ObjectMgr::LoadGameObjectForQuests()
break;
}
}
-
sLog.outString();
sLog.outString( ">> Loaded %u GameObjects for quests", count );
}
-
bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 min_value, int32 max_value)
{
int32 start_value = min_value;
@@ -7328,7 +6092,6 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi
sLog.outErrorDb("Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.",table,min_value,max_value);
return false;
}
-
// real range (max+1,min+1) exaple: (-10,-1000) -> -999...-10+1
std::swap(start_value,end_value);
++start_value;
@@ -7342,7 +6105,6 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi
return false;
}
}
-
// cleanup affected map part for reloading case
for(TrinityStringLocaleMap::iterator itr = mTrinityStringLocaleMap.begin(); itr != mTrinityStringLocaleMap.end();)
{
@@ -7351,15 +6113,11 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi
else
++itr;
}
-
QueryResult *result = db.PQuery("SELECT entry,content_default,content_loc1,content_loc2,content_loc3,content_loc4,content_loc5,content_loc6,content_loc7,content_loc8 FROM %s",table);
-
if (!result)
{
barGoLink bar(1);
-
bar.step();
-
sLog.outString();
if (min_value == MIN_TRINITY_STRING_ID) // error only in case internal strings
sLog.outErrorDb(">> Loaded 0 trinity strings. DB table `%s` is empty. Cannot continue.",table);
@@ -7367,18 +6125,13 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi
sLog.outString(">> Loaded 0 string templates. DB table `%s` is empty.",table);
return false;
}
-
uint32 count = 0;
-
barGoLink bar(result->GetRowCount());
-
do
{
Field *fields = result->Fetch();
bar.step();
-
int32 entry = fields[0].GetInt32();
-
if (entry==0)
{
sLog.outErrorDb("Table `%s` contain reserved entry 0, ignored.",table);
@@ -7389,21 +6142,16 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi
sLog.outErrorDb("Table `%s` contain entry %i out of allowed range (%d - %d), ignored.",table,entry,min_value,max_value);
continue;
}
-
TrinityStringLocale& data = mTrinityStringLocaleMap[entry];
-
if (data.Content.size() > 0)
{
sLog.outErrorDb("Table `%s` contain data for already loaded entry %i (from another table?), ignored.",table,entry);
continue;
}
-
data.Content.resize(1);
++count;
-
// 0 -> default, idx in to idx+1
data.Content[0] = fields[1].GetCppString();
-
for(uint8 i = 1; i < MAX_LOCALE; ++i)
{
std::string str = fields[i+1].GetCppString();
@@ -7415,24 +6163,19 @@ bool ObjectMgr::LoadTrinityStrings(DatabaseType& db, char const* table, int32 mi
// 0 -> default, idx in to idx+1
if (data.Content.size() <= idx+1)
data.Content.resize(idx+2);
-
data.Content[idx+1] = str;
}
}
}
} while (result->NextRow());
-
delete result;
-
sLog.outString();
if (min_value == MIN_TRINITY_STRING_ID)
sLog.outString( ">> Loaded %u Trinity strings from table %s", count,table);
else
sLog.outString( ">> Loaded %u string templates from %s", count,table);
-
return true;
}
-
const char *ObjectMgr::GetTrinityString(int32 entry, int locale_idx) const
{
// locale_idx==-1 -> default, locale_idx >= 0 in to idx+1
@@ -7444,35 +6187,28 @@ const char *ObjectMgr::GetTrinityString(int32 entry, int locale_idx) const
else
return msl->Content[0].c_str();
}
-
if(entry > 0)
sLog.outErrorDb("Entry %i not found in `trinity_string` table.",entry);
else
sLog.outErrorDb("Trinity string entry %i not found in DB.",entry);
return "<error>";
}
-
void ObjectMgr::LoadSpellDisabledEntrys()
{
m_DisabledPlayerSpells.clear(); // need for reload case
m_DisabledCreatureSpells.clear();
m_DisabledPetSpells.clear();
QueryResult *result = WorldDatabase.Query("SELECT entry, disable_mask FROM spell_disabled");
-
uint32 total_count = 0;
-
if( !result )
{
barGoLink bar( 1 );
bar.step();
-
sLog.outString();
sLog.outString( ">> Loaded %u disabled spells", total_count );
return;
}
-
barGoLink bar( result->GetRowCount() );
-
Field* fields;
do
{
@@ -7493,59 +6229,44 @@ void ObjectMgr::LoadSpellDisabledEntrys()
m_DisabledPetSpells.insert(spellid);
++total_count;
} while ( result->NextRow() );
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u disabled spells from `spell_disabled`", total_count);
}
-
void ObjectMgr::LoadFishingBaseSkillLevel()
{
mFishingBaseForArea.clear(); // for reload case
-
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT entry,skill FROM skill_fishing_base_level");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded `skill_fishing_base_level`, table is empty!");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
bar.step();
-
Field *fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
int32 skill = fields[1].GetInt32();
-
AreaTableEntry const* fArea = GetAreaEntryByAreaID(entry);
if(!fArea)
{
sLog.outErrorDb("AreaId %u defined in `skill_fishing_base_level` does not exist",entry);
continue;
}
-
mFishingBaseForArea[entry] = skill;
++count;
}
while (result->NextRow());
-
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u areas for fishing base skill level", count );
}
-
// Searches for the same condition already in Conditions store
// Returns Id if found, else adds it to Conditions and returns Id
uint16 ObjectMgr::GetConditionId( ConditionType condition, uint32 value1, uint32 value2 )
@@ -7556,18 +6277,14 @@ uint16 ObjectMgr::GetConditionId( ConditionType condition, uint32 value1, uint32
if (lc == mConditions[i])
return i;
}
-
mConditions.push_back(lc);
-
if(mConditions.size() > 0xFFFF)
{
sLog.outError("Conditions store overflow! Current and later loaded conditions will ignored!");
return 0;
}
-
return mConditions.size() - 1;
}
-
bool ObjectMgr::CheckDeclinedNames( std::wstring mainpart, DeclinedName const& names )
{
for(uint8 i =0; i < MAX_DECLINED_NAME_CASES; ++i)
@@ -7575,13 +6292,11 @@ bool ObjectMgr::CheckDeclinedNames( std::wstring mainpart, DeclinedName const& n
std::wstring wname;
if(!Utf8toWStr(names.name[i],wname))
return false;
-
if(mainpart!=GetMainPartOfName(wname,i+1))
return false;
}
return true;
}
-
uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id)
{
AreaTriggerScriptMap::const_iterator i = mAreaTriggerScripts.find(trigger_id);
@@ -7589,13 +6304,11 @@ uint32 ObjectMgr::GetAreaTriggerScriptId(uint32 trigger_id)
return i->second;
return 0;
}
-
// Checks if player meets the condition
bool PlayerCondition::Meets(Player const * player) const
{
if( !player )
return false; // player not present, return false
-
switch (condition)
{
case CONDITION_NONE:
@@ -7646,7 +6359,6 @@ bool PlayerCondition::Meets(Player const * player) const
return false;
}
}
-
// Verification of condition values validity
bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 value2)
{
@@ -7655,7 +6367,6 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
sLog.outErrorDb("Condition has bad type of %u, skipped ", condition );
return false;
}
-
switch (condition)
{
case CONDITION_AURA:
@@ -7794,7 +6505,6 @@ bool PlayerCondition::IsValid(ConditionType condition, uint32 value1, uint32 val
}
return true;
}
-
SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial)
{
switch(pSkill->categoryId)
@@ -7826,79 +6536,59 @@ SkillRangeType GetSkillRangeType(SkillLineEntry const *pSkill, bool racial)
return SKILL_RANGE_NONE;
}
}
-
void ObjectMgr::LoadGameTele()
{
m_GameTeleMap.clear(); // for reload case
-
uint32 count = 0;
QueryResult *result = WorldDatabase.Query("SELECT id, position_x, position_y, position_z, orientation, map, name FROM game_tele");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded `game_tele`, table is empty!");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
do
{
bar.step();
-
Field *fields = result->Fetch();
-
uint32 id = fields[0].GetUInt32();
-
GameTele gt;
-
gt.position_x = fields[1].GetFloat();
gt.position_y = fields[2].GetFloat();
gt.position_z = fields[3].GetFloat();
gt.orientation = fields[4].GetFloat();
gt.mapId = fields[5].GetUInt32();
gt.name = fields[6].GetCppString();
-
if(!MapManager::IsValidMapCoord(gt.mapId,gt.position_x,gt.position_y,gt.position_z,gt.orientation))
{
sLog.outErrorDb("Wrong position for id %u (name: %s) in `game_tele` table, ignoring.",id,gt.name.c_str());
continue;
}
-
if(!Utf8toWStr(gt.name,gt.wnameLow))
{
sLog.outErrorDb("Wrong UTF8 name for id %u in `game_tele` table, ignoring.",id);
continue;
}
-
wstrToLower( gt.wnameLow );
-
m_GameTeleMap[id] = gt;
-
++count;
}
while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %u GameTeleports", count );
}
-
GameTele const* ObjectMgr::GetGameTele(const std::string& name) const
{
// explicit name case
std::wstring wname;
if(!Utf8toWStr(name,wname))
return false;
-
// converting string that we try to find to lower case
wstrToLower( wname );
-
// Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
const GameTele* alt = NULL;
for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr)
@@ -7908,10 +6598,8 @@ GameTele const* ObjectMgr::GetGameTele(const std::string& name) const
else if (alt == NULL && itr->second.wnameLow.find(wname) != std::wstring::npos)
alt = &itr->second;
}
-
return alt;
}
-
bool ObjectMgr::AddGameTele(GameTele& tele)
{
// find max id
@@ -7919,31 +6607,23 @@ bool ObjectMgr::AddGameTele(GameTele& tele)
for(GameTeleMap::const_iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr)
if(itr->first > new_id)
new_id = itr->first;
-
// use next
++new_id;
-
if(!Utf8toWStr(tele.name,tele.wnameLow))
return false;
-
wstrToLower( tele.wnameLow );
-
m_GameTeleMap[new_id] = tele;
-
return WorldDatabase.PExecuteLog("INSERT INTO game_tele (id,position_x,position_y,position_z,orientation,map,name) VALUES (%u,%f,%f,%f,%f,%d,'%s')",
new_id,tele.position_x,tele.position_y,tele.position_z,tele.orientation,tele.mapId,tele.name.c_str());
}
-
bool ObjectMgr::DeleteGameTele(const std::string& name)
{
// explicit name case
std::wstring wname;
if(!Utf8toWStr(name,wname))
return false;
-
// converting string that we try to find to lower case
wstrToLower( wname );
-
for(GameTeleMap::iterator itr = m_GameTeleMap.begin(); itr != m_GameTeleMap.end(); ++itr)
{
if(itr->second.wnameLow == wname)
@@ -7953,54 +6633,39 @@ bool ObjectMgr::DeleteGameTele(const std::string& name)
return true;
}
}
-
return false;
}
-
void ObjectMgr::LoadTrainerSpell()
{
// For reload case
for (CacheTrainerSpellMap::iterator itr = m_mCacheTrainerSpellMap.begin(); itr != m_mCacheTrainerSpellMap.end(); ++itr)
itr->second.Clear();
m_mCacheTrainerSpellMap.clear();
-
std::set<uint32> skip_trainers;
-
QueryResult *result = WorldDatabase.Query("SELECT entry, spell,spellcost,reqskill,reqskillvalue,reqlevel FROM npc_trainer");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded `npc_trainer`, table is empty!");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
std::set<uint32> talentIds;
-
uint32 count = 0;
do
{
bar.step();
-
Field* fields = result->Fetch();
-
uint32 entry = fields[0].GetUInt32();
uint32 spell = fields[1].GetUInt32();
-
CreatureInfo const* cInfo = GetCreatureTemplate(entry);
-
if(!cInfo)
{
sLog.outErrorDb("Table `npc_trainer` have entry for not existed creature template (Entry: %u), ignore", entry);
continue;
}
-
if(!(cInfo->npcflag & UNIT_NPC_FLAG_TRAINER))
{
if(skip_trainers.count(entry) == 0)
@@ -8010,20 +6675,17 @@ void ObjectMgr::LoadTrainerSpell()
}
continue;
}
-
SpellEntry const *spellinfo = sSpellStore.LookupEntry(spell);
if(!spellinfo)
{
sLog.outErrorDb("Table `npc_trainer` for Trainer (Entry: %u ) has non existing spell %u, ignore", entry,spell);
continue;
}
-
if(!SpellMgr::IsSpellValid(spellinfo))
{
sLog.outErrorDb("Table `npc_trainer` for Trainer (Entry: %u) has broken learning spell %u, ignore", entry, spell);
continue;
}
-
if(GetTalentSpellCost(spell))
{
if(talentIds.count(spell)==0)
@@ -8033,19 +6695,15 @@ void ObjectMgr::LoadTrainerSpell()
}
continue;
}
-
TrainerSpellData& data = m_mCacheTrainerSpellMap[entry];
-
TrainerSpell& trainerSpell = data.spellList[spell];
trainerSpell.spell = spell;
trainerSpell.spellCost = fields[2].GetUInt32();
trainerSpell.reqSkill = fields[3].GetUInt32();
trainerSpell.reqSkillValue = fields[4].GetUInt32();
trainerSpell.reqLevel = fields[5].GetUInt32();
-
if(!trainerSpell.reqLevel)
trainerSpell.reqLevel = spellinfo->spellLevel;
-
// calculate learned spell for profession case when stored cast-spell
trainerSpell.learnedSpell = spell;
for(uint8 i = 0; i <3; ++i)
@@ -8058,99 +6716,72 @@ void ObjectMgr::LoadTrainerSpell()
break;
}
}
-
if(SpellMgr::IsProfessionSpell(trainerSpell.learnedSpell))
data.trainerType = 2;
-
++count;
-
} while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %d Trainers", count );
}
-
void ObjectMgr::LoadVendors()
{
// For reload case
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
itr->second.Clear();
m_mCacheVendorItemMap.clear();
-
std::set<uint32> skip_vendors;
-
QueryResult *result = WorldDatabase.Query("SELECT entry, item, maxcount, incrtime, ExtendedCost FROM npc_vendor");
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded `npc_vendor`, table is empty!");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
uint32 count = 0;
do
{
bar.step();
Field* fields = result->Fetch();
-
uint32 entry = fields[0].GetUInt32();
uint32 item_id = fields[1].GetUInt32();
uint32 maxcount = fields[2].GetUInt32();
uint32 incrtime = fields[3].GetUInt32();
uint32 ExtendedCost = fields[4].GetUInt32();
-
if(!IsVendorItemValid(entry,item_id,maxcount,incrtime,ExtendedCost,NULL,&skip_vendors))
continue;
-
VendorItemData& vList = m_mCacheVendorItemMap[entry];
-
vList.AddItem(item_id,maxcount,incrtime,ExtendedCost);
++count;
-
} while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %d Vendors ", count );
}
-
void ObjectMgr::LoadNpcTextId()
{
-
m_mCacheNpcTextIdMap.clear();
-
QueryResult* result = WorldDatabase.Query("SELECT npc_guid, textid FROM npc_gossip");
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded `npc_gossip`, table is empty!");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
uint32 count = 0;
uint32 guid,textid;
do
{
bar.step();
-
Field* fields = result->Fetch();
-
guid = fields[0].GetUInt32();
textid = fields[1].GetUInt32();
-
if (!GetCreatureData(guid))
{
sLog.outErrorDb("Table `npc_gossip` have not existed creature (GUID: %u) entry, ignore. ",guid);
@@ -8161,47 +6792,34 @@ void ObjectMgr::LoadNpcTextId()
sLog.outErrorDb("Table `npc_gossip` for creature (GUID: %u) have wrong Textid (%u), ignore. ", guid, textid);
continue;
}
-
m_mCacheNpcTextIdMap[guid] = textid ;
++count;
-
} while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %d NpcTextId ", count );
}
-
void ObjectMgr::LoadNpcOptions()
{
m_mCacheNpcOptionList.clear(); // For reload case
-
QueryResult *result = WorldDatabase.Query(
// 0 1 2 3 4 5 6 7 8
"SELECT id,gossip_id,npcflag,icon,action,box_money,coded,option_text,box_text "
"FROM npc_option");
-
if( !result )
{
barGoLink bar( 1 );
-
bar.step();
-
sLog.outString();
sLog.outErrorDb(">> Loaded `npc_option`, table is empty!");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
uint32 count = 0;
-
do
{
bar.step();
-
Field* fields = result->Fetch();
-
GossipOption go;
go.Id = fields[0].GetUInt32();
go.GossipId = fields[1].GetUInt32();
@@ -8212,40 +6830,30 @@ void ObjectMgr::LoadNpcOptions()
go.Coded = fields[6].GetUInt8()!=0;
go.OptionText = fields[7].GetCppString();
go.BoxText = fields[8].GetCppString();
-
m_mCacheNpcOptionList.push_back(go);
-
++count;
-
} while (result->NextRow());
delete result;
-
sLog.outString();
sLog.outString( ">> Loaded %d npc_option entries", count );
}
-
void ObjectMgr::AddVendorItem( uint32 entry,uint32 item, uint32 maxcount, uint32 incrtime, uint32 extendedcost, bool savetodb)
{
VendorItemData& vList = m_mCacheVendorItemMap[entry];
vList.AddItem(item,maxcount,incrtime,extendedcost);
-
if(savetodb) WorldDatabase.PExecuteLog("INSERT INTO npc_vendor (entry,item,maxcount,incrtime,extendedcost) VALUES('%u','%u','%u','%u','%u')",entry, item, maxcount,incrtime,extendedcost);
}
-
bool ObjectMgr::RemoveVendorItem( uint32 entry,uint32 item, bool savetodb)
{
CacheVendorItemMap::iterator iter = m_mCacheVendorItemMap.find(entry);
if(iter == m_mCacheVendorItemMap.end())
return false;
-
if(!iter->second.FindItem(item))
return false;
-
iter->second.RemoveItem(item);
if(savetodb) WorldDatabase.PExecuteLog("DELETE FROM npc_vendor WHERE entry='%u' AND item='%u'",entry, item);
return true;
}
-
bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 maxcount, uint32 incrtime, uint32 ExtendedCost, Player* pl, std::set<uint32>* skip_vendors, uint32 ORnpcflag ) const
{
CreatureInfo const* cInfo = GetCreatureTemplate(vendor_entry);
@@ -8257,7 +6865,6 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
sLog.outErrorDb("Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: %u), ignore", vendor_entry);
return false;
}
-
if(!((cInfo->npcflag | ORnpcflag) & UNIT_NPC_FLAG_VENDOR))
{
if(!skip_vendors || skip_vendors->count(vendor_entry)==0)
@@ -8266,13 +6873,11 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
ChatHandler(pl).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
else
sLog.outErrorDb("Table `(game_event_)npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry);
-
if(skip_vendors)
skip_vendors->insert(vendor_entry);
}
return false;
}
-
if(!GetItemPrototype(item_id))
{
if(pl)
@@ -8281,7 +6886,6 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
sLog.outErrorDb("Table `(game_event_)npc_vendor` for Vendor (Entry: %u) have in item list non-existed item (%u), ignore",vendor_entry,item_id);
return false;
}
-
if(ExtendedCost && !sItemExtendedCostStore.LookupEntry(ExtendedCost))
{
if(pl)
@@ -8290,7 +6894,6 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
sLog.outErrorDb("Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore",item_id,ExtendedCost,vendor_entry);
return false;
}
-
if(maxcount > 0 && incrtime == 0)
{
if(pl)
@@ -8307,11 +6910,9 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
sLog.outErrorDb( "Table `(game_event_)npc_vendor` has `maxcount`=0 for item %u of vendor (Entry: %u) but `incrtime`<>0, ignore", item_id, vendor_entry);
return false;
}
-
VendorItemData const* vItems = GetNpcVendorItemList(vendor_entry);
if(!vItems)
return true; // later checks for non-empty lists
-
if(vItems->FindItem(item_id))
{
if(pl)
@@ -8320,7 +6921,6 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
sLog.outErrorDb( "Table `(game_event_)npc_vendor` has duplicate items %u for vendor (Entry: %u), ignore", item_id, vendor_entry);
return false;
}
-
if(vItems->GetItemCount() >= MAX_VENDOR_ITEMS)
{
if(pl)
@@ -8329,10 +6929,8 @@ bool ObjectMgr::IsVendorItemValid( uint32 vendor_entry, uint32 item_id, uint32 m
sLog.outErrorDb( "Table `npc_vendor` has too many items (%u >= %i) for vendor (Entry: %u), ignore", vItems->GetItemCount(), MAX_VENDOR_ITEMS, vendor_entry);
return false;
}
-
return true;
}
-
void ObjectMgr::LoadScriptNames()
{
m_scriptNames.push_back("");
@@ -8346,7 +6944,6 @@ void ObjectMgr::LoadScriptNames()
"SELECT DISTINCT(ScriptName) FROM areatrigger_scripts WHERE ScriptName <> '' "
"UNION "
"SELECT DISTINCT(script) FROM instance_template WHERE script <> ''");
-
if( !result )
{
barGoLink bar( 1 );
@@ -8355,13 +6952,10 @@ void ObjectMgr::LoadScriptNames()
sLog.outErrorDb(">> Loaded empty set of Script Names!");
return;
}
-
barGoLink bar( result->GetRowCount() );
-
//OnEvent Changes
m_scriptNames.push_back("scripted_on_events");
uint32 count = 1;
-
do
{
bar.step();
@@ -8369,12 +6963,10 @@ void ObjectMgr::LoadScriptNames()
++count;
} while (result->NextRow());
delete result;
-
std::sort(m_scriptNames.begin(), m_scriptNames.end());
sLog.outString();
sLog.outString( ">> Loaded %d Script Names", count );
}
-
uint32 ObjectMgr::GetScriptId(const char *name)
{
// use binary search to find the script name in the sorted vector
@@ -8385,7 +6977,6 @@ uint32 ObjectMgr::GetScriptId(const char *name)
if(itr == m_scriptNames.end() || *itr != name) return 0;
return itr - m_scriptNames.begin();
}
-
void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids)
{
for(ScriptMapMap::const_iterator itrMM = scripts.begin(); itrMM != scripts.end(); ++itrMM)
@@ -8398,7 +6989,6 @@ void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids)
{
if(!GetTrinityStringLocale (itrM->second.dataint))
sLog.outErrorDb( "Table `db_script_string` not has string id %u used db script (ID: %u)", itrM->second.dataint, itrMM->first);
-
if(ids.count(itrM->second.dataint))
ids.erase(itrM->second.dataint);
}
@@ -8406,35 +6996,27 @@ void ObjectMgr::CheckScripts(ScriptMapMap const& scripts,std::set<int32>& ids)
}
}
}
-
void ObjectMgr::LoadDbScriptStrings()
{
LoadTrinityStrings(WorldDatabase,"db_script_string",MIN_DB_SCRIPT_STRING_ID,MAX_DB_SCRIPT_STRING_ID);
-
std::set<int32> ids;
-
for(int32 i = MIN_DB_SCRIPT_STRING_ID; i < MAX_DB_SCRIPT_STRING_ID; ++i)
if(GetTrinityStringLocale(i))
ids.insert(i);
-
CheckScripts(sQuestEndScripts,ids);
CheckScripts(sQuestStartScripts,ids);
CheckScripts(sSpellScripts,ids);
CheckScripts(sGameObjectScripts,ids);
CheckScripts(sEventScripts,ids);
-
CheckScripts(sWaypointScripts,ids);
-
for(std::set<int32>::const_iterator itr = ids.begin(); itr != ids.end(); ++itr)
sLog.outErrorDb( "Table `db_script_string` has unused string id %u", *itr);
}
-
// Functions for scripting access
uint32 GetAreaTriggerScriptId(uint32 trigger_id)
{
return objmgr.GetAreaTriggerScriptId(trigger_id);
}
-
bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value, int32 end_value)
{
// MAX_DB_SCRIPT_STRING_ID is max allowed negative value for scripts (scrpts can use only more deep negative values
@@ -8444,35 +7026,27 @@ bool LoadTrinityStrings(DatabaseType& db, char const* table,int32 start_value, i
sLog.outErrorDb("Table '%s' attempt loaded with reserved by mangos range (%d - %d), strings not loaded.",table,start_value,end_value+1);
return false;
}
-
return objmgr.LoadTrinityStrings(db,table,start_value,end_value);
}
-
uint32 TRINITY_DLL_SPEC GetScriptId(const char *name)
{
return objmgr.GetScriptId(name);
}
-
ObjectMgr::ScriptNameMap & GetScriptNames()
{
return objmgr.GetScriptNames();
}
-
GameObjectInfo const *GetGameObjectInfo(uint32 id)
{
return objmgr.GetGameObjectInfo(id);
}
-
CreatureInfo const *GetCreatureInfo(uint32 id)
{
return objmgr.GetCreatureTemplate(id);
}
-
void ObjectMgr::LoadTransportEvents()
{
-
QueryResult *result = WorldDatabase.Query("SELECT entry, waypoint_id, event_id FROM transport_events");
-
if( !result )
{
barGoLink bar1( 1 );
@@ -8480,57 +7054,43 @@ void ObjectMgr::LoadTransportEvents()
sLog.outString( "\n>> Transport events table is empty \n" );
return;
}
-
barGoLink bar1( result->GetRowCount() );
-
do
{
bar1.step();
-
Field *fields = result->Fetch();
-
//Load event values
uint32 entry = fields[0].GetUInt32();
uint32 waypoint_id = fields[1].GetUInt32();
uint32 event_id = fields[2].GetUInt32();
-
uint32 event_count = (entry*100)+waypoint_id;
TransportEventMap[event_count] = event_id;
}
while(result->NextRow());
-
sLog.outString( "\n>> Loaded %u transport events \n", result->GetRowCount() );
-
delete result;
}
-
CreatureInfo const* GetCreatureTemplateStore(uint32 entry)
{
return sCreatureStorage.LookupEntry<CreatureInfo>(entry);
}
-
Quest const* GetQuestTemplateStore(uint32 entry)
{
return objmgr.GetQuestTemplate(entry);
}
-
uint64 ObjectMgr::GenerateGMTicketId()
{
return ++m_GMticketid;
}
-
void ObjectMgr::LoadGMTickets()
{
m_GMTicketList.clear();
-
QueryResult *result = CharacterDatabase.Query( "SELECT guid, playerGuid, name, message, createtime, map, posX, posY, posZ, timestamp, closed, assignedto, comment FROM gm_tickets" );
-
if(!result)
{
sLog.outString(" \n>> GM Tickets table is empty, no tickets were loaded.\n" );
return;
}
-
uint16 count = 0;
barGoLink bar ((*result).GetRowCount());
GM_Ticket *ticket;
@@ -8553,29 +7113,22 @@ void ObjectMgr::LoadGMTickets()
ticket->comment = fields[12].GetCppString();
++count;
bar.step();
-
m_GMTicketList.push_back(ticket);
-
} while( result->NextRow() );
-
result = CharacterDatabase.PQuery("SELECT MAX(guid) from gm_tickets");
- m_GMticketid = (*result)[0].GetUInt64();
-
+ m_GMticketid = (*result)[0].GetUInt64();
sLog.outString(">>> %u GM Tickets loaded from the database.", count);
delete result;
}
-
void ObjectMgr::AddOrUpdateGMTicket(GM_Ticket &ticket, bool create)
{
if(create)
m_GMTicketList.push_back(&ticket);
-
- _AddOrUpdateGMTicket(ticket);
+ _AddOrUpdateGMTicket(ticket);
}
-
void ObjectMgr::_AddOrUpdateGMTicket(GM_Ticket &ticket)
{
- std::string msg(ticket.message), name(ticket.name), comment(ticket.comment);
+ std::string msg(ticket.message), name(ticket.name), comment(ticket.comment);
CharacterDatabase.escape_string(msg);
CharacterDatabase.escape_string(name);
CharacterDatabase.escape_string(comment);
@@ -8598,7 +7151,6 @@ void ObjectMgr::_AddOrUpdateGMTicket(GM_Ticket &ticket)
CharacterDatabase.Execute(ss.str().c_str());
CharacterDatabase.CommitTransaction();
}
-
void ObjectMgr::RemoveGMTicket(GM_Ticket *ticket, int64 source, bool permanently)
{
for(GmTicketList::iterator i = m_GMTicketList.begin(); i != m_GMTicketList.end(); ++i)
@@ -8615,35 +7167,28 @@ void ObjectMgr::RemoveGMTicket(GM_Ticket *ticket, int64 source, bool permanently
_AddOrUpdateGMTicket(*(*i));
}
}
-
void ObjectMgr::RemoveGMTicket(uint64 ticketGuid, int64 source, bool permanently)
{
GM_Ticket *ticket = GetGMTicket(ticketGuid);
assert( ticket );
RemoveGMTicket(ticket, source, permanently);
}
-
bool ObjectMgr::CheckDB() const
{
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(28511);
if(!cInfo || cInfo->spells[4] != 51890)
return false;
-
cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(30068);
if(!cInfo || cInfo->faction_A != 21)
return false;
-
cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(28768); // Dark Rider of Acherus
if(!cInfo || !cInfo->ScriptID)
return false;
-
cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(32627); // Wintergrasp Siege Engine
if(!cInfo || !cInfo->spells[0] || cInfo->VehicleId != 117)
return false;
-
cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(33114); // Flame Leviathan Seat
if(!cInfo || cInfo->VehicleId != 341)
return false;
-
return true;
}