Core/ObjectMgr: Refactor guild related functions into dedicated class
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user