Core/ObjectMgr:
- Fix a startup crash in guild loading when loading from the guild subtables with an invalid guild ID. - Abort loading guild subtables if no entries were found in guild table - Code style cleanup in affected functions Fixes issue #4095 --HG-- branch : trunk
This commit is contained in:
@@ -3464,6 +3464,17 @@ void ObjectMgr::LoadGuilds()
|
|||||||
"BackgroundColor,info,motd,createdate,BankMoney,COUNT(guild_bank_tab.guildid) "
|
"BackgroundColor,info,motd,createdate,BankMoney,COUNT(guild_bank_tab.guildid) "
|
||||||
"FROM guild LEFT JOIN guild_bank_tab ON guild.guildid = guild_bank_tab.guildid GROUP BY guild.guildid ORDER BY guildid ASC");
|
"FROM guild LEFT JOIN guild_bank_tab ON guild.guildid = guild_bank_tab.guildid GROUP BY guild.guildid ORDER BY guildid ASC");
|
||||||
|
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
barGoLink bar(1);
|
||||||
|
|
||||||
|
bar.step();
|
||||||
|
|
||||||
|
sLog.outString();
|
||||||
|
sLog.outString(">> Loaded 0 guild definitions");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// load guild ranks
|
// load guild ranks
|
||||||
// 0 1 2 3 4
|
// 0 1 2 3 4
|
||||||
QueryResult guildRanksResult = CharacterDatabase.Query("SELECT guildid,rid,rname,rights,BankMoneyPerDay FROM guild_rank ORDER BY guildid ASC, rid ASC");
|
QueryResult guildRanksResult = CharacterDatabase.Query("SELECT guildid,rid,rname,rights,BankMoneyPerDay FROM guild_rank ORDER BY guildid ASC, rid ASC");
|
||||||
@@ -3484,17 +3495,6 @@ void ObjectMgr::LoadGuilds()
|
|||||||
QueryResult guildBankTabRightsResult = CharacterDatabase.Query("SELECT guildid,TabId,rid,gbright,SlotPerDay FROM guild_bank_right ORDER BY guildid ASC, TabId ASC");
|
QueryResult guildBankTabRightsResult = CharacterDatabase.Query("SELECT guildid,TabId,rid,gbright,SlotPerDay FROM guild_bank_right ORDER BY guildid ASC, TabId ASC");
|
||||||
|
|
||||||
|
|
||||||
if (!result)
|
|
||||||
{
|
|
||||||
barGoLink bar(1);
|
|
||||||
|
|
||||||
bar.step();
|
|
||||||
|
|
||||||
sLog.outString();
|
|
||||||
sLog.outString(">> Loaded 0 guild definitions");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
barGoLink bar(result->GetRowCount());
|
barGoLink bar(result->GetRowCount());
|
||||||
|
|
||||||
uint32 maxid = 0;
|
uint32 maxid = 0;
|
||||||
@@ -3524,7 +3524,8 @@ void ObjectMgr::LoadGuilds()
|
|||||||
if (maxid < newGuild->GetId())
|
if (maxid < newGuild->GetId())
|
||||||
maxid = newGuild->GetId();
|
maxid = newGuild->GetId();
|
||||||
|
|
||||||
} while (result->NextRow());
|
}
|
||||||
|
while (result->NextRow());
|
||||||
|
|
||||||
std::vector<Guild*> GuildVector(maxid + 1);
|
std::vector<Guild*> GuildVector(maxid + 1);
|
||||||
|
|
||||||
@@ -3568,6 +3569,8 @@ void ObjectMgr::LoadGuildEvents(std::vector<Guild*>& GuildVector, QueryResult& r
|
|||||||
{
|
{
|
||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
uint32 guildid = fields[6].GetUInt32();
|
uint32 guildid = fields[6].GetUInt32();
|
||||||
|
if (guildid >= GuildVector.size())
|
||||||
|
return;
|
||||||
|
|
||||||
if (!GuildVector[guildid]->m_GuildEventLogNextGuid)
|
if (!GuildVector[guildid]->m_GuildEventLogNextGuid)
|
||||||
GuildVector[guildid]->m_GuildEventLogNextGuid = fields[0].GetUInt32();
|
GuildVector[guildid]->m_GuildEventLogNextGuid = fields[0].GetUInt32();
|
||||||
@@ -3597,6 +3600,9 @@ void ObjectMgr::LoadGuildBankEvents(std::vector<Guild*>& GuildVector, QueryResul
|
|||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
uint32 logGuid = fields[0].GetUInt32();
|
uint32 logGuid = fields[0].GetUInt32();
|
||||||
uint32 guildid = fields[7].GetUInt32();
|
uint32 guildid = fields[7].GetUInt32();
|
||||||
|
if (guildid >= GuildVector.size())
|
||||||
|
return;
|
||||||
|
|
||||||
uint8 TabId = fields[8].GetUInt8();
|
uint8 TabId = fields[8].GetUInt8();
|
||||||
|
|
||||||
if (TabId < GuildVector[guildid]->GetPurchasedTabs() || TabId == GUILD_BANK_MONEY_LOGS_TAB)
|
if (TabId < GuildVector[guildid]->GetPurchasedTabs() || TabId == GUILD_BANK_MONEY_LOGS_TAB)
|
||||||
@@ -3663,6 +3669,8 @@ void ObjectMgr::LoadGuildBanks(std::vector<Guild*>& GuildVector, QueryResult& re
|
|||||||
Field *fields = result->Fetch();
|
Field *fields = result->Fetch();
|
||||||
uint32 TabId = fields[0].GetUInt32();
|
uint32 TabId = fields[0].GetUInt32();
|
||||||
uint32 guildid = fields[4].GetUInt32();
|
uint32 guildid = fields[4].GetUInt32();
|
||||||
|
if (guildid >= GuildVector.size())
|
||||||
|
return;
|
||||||
|
|
||||||
if (TabId < GuildVector[guildid]->GetPurchasedTabs())
|
if (TabId < GuildVector[guildid]->GetPurchasedTabs())
|
||||||
{
|
{
|
||||||
@@ -3689,6 +3697,8 @@ void ObjectMgr::LoadGuildBanks(std::vector<Guild*>& GuildVector, QueryResult& re
|
|||||||
uint32 ItemGuid = itemfields[13].GetUInt32();
|
uint32 ItemGuid = itemfields[13].GetUInt32();
|
||||||
uint32 ItemEntry = itemfields[14].GetUInt32();
|
uint32 ItemEntry = itemfields[14].GetUInt32();
|
||||||
uint32 guildid = itemfields[15].GetUInt32();
|
uint32 guildid = itemfields[15].GetUInt32();
|
||||||
|
if (guildid >= GuildVector.size())
|
||||||
|
return;
|
||||||
|
|
||||||
if (TabId >= GuildVector[guildid]->GetPurchasedTabs())
|
if (TabId >= GuildVector[guildid]->GetPurchasedTabs())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user