Check rank rights based on MemberInfo before looking up the player in guild chat broadcasts (#1234)
Load guild information on player load so that it is stored before MasterPlayer initialization, rather than waiting for a later update to properly set MasterPlayer data Always send guild MOTD and login notification on player login, even if it is a reconnect
This commit is contained in:
@@ -583,9 +583,12 @@ void Guild::BroadcastToGuild(WorldSession *session, const std::string& msg, uint
|
||||
|
||||
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
|
||||
{
|
||||
if (!HasRankRight(itr->second.RankId, GR_RIGHT_GCHATLISTEN))
|
||||
continue;
|
||||
|
||||
MasterPlayer *pl = ObjectAccessor::FindMasterPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
|
||||
|
||||
if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_GCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetMasterPlayer()->GetObjectGuid()))
|
||||
if (pl && pl->GetSession() && !pl->GetSocial()->HasIgnore(session->GetMasterPlayer()->GetObjectGuid()))
|
||||
pl->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
@@ -595,14 +598,17 @@ void Guild::BroadcastToOfficers(WorldSession *session, const std::string& msg, u
|
||||
{
|
||||
if (session && session->GetMasterPlayer() && HasRankRight(session->GetMasterPlayer()->GetRank(), GR_RIGHT_OFFCHATSPEAK))
|
||||
{
|
||||
WorldPacket data;
|
||||
ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, msg.c_str());
|
||||
|
||||
for (MemberList::const_iterator itr = members.begin(); itr != members.end(); ++itr)
|
||||
{
|
||||
WorldPacket data;
|
||||
ChatHandler::FillMessageData(&data, session, CHAT_MSG_OFFICER, language, msg.c_str());
|
||||
if (!HasRankRight(itr->second.RankId, GR_RIGHT_OFFCHATLISTEN))
|
||||
continue;
|
||||
|
||||
MasterPlayer *pl = ObjectAccessor::FindMasterPlayer(ObjectGuid(HIGHGUID_PLAYER, itr->first));
|
||||
|
||||
if (pl && pl->GetSession() && HasRankRight(pl->GetRank(), GR_RIGHT_OFFCHATLISTEN) && !pl->GetSocial()->HasIgnore(session->GetMasterPlayer()->GetObjectGuid()))
|
||||
if (pl && pl->GetSession() && !pl->GetSocial()->HasIgnore(session->GetMasterPlayer()->GetObjectGuid()))
|
||||
pl->GetSession()->SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -586,44 +586,16 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder)
|
||||
DEBUG_LOG("WORLD: Sent motd (SMSG_MOTD)");
|
||||
}
|
||||
|
||||
if (!alreadyOnline)
|
||||
if (Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId()))
|
||||
{
|
||||
//QueryResult *result = CharacterDatabase.PQuery("SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
|
||||
QueryResult *resultGuild = holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD);
|
||||
WorldPacket data(SMSG_GUILD_EVENT, (2 + guild->GetMOTD().size() + 1));
|
||||
data << uint8(GE_MOTD);
|
||||
data << uint8(1);
|
||||
data << guild->GetMOTD();
|
||||
SendPacket(&data);
|
||||
DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");
|
||||
|
||||
if (resultGuild)
|
||||
{
|
||||
Field *fields = resultGuild->Fetch();
|
||||
pCurrChar->SetInGuild(fields[0].GetUInt32());
|
||||
pCurrChar->SetRank(fields[1].GetUInt32());
|
||||
}
|
||||
else if (pCurrChar->GetGuildId()) // clear guild related fields in case wrong data about nonexistent membership
|
||||
{
|
||||
pCurrChar->SetInGuild(0);
|
||||
pCurrChar->SetRank(0);
|
||||
}
|
||||
|
||||
if (pCurrChar->GetGuildId() != 0)
|
||||
{
|
||||
Guild* guild = sGuildMgr.GetGuildById(pCurrChar->GetGuildId());
|
||||
if (guild)
|
||||
{
|
||||
data.Initialize(SMSG_GUILD_EVENT, (2 + guild->GetMOTD().size() + 1));
|
||||
data << uint8(GE_MOTD);
|
||||
data << uint8(1);
|
||||
data << guild->GetMOTD();
|
||||
SendPacket(&data);
|
||||
DEBUG_LOG("WORLD: Sent guild-motd (SMSG_GUILD_EVENT)");
|
||||
|
||||
guild->BroadcastEvent(GE_SIGNED_ON, pCurrChar->GetObjectGuid(), pCurrChar->GetName());
|
||||
}
|
||||
else
|
||||
{
|
||||
// remove wrong guild data
|
||||
sLog.outError("Player %s (GUID: %u) marked as member of nonexistent guild (id: %u), removing guild membership for player.", pCurrChar->GetName(), pCurrChar->GetGUIDLow(), pCurrChar->GetGuildId());
|
||||
pCurrChar->SetInGuild(0);
|
||||
}
|
||||
}
|
||||
guild->BroadcastEvent(GE_SIGNED_ON, pCurrChar->GetObjectGuid(), pCurrChar->GetName());
|
||||
}
|
||||
|
||||
if (!pCurrChar->isAlive())
|
||||
|
||||
@@ -14450,6 +14450,8 @@ bool Player::LoadFromDB(ObjectGuid guid, SqlQueryHolder *holder)
|
||||
_LoadBoundInstances(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBOUNDINSTANCES));
|
||||
_LoadBGData(holder->GetResult(PLAYER_LOGIN_QUERY_LOADBGDATA));
|
||||
|
||||
_LoadGuild(holder->GetResult(PLAYER_LOGIN_QUERY_LOADGUILD));
|
||||
|
||||
MapEntry const* mapEntry = sMapStorage.LookupEntry<MapEntry>(GetMapId());
|
||||
|
||||
// Check for valid map
|
||||
@@ -15713,6 +15715,35 @@ bool Player::_LoadHomeBind(QueryResult *result)
|
||||
return true;
|
||||
}
|
||||
|
||||
void Player::_LoadGuild(QueryResult* result)
|
||||
{
|
||||
//"SELECT guildid,rank FROM guild_member WHERE guid = '%u'",pCurrChar->GetGUIDLow());
|
||||
|
||||
if (result)
|
||||
{
|
||||
Field *fields = result->Fetch();
|
||||
SetInGuild(fields[0].GetUInt32());
|
||||
SetRank(fields[1].GetUInt32());
|
||||
}
|
||||
else // clear guild related fields in case wrong data about nonexistent membership
|
||||
{
|
||||
SetInGuild(0);
|
||||
SetRank(0);
|
||||
}
|
||||
|
||||
if (GetGuildId() != 0)
|
||||
{
|
||||
Guild* guild = sGuildMgr.GetGuildById(GetGuildId());
|
||||
if (!guild)
|
||||
{
|
||||
// remove wrong guild data
|
||||
sLog.outError("%s marked as member of nonexistent guild (id: %u), removing guild membership for player.", GetGuidStr().c_str(), GetGuildId());
|
||||
SetInGuild(0);
|
||||
SetRank(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
/*** SAVE SYSTEM ***/
|
||||
/*********************************************************/
|
||||
|
||||
@@ -2250,6 +2250,7 @@ class MANGOS_DLL_SPEC Player final: public Unit
|
||||
bool _LoadHomeBind(QueryResult *result);
|
||||
void _LoadBGData(QueryResult* result);
|
||||
void _LoadIntoDataField(const char* data, uint32 startOffset, uint32 count);
|
||||
void _LoadGuild(QueryResult* result);
|
||||
|
||||
/*********************************************************/
|
||||
/*** SAVE SYSTEM ***/
|
||||
|
||||
Reference in New Issue
Block a user