Core/ObjectMgr: Refactor guild related functions into dedicated class
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include "DBCEnums.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "DatabaseEnv.h"
|
||||
@@ -638,7 +639,7 @@ void AchievementMgr::SendAchievementEarned(AchievementEntry const* achievement)
|
||||
sLog->outDebug(LOG_FILTER_ACHIEVEMENTSYS, "AchievementMgr::SendAchievementEarned(%u)", achievement->ID);
|
||||
#endif
|
||||
|
||||
if (Guild* guild = sObjectMgr->GetGuildById(GetPlayer()->GetGuildId()))
|
||||
if (Guild* guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
|
||||
{
|
||||
Trinity::AchievementChatBuilder say_builder(*GetPlayer(), CHAT_MSG_GUILD_ACHIEVEMENT, LANG_ACHIEVEMENT_EARNED, achievement->ID);
|
||||
Trinity::LocalizedPacketDo<Trinity::AchievementChatBuilder> say_do(say_builder);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "AccountMgr.h"
|
||||
#include "PlayerDump.h"
|
||||
@@ -1690,7 +1691,7 @@ bool ChatHandler::HandleGuildCreateCommand(const char *args)
|
||||
return false;
|
||||
}
|
||||
|
||||
sObjectMgr->AddGuild (guild);
|
||||
sGuildMgr->AddGuild(guild);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1713,7 +1714,7 @@ bool ChatHandler::HandleGuildInviteCommand(const char *args)
|
||||
return false;
|
||||
|
||||
std::string glName = guildStr;
|
||||
Guild* targetGuild = sObjectMgr->GetGuildByName (glName);
|
||||
Guild* targetGuild = sGuildMgr->GetGuildByName (glName);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
@@ -1733,7 +1734,7 @@ bool ChatHandler::HandleGuildUninviteCommand(const char *args)
|
||||
if (!glId)
|
||||
return false;
|
||||
|
||||
Guild* targetGuild = sObjectMgr->GetGuildById (glId);
|
||||
Guild* targetGuild = sGuildMgr->GetGuildById (glId);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
@@ -1759,7 +1760,7 @@ bool ChatHandler::HandleGuildRankCommand(const char *args)
|
||||
if (!glId)
|
||||
return false;
|
||||
|
||||
Guild* targetGuild = sObjectMgr->GetGuildById (glId);
|
||||
Guild* targetGuild = sGuildMgr->GetGuildById (glId);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
@@ -1778,7 +1779,7 @@ bool ChatHandler::HandleGuildDeleteCommand(const char *args)
|
||||
|
||||
std::string gld = guildStr;
|
||||
|
||||
Guild* targetGuild = sObjectMgr->GetGuildByName (gld);
|
||||
Guild* targetGuild = sGuildMgr->GetGuildByName (gld);
|
||||
if (!targetGuild)
|
||||
return false;
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
#include "CellImpl.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Formulas.h"
|
||||
@@ -4726,7 +4727,7 @@ void Player::DeleteFromDB(uint64 playerguid, uint32 accountId, bool updateRealmC
|
||||
sObjectAccessor->ConvertCorpseForPlayer(playerguid);
|
||||
|
||||
if (uint32 guildId = GetGuildIdFromDB(playerguid))
|
||||
if (Guild* pGuild = sObjectMgr->GetGuildById(guildId))
|
||||
if (Guild* pGuild = sGuildMgr->GetGuildById(guildId))
|
||||
pGuild->DeleteMember(guid);
|
||||
|
||||
// remove from arena teams
|
||||
@@ -5409,7 +5410,7 @@ uint32 Player::DurabilityRepair(uint16 pos, bool cost, float discountMod, bool g
|
||||
return TotalCost;
|
||||
}
|
||||
|
||||
Guild *pGuild = sObjectMgr->GetGuildById(GetGuildId());
|
||||
Guild *pGuild = sGuildMgr->GetGuildById(GetGuildId());
|
||||
if (!pGuild)
|
||||
return TotalCost;
|
||||
|
||||
@@ -24346,7 +24347,7 @@ uint32 Player::GetReputation(uint32 factionentry)
|
||||
|
||||
std::string Player::GetGuildName()
|
||||
{
|
||||
return sObjectMgr->GetGuildById(GetGuildId())->GetName();
|
||||
return sGuildMgr->GetGuildById(GetGuildId())->GetName();
|
||||
}
|
||||
|
||||
void Player::SendDuelCountdown(uint32 counter)
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
#include "MapManager.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "UpdateMask.h"
|
||||
#include "World.h"
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "ArenaTeam.h"
|
||||
#include "Transport.h"
|
||||
#include "Language.h"
|
||||
@@ -270,7 +270,6 @@ ObjectMgr::ObjectMgr()
|
||||
m_ItemTextId = 1;
|
||||
m_mailid = 1;
|
||||
m_equipmentSetGuid = 1;
|
||||
m_guildId = 1;
|
||||
m_auctionid = 1;
|
||||
NextGroupStorageId = 1;
|
||||
}
|
||||
@@ -295,9 +294,6 @@ ObjectMgr::~ObjectMgr()
|
||||
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;
|
||||
|
||||
for (CacheVendorItemMap::iterator itr = m_mCacheVendorItemMap.begin(); itr != m_mCacheVendorItemMap.end(); ++itr)
|
||||
itr->second.Clear();
|
||||
|
||||
@@ -321,56 +317,6 @@ Group* ObjectMgr::GetGroupByStorageId(uint32 storageId) const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Guild collection
|
||||
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
|
||||
{
|
||||
std::string search = guildname;
|
||||
std::transform(search.begin(), search.end(), search.begin(), ::toupper);
|
||||
for (GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
{
|
||||
std::string gname = itr->second->GetName();
|
||||
std::transform(gname.begin(), gname.end(), gname.begin(), ::toupper);
|
||||
if (search == gname)
|
||||
return itr->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string ObjectMgr::GetGuildNameById(uint32 guildId) const
|
||||
{
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
return pGuild->GetName();
|
||||
return "";
|
||||
}
|
||||
|
||||
Guild* ObjectMgr::GetGuildByLeader(const uint64 &guid) const
|
||||
{
|
||||
for (GuildMap::const_iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
if (itr->second->GetLeaderGUID() == guid)
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObjectMgr::AddGuild(Guild* guild)
|
||||
{
|
||||
mGuildMap[guild->GetId()] = guild;
|
||||
}
|
||||
|
||||
void ObjectMgr::RemoveGuild(uint32 guildId)
|
||||
{
|
||||
mGuildMap.erase(guildId);
|
||||
}
|
||||
|
||||
void ObjectMgr::AddLocaleString(std::string& s, LocaleConstant locale, StringVector& data)
|
||||
{
|
||||
if (!s.empty())
|
||||
@@ -3841,330 +3787,6 @@ void ObjectMgr::BuildPlayerLevelInfo(uint8 race, uint8 _class, uint8 level, Play
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGuilds()
|
||||
{
|
||||
// 1. Load all guilds
|
||||
sLog->outString("Loading guilds definitions...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILDS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild definitions. DB table `guild` is empty.");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
Guild* pNewGuild = new Guild();
|
||||
|
||||
if (!pNewGuild->LoadFromDB(fields))
|
||||
{
|
||||
delete pNewGuild;
|
||||
continue;
|
||||
}
|
||||
AddGuild(pNewGuild);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Load all guild ranks
|
||||
sLog->outString("Loading guild ranks...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild rank entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_RANKS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_RANKS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild ranks. DB table `guild_rank` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
pGuild->LoadRankFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild ranks in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Load all guild members
|
||||
sLog->outString("Loading guild members...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild member entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_MEMBERS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_MEMBERS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild members. DB table `guild_member` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
pGuild->LoadMemberFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild members int %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Load all guild bank tab rights
|
||||
sLog->outString("Loading bank tab rights...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild bank right entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_RIGHTS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_RIGHTS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank tab rights. DB table `guild_bank_right` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
pGuild->LoadBankRightFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u bank tab rights in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Load all event logs
|
||||
sLog->outString("Loading guild event logs...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_GUILD_EVENT_LOGS);
|
||||
stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_GUILD_EVENT_LOG_COUNT));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_EVENTLOGS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild event logs. DB table `guild_eventlog` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
pGuild->LoadEventLogFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild event logs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Load all bank event logs
|
||||
sLog->outString("Loading guild bank event logs...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Remove log entries that exceed the number of allowed entries per guild
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_GUILD_BANK_EVENT_LOGS);
|
||||
stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_EVENTLOGS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank event logs. DB table `guild_bank_eventlog` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
pGuild->LoadBankEventLogFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild bank event logs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Load all guild bank tabs
|
||||
sLog->outString("Loading guild bank tabs...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild bank tab entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_TABS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_TABS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank tabs. DB table `guild_bank_tab` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
pGuild->LoadBankTabFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild bank tabs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 8. Fill all guild bank tabs
|
||||
sLog->outString("Filling bank tabs with items...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphan guild bank items
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEMS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_ITEMS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank tab items. DB table `guild_bank_item` or `item_instance` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[11].GetUInt32();
|
||||
|
||||
if (Guild* pGuild = GetGuildById(guildId))
|
||||
pGuild->LoadBankItemFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild bank tab items in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 9. Validate loaded guild data
|
||||
sLog->outString("Validating data of loaded guilds...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
for (GuildMap::iterator itr = mGuildMap.begin(); itr != mGuildMap.end(); ++itr)
|
||||
{
|
||||
Guild* pGuild = itr->second;
|
||||
if (pGuild)
|
||||
{
|
||||
if (!pGuild->Validate())
|
||||
{
|
||||
RemoveGuild(pGuild->GetId());
|
||||
delete pGuild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sLog->outString(">> Validated data of loaded guilds in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadGroups()
|
||||
{
|
||||
{
|
||||
@@ -6848,7 +6470,7 @@ void ObjectMgr::SetHighestGuids()
|
||||
|
||||
result = CharacterDatabase.Query("SELECT MAX(guildId) FROM guild");
|
||||
if (result)
|
||||
m_guildId = (*result)[0].GetUInt32()+1;
|
||||
sGuildMgr->SetNextGuildId((*result)[0].GetUInt32()+1);
|
||||
|
||||
result = CharacterDatabase.Query("SELECT MAX(guid) FROM groups");
|
||||
if (result)
|
||||
@@ -6877,16 +6499,6 @@ uint64 ObjectMgr::GenerateEquipmentSetGuid()
|
||||
return m_equipmentSetGuid++;
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GenerateGuildId()
|
||||
{
|
||||
if (m_guildId >= 0xFFFFFFFE)
|
||||
{
|
||||
sLog->outError("Guild ids overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
return m_guildId++;
|
||||
}
|
||||
|
||||
uint32 ObjectMgr::GenerateMailID()
|
||||
{
|
||||
if (m_mailid >= 0xFFFFFFFE)
|
||||
|
||||
@@ -44,7 +44,6 @@
|
||||
#include <functional>
|
||||
|
||||
class Group;
|
||||
class Guild;
|
||||
class Item;
|
||||
|
||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push, N), also any gcc version not support it at some platform
|
||||
@@ -609,8 +608,6 @@ class ObjectMgr
|
||||
typedef std::set<Group *> GroupSet;
|
||||
typedef std::vector<Group *> GroupStorage;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, Guild*> GuildMap;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, Quest*> QuestMap;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerMap;
|
||||
@@ -650,12 +647,6 @@ class ObjectMgr
|
||||
void SetNextGroupStorageId(uint32 storageId) { NextGroupStorageId = storageId; };
|
||||
Group* GetGroupByStorageId(uint32 storageId) const;
|
||||
|
||||
Guild* GetGuildByLeader(uint64 const&guid) const;
|
||||
Guild* GetGuildById(uint32 guildId) const;
|
||||
Guild* GetGuildByName(const std::string& guildname) const;
|
||||
std::string GetGuildNameById(uint32 guildId) const;
|
||||
void AddGuild(Guild* pGuild);
|
||||
void RemoveGuild(uint32 guildId);
|
||||
|
||||
CreatureTemplate const* GetCreatureTemplate(uint32 entry);
|
||||
CreatureTemplateContainer const* GetCreatureTemplates() { return &CreatureTemplateStore; }
|
||||
@@ -837,7 +828,6 @@ class ObjectMgr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void LoadGuilds();
|
||||
void LoadGroups();
|
||||
void LoadQuests();
|
||||
void LoadQuestRelations()
|
||||
@@ -987,7 +977,7 @@ class ObjectMgr
|
||||
uint32 GenerateLowGuid(HighGuid guidhigh);
|
||||
uint32 GenerateAuctionID();
|
||||
uint64 GenerateEquipmentSetGuid();
|
||||
uint32 GenerateGuildId();
|
||||
|
||||
uint32 GenerateMailID();
|
||||
uint32 GeneratePetNumber();
|
||||
|
||||
@@ -1258,7 +1248,6 @@ class ObjectMgr
|
||||
// first free id for selected id type
|
||||
uint32 m_auctionid;
|
||||
uint64 m_equipmentSetGuid;
|
||||
uint32 m_guildId;
|
||||
uint32 m_ItemTextId;
|
||||
uint32 m_mailid;
|
||||
uint32 m_hiPetNumber;
|
||||
@@ -1288,7 +1277,6 @@ class ObjectMgr
|
||||
|
||||
GroupSet mGroupSet;
|
||||
GroupStorage mGroupStorage;
|
||||
GuildMap mGuildMap;
|
||||
|
||||
QuestAreaTriggerMap mQuestAreaTriggerMap;
|
||||
TavernAreaTriggerSet mTavernAreaTriggerSet;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "DatabaseEnv.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "Chat.h"
|
||||
#include "Config.h"
|
||||
@@ -1092,14 +1093,14 @@ Guild::~Guild()
|
||||
bool Guild::Create(Player* pLeader, const std::string& name)
|
||||
{
|
||||
// Check if guild with such name already exists
|
||||
if (sObjectMgr->GetGuildByName(name))
|
||||
if (sGuildMgr->GetGuildByName(name))
|
||||
return false;
|
||||
|
||||
WorldSession* pLeaderSession = pLeader->GetSession();
|
||||
if (!pLeaderSession)
|
||||
return false;
|
||||
|
||||
m_id = sObjectMgr->GenerateGuildId();
|
||||
m_id = sGuildMgr->GenerateGuildId();
|
||||
m_leaderGuid = pLeader->GetGUID();
|
||||
m_name = name;
|
||||
m_info = "";
|
||||
@@ -1194,7 +1195,7 @@ void Guild::Disband()
|
||||
trans->Append(stmt);
|
||||
|
||||
CharacterDatabase.CommitTransaction(trans);
|
||||
sObjectMgr->RemoveGuild(m_id);
|
||||
sGuildMgr->RemoveGuild(m_id);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -0,0 +1,415 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Common.h"
|
||||
#include "GuildMgr.h"
|
||||
|
||||
GuildMgr::GuildMgr()
|
||||
{
|
||||
NextGuildId = 1;
|
||||
}
|
||||
|
||||
GuildMgr::~GuildMgr()
|
||||
{
|
||||
for (GuildContainer::iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr)
|
||||
delete itr->second;
|
||||
}
|
||||
|
||||
void GuildMgr::AddGuild(Guild* guild)
|
||||
{
|
||||
GuildStore[guild->GetId()] = guild;
|
||||
}
|
||||
|
||||
void GuildMgr::RemoveGuild(uint32 guildId)
|
||||
{
|
||||
GuildStore.erase(guildId);
|
||||
}
|
||||
|
||||
uint32 GuildMgr::GenerateGuildId()
|
||||
{
|
||||
if (NextGuildId >= 0xFFFFFFFE)
|
||||
{
|
||||
sLog->outError("Guild ids overflow!! Can't continue, shutting down server. ");
|
||||
World::StopNow(ERROR_EXIT_CODE);
|
||||
}
|
||||
return NextGuildId++;
|
||||
}
|
||||
|
||||
// Guild collection
|
||||
Guild* GuildMgr::GetGuildById(uint32 guildId) const
|
||||
{
|
||||
GuildContainer::const_iterator itr = GuildStore.find(guildId);
|
||||
if (itr != GuildStore.end())
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Guild* GuildMgr::GetGuildByName(const std::string& guildName) const
|
||||
{
|
||||
std::string search = guildName;
|
||||
std::transform(search.begin(), search.end(), search.begin(), ::toupper);
|
||||
for (GuildContainer::const_iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr)
|
||||
{
|
||||
std::string gname = itr->second->GetName();
|
||||
std::transform(gname.begin(), gname.end(), gname.begin(), ::toupper);
|
||||
if (search == gname)
|
||||
return itr->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
std::string GuildMgr::GetGuildNameById(uint32 guildId) const
|
||||
{
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
return guild->GetName();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
Guild* GuildMgr::GetGuildByLeader(const uint64 &guid) const
|
||||
{
|
||||
for (GuildContainer::const_iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr)
|
||||
if (itr->second->GetLeaderGUID() == guid)
|
||||
return itr->second;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void GuildMgr::LoadGuilds()
|
||||
{
|
||||
// 1. Load all guilds
|
||||
sLog->outString("Loading guilds definitions...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILDS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild definitions. DB table `guild` is empty.");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
Guild* guild = new Guild();
|
||||
|
||||
if (!guild->LoadFromDB(fields))
|
||||
{
|
||||
delete guild;
|
||||
continue;
|
||||
}
|
||||
AddGuild(guild);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Load all guild ranks
|
||||
sLog->outString("Loading guild ranks...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild rank entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_RANKS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_RANKS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild ranks. DB table `guild_rank` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadRankFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild ranks in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Load all guild members
|
||||
sLog->outString("Loading guild members...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild member entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_MEMBERS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_MEMBERS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild members. DB table `guild_member` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadMemberFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild members int %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Load all guild bank tab rights
|
||||
sLog->outString("Loading bank tab rights...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild bank right entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_RIGHTS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_RIGHTS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank tab rights. DB table `guild_bank_right` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankRightFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u bank tab rights in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Load all event logs
|
||||
sLog->outString("Loading guild event logs...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_GUILD_EVENT_LOGS);
|
||||
stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_GUILD_EVENT_LOG_COUNT));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_EVENTLOGS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild event logs. DB table `guild_eventlog` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadEventLogFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild event logs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Load all bank event logs
|
||||
sLog->outString("Loading guild bank event logs...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Remove log entries that exceed the number of allowed entries per guild
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_OLD_GUILD_BANK_EVENT_LOGS);
|
||||
stmt->setUInt32(0, sWorld->getIntConfig(CONFIG_GUILD_BANK_EVENT_LOG_COUNT));
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_EVENTLOGS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank event logs. DB table `guild_bank_eventlog` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankEventLogFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild bank event logs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 7. Load all guild bank tabs
|
||||
sLog->outString("Loading guild bank tabs...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphaned guild bank tab entries before loading the valid ones
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_TABS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_TABS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank tabs. DB table `guild_bank_tab` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[0].GetUInt32();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankTabFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild bank tabs in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 8. Fill all guild bank tabs
|
||||
sLog->outString("Filling bank tabs with items...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// Delete orphan guild bank items
|
||||
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_NONEXISTENT_GUILD_BANK_ITEMS);
|
||||
CharacterDatabase.Execute(stmt);
|
||||
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CHAR_LOAD_GUILD_BANK_ITEMS);
|
||||
PreparedQueryResult result = CharacterDatabase.Query(stmt);
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 guild bank tab items. DB table `guild_bank_item` or `item_instance` is empty.");
|
||||
sLog->outString();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 count = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 guildId = fields[11].GetUInt32();
|
||||
|
||||
if (Guild* guild = GetGuildById(guildId))
|
||||
guild->LoadBankItemFromDB(fields);
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u guild bank tab items in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
|
||||
// 9. Validate loaded guild data
|
||||
sLog->outString("Validating data of loaded guilds...");
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
for (GuildContainer::iterator itr = GuildStore.begin(); itr != GuildStore.end(); ++itr)
|
||||
{
|
||||
Guild* guild = itr->second;
|
||||
if (guild)
|
||||
{
|
||||
if (!guild->Validate())
|
||||
{
|
||||
RemoveGuild(guild->GetId());
|
||||
delete guild;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sLog->outString(">> Validated data of loaded guilds in %u ms", GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2011 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _GUILDMGR_H
|
||||
#define _GUILDMGR_H
|
||||
|
||||
#include "Guild.h"
|
||||
|
||||
class GuildMgr
|
||||
{
|
||||
friend class ACE_Singleton<GuildMgr, ACE_Null_Mutex>;
|
||||
GuildMgr();
|
||||
~GuildMgr();
|
||||
|
||||
public:
|
||||
typedef UNORDERED_MAP<uint32, Guild*> GuildContainer;
|
||||
|
||||
Guild* GetGuildByLeader(uint64 const& guid) const;
|
||||
Guild* GetGuildById(uint32 guildId) const;
|
||||
Guild* GetGuildByName(const std::string& guildName) const;
|
||||
std::string GetGuildNameById(uint32 guildId) const;
|
||||
|
||||
void LoadGuilds();
|
||||
void AddGuild(Guild* guild);
|
||||
void RemoveGuild(uint32 guildId);
|
||||
|
||||
uint32 GenerateGuildId();
|
||||
void SetNextGuildId(uint32 Id) { NextGuildId = Id; }
|
||||
|
||||
protected:
|
||||
uint32 NextGuildId;
|
||||
GuildContainer GuildStore;
|
||||
};
|
||||
|
||||
#define sGuildMgr ACE_Singleton<GuildMgr, ACE_Null_Mutex>::instance()
|
||||
|
||||
#endif
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "SystemConfig.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
@@ -598,7 +599,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket & recv_data)
|
||||
std::string name;
|
||||
|
||||
// is guild leader
|
||||
if (sObjectMgr->GetGuildByLeader(guid))
|
||||
if (sGuildMgr->GetGuildByLeader(guid))
|
||||
{
|
||||
WorldPacket data(SMSG_CHAR_DELETE, 1);
|
||||
data << (uint8)CHAR_DELETE_FAILED_GUILD_LEADER;
|
||||
@@ -773,7 +774,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder)
|
||||
|
||||
if (pCurrChar->GetGuildId() != 0)
|
||||
{
|
||||
if (Guild* pGuild = sObjectMgr->GetGuildById(pCurrChar->GetGuildId()))
|
||||
if (Guild* pGuild = sGuildMgr->GetGuildById(pCurrChar->GetGuildId()))
|
||||
pGuild->SendLoginInfo(this);
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "Common.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
@@ -314,7 +315,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
if (GetPlayer()->GetGuildId())
|
||||
{
|
||||
if (Guild *guild = sObjectMgr->GetGuildById(GetPlayer()->GetGuildId()))
|
||||
if (Guild *guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
|
||||
{
|
||||
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
|
||||
|
||||
@@ -326,7 +327,7 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket & recv_data)
|
||||
{
|
||||
if (GetPlayer()->GetGuildId())
|
||||
{
|
||||
if (Guild *guild = sObjectMgr->GetGuildById(GetPlayer()->GetGuildId()))
|
||||
if (Guild *guild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildId()))
|
||||
{
|
||||
sScriptMgr->OnPlayerChat(GetPlayer(), type, lang, msg, guild);
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Guild.h"
|
||||
@@ -32,7 +33,7 @@
|
||||
inline Guild* _GetPlayerGuild(WorldSession* session, bool sendError = false)
|
||||
{
|
||||
if (uint32 guildId = session->GetPlayer()->GetGuildId()) // If guild id = 0, player is not in guild
|
||||
if (Guild* pGuild = sObjectMgr->GetGuildById(guildId)) // Find guild by id
|
||||
if (Guild* pGuild = sGuildMgr->GetGuildById(guildId)) // Find guild by id
|
||||
return pGuild;
|
||||
if (sendError)
|
||||
Guild::SendCommandResult(session, GUILD_CREATE_S, ERR_GUILD_PLAYER_NOT_IN_GUILD);
|
||||
@@ -46,7 +47,7 @@ void WorldSession::HandleGuildQueryOpcode(WorldPacket& recvPacket)
|
||||
uint32 guildId;
|
||||
recvPacket >> guildId;
|
||||
// Use received guild id to access guild method (not player's guild id)
|
||||
if (Guild* pGuild = sObjectMgr->GetGuildById(guildId))
|
||||
if (Guild* pGuild = sGuildMgr->GetGuildById(guildId))
|
||||
pGuild->HandleQuery(this);
|
||||
else
|
||||
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_PLAYER_NOT_IN_GUILD);
|
||||
@@ -63,7 +64,7 @@ void WorldSession::HandleGuildCreateOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
Guild* pGuild = new Guild();
|
||||
if (pGuild->Create(GetPlayer(), name))
|
||||
sObjectMgr->AddGuild(pGuild);
|
||||
sGuildMgr->AddGuild(pGuild);
|
||||
else
|
||||
delete pGuild;
|
||||
}
|
||||
@@ -99,7 +100,7 @@ void WorldSession::HandleGuildAcceptOpcode(WorldPacket& /*recvPacket*/)
|
||||
// Player cannot be in guild
|
||||
if (!GetPlayer()->GetGuildId())
|
||||
// Guild where player was invited must exist
|
||||
if (Guild* pGuild = sObjectMgr->GetGuildById(GetPlayer()->GetGuildIdInvited()))
|
||||
if (Guild* pGuild = sGuildMgr->GetGuildById(GetPlayer()->GetGuildIdInvited()))
|
||||
pGuild->HandleAcceptMember(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "GossipDef.h"
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "WorldSession.h"
|
||||
#include "BigNumber.h"
|
||||
#include "SHA1.h"
|
||||
@@ -299,7 +300,7 @@ void WorldSession::HandleWhoOpcode(WorldPacket & recv_data)
|
||||
if (!(wplayer_name.empty() || wpname.find(wplayer_name) != std::wstring::npos))
|
||||
continue;
|
||||
|
||||
std::string gname = sObjectMgr->GetGuildNameById(itr->second->GetGuildId());
|
||||
std::string gname = sGuildMgr->GetGuildNameById(itr->second->GetGuildId());
|
||||
std::wstring wgname;
|
||||
if (!Utf8toWStr(gname, wgname))
|
||||
continue;
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "World.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Log.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Guild.h"
|
||||
@@ -155,7 +156,7 @@ void WorldSession::HandlePetitionBuyOpcode(WorldPacket & recv_data)
|
||||
|
||||
if (type == GUILD_CHARTER_TYPE)
|
||||
{
|
||||
if (sObjectMgr->GetGuildByName(name))
|
||||
if (sGuildMgr->GetGuildByName(name))
|
||||
{
|
||||
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, name);
|
||||
return;
|
||||
@@ -405,7 +406,7 @@ void WorldSession::HandlePetitionRenameOpcode(WorldPacket & recv_data)
|
||||
|
||||
if (type == GUILD_CHARTER_TYPE)
|
||||
{
|
||||
if (sObjectMgr->GetGuildByName(newname))
|
||||
if (sGuildMgr->GetGuildByName(newname))
|
||||
{
|
||||
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, newname);
|
||||
return;
|
||||
@@ -750,7 +751,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||
}
|
||||
|
||||
// Check if guild name is already taken
|
||||
if (sObjectMgr->GetGuildByName(name))
|
||||
if (sGuildMgr->GetGuildByName(name))
|
||||
{
|
||||
Guild::SendCommandResult(this, GUILD_CREATE_S, ERR_GUILD_NAME_EXISTS_S, name);
|
||||
return;
|
||||
@@ -822,7 +823,7 @@ void WorldSession::HandleTurnInPetitionOpcode(WorldPacket & recv_data)
|
||||
}
|
||||
|
||||
// Register guild and add guild master
|
||||
sObjectMgr->AddGuild(guild);
|
||||
sGuildMgr->AddGuild(guild);
|
||||
|
||||
// Add members from signatures
|
||||
for (uint8 i = 0; i < signatures; ++i)
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "Player.h"
|
||||
#include "Vehicle.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "World.h"
|
||||
@@ -437,7 +438,7 @@ void WorldSession::LogoutPlayer(bool Save)
|
||||
HandleMoveWorldportAckOpcode();
|
||||
|
||||
///- If the player is in a guild, update the guild roster and broadcast a logout message to other guild members
|
||||
if (Guild *pGuild = sObjectMgr->GetGuildById(_player->GetGuildId()))
|
||||
if (Guild *pGuild = sGuildMgr->GetGuildById(_player->GetGuildId()))
|
||||
pGuild->HandleMemberLogout(this);
|
||||
|
||||
///- Remove pet
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "AuctionHouseMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "ArenaTeamMgr.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "TicketMgr.h"
|
||||
#include "CreatureEventAIMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
@@ -1516,7 +1517,7 @@ void World::SetInitialWorldSettings()
|
||||
sLog->outString("Loading Auctions...");
|
||||
sAuctionMgr->LoadAuctions();
|
||||
|
||||
sObjectMgr->LoadGuilds();
|
||||
sGuildMgr->LoadGuilds();
|
||||
|
||||
sLog->outString("Loading ArenaTeams...");
|
||||
sArenaTeamMgr->LoadArenaTeams();
|
||||
|
||||
Reference in New Issue
Block a user