mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 22:26:22 +00:00
refactor(Core/Player): Improve Channel.RestrictedLfg handling (#21145)
This commit is contained in:
@@ -85,7 +85,7 @@ bool ArenaSpectator::HandleSpectatorSpectateCommand(ChatHandler* handler, std::s
|
||||
if (player->IsInCombat())
|
||||
errors.push_back("Can't be in combat.");
|
||||
|
||||
if (player->isUsingLfg())
|
||||
if (player->IsUsingLfg())
|
||||
errors.push_back("Can't spectate while using LFG system.");
|
||||
|
||||
if (player->InBattlegroundQueue())
|
||||
|
||||
@@ -185,10 +185,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass)
|
||||
return;
|
||||
}
|
||||
|
||||
if (HasFlag(CHANNEL_FLAG_LFG) &&
|
||||
sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) &&
|
||||
AccountMgr::IsPlayerAccount(player->GetSession()->GetSecurity()) &&
|
||||
player->GetGroup())
|
||||
if (IsLFG() && sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !player->IsUsingLfg())
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotInLfg(&data);
|
||||
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
[[nodiscard]] uint32 GetChannelDBId() const { return _channelDBId; }
|
||||
[[nodiscard]] bool IsConstant() const { return _channelId != 0; }
|
||||
[[nodiscard]] bool IsAnnounce() const { return _announce; }
|
||||
[[nodiscard]] bool IsLFG() const { return GetFlags() & CHANNEL_FLAG_LFG; }
|
||||
[[nodiscard]] bool IsLFG() const { return HasFlag(CHANNEL_FLAG_LFG); }
|
||||
[[nodiscard]] std::string const& GetPassword() const { return _password; }
|
||||
void SetPassword(std::string const& npassword) { _password = npassword; }
|
||||
[[nodiscard]] uint32 GetNumPlayers() const { return playersStore.size(); }
|
||||
|
||||
@@ -13100,7 +13100,7 @@ PartyResult Player::CanUninviteFromGroup(ObjectGuid targetPlayerGUID) const
|
||||
return ERR_PARTY_RESULT_OK;
|
||||
}
|
||||
|
||||
bool Player::isUsingLfg()
|
||||
bool Player::IsUsingLfg()
|
||||
{
|
||||
return sLFGMgr->GetState(GetGUID()) != lfg::LFG_STATE_NONE;
|
||||
}
|
||||
|
||||
@@ -2071,6 +2071,7 @@ public:
|
||||
void LeftChannel(Channel* c);
|
||||
void CleanupChannels();
|
||||
void ClearChannelWatch();
|
||||
void UpdateLFGChannel();
|
||||
void UpdateLocalChannels(uint32 newZone);
|
||||
|
||||
void UpdateDefense();
|
||||
@@ -2406,7 +2407,7 @@ public:
|
||||
void SetAtLoginFlag(AtLoginFlags f) { m_atLoginFlags |= f; }
|
||||
void RemoveAtLoginFlag(AtLoginFlags flags, bool persist = false);
|
||||
|
||||
bool isUsingLfg();
|
||||
bool IsUsingLfg();
|
||||
bool inRandomLfgDungeon();
|
||||
|
||||
typedef std::set<uint32> DFQuestsDoneList;
|
||||
|
||||
@@ -461,6 +461,44 @@ void Player::UpdateNextMailTimeAndUnreads()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::UpdateLFGChannel()
|
||||
{
|
||||
if (!sWorld->getBoolConfig(CONFIG_RESTRICTED_LFG_CHANNEL))
|
||||
return;
|
||||
|
||||
ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeamId());
|
||||
if (!cMgr)
|
||||
return;
|
||||
|
||||
ChatChannelsEntry const* cce = sChatChannelsStore.LookupEntry(26); /*LookingForGroup*/
|
||||
Channel* cLFG = cMgr->GetJoinChannel(cce->pattern[m_session->GetSessionDbcLocale()], cce->ChannelID);
|
||||
if (!cLFG)
|
||||
return;
|
||||
|
||||
Channel* cUsed = nullptr;
|
||||
for (Channel* channel : m_channels)
|
||||
if (channel && channel->GetChannelId() == cce->ChannelID)
|
||||
{
|
||||
cUsed = cLFG;
|
||||
break;
|
||||
}
|
||||
|
||||
if (IsUsingLfg())
|
||||
{
|
||||
if (cUsed == cLFG)
|
||||
return;
|
||||
|
||||
cLFG->JoinChannel(this, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cLFG != cUsed)
|
||||
return;
|
||||
|
||||
cLFG->LeaveChannel(this, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::UpdateLocalChannels(uint32 newZone)
|
||||
{
|
||||
// pussywizard: mutex needed (tc changed opcode to THREAD UNSAFE)
|
||||
|
||||
@@ -47,15 +47,11 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
|
||||
return;
|
||||
|
||||
if (channelName.size() >= 100 || !DisallowHyperlinksAndMaybeKick(channelName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeamId()))
|
||||
{
|
||||
if (Channel* channel = cMgr->GetJoinChannel(channelName, channelId))
|
||||
channel->JoinChannel(GetPlayer(), password);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
|
||||
@@ -70,10 +66,8 @@ void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeamId()))
|
||||
{
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->LeaveChannel(GetPlayer(), true);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelList(WorldPacket& recvPacket)
|
||||
|
||||
@@ -71,6 +71,7 @@ void WorldSession::HandleLfgJoinOpcode(WorldPackets::LFG::LFGJoin& packet)
|
||||
GetPlayerInfo(), packet.Roles, newDungeons.size(), packet.Comment);
|
||||
|
||||
sLFGMgr->JoinLfg(GetPlayer(), uint8(packet.Roles), newDungeons, packet.Comment);
|
||||
GetPlayer()->UpdateLFGChannel();
|
||||
}
|
||||
|
||||
void WorldSession::HandleLfgLeaveOpcode(WorldPackets::LFG::LFGLeave& /*packet*/)
|
||||
@@ -87,6 +88,7 @@ void WorldSession::HandleLfgLeaveOpcode(WorldPackets::LFG::LFGLeave& /*packet*/)
|
||||
sLFGMgr->LeaveLfg(sLFGMgr->GetState(guid) == lfg::LFG_STATE_RAIDBROWSER ? guid : gguid);
|
||||
sLFGMgr->LeaveAllLfgQueues(guid, true, group ? group->GetGUID() : ObjectGuid::Empty);
|
||||
}
|
||||
GetPlayer()->UpdateLFGChannel();
|
||||
}
|
||||
|
||||
void WorldSession::HandleLfgProposalResultOpcode(WorldPacket& recvData)
|
||||
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
break;
|
||||
}
|
||||
|
||||
if (plr->isUsingLfg())
|
||||
if (plr->IsUsingLfg())
|
||||
{
|
||||
error = 4;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user