refactor(Core/Player): Improve Channel.RestrictedLfg handling (#21145)

This commit is contained in:
Kitzunu
2025-01-21 19:09:31 +01:00
committed by GitHub
parent 7725610ff3
commit 0733c30471
9 changed files with 47 additions and 15 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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)