Core/Channels: Fix a bug that would cause channel settings to disappear in certain settings. Fix a bug that would cause channels to not be saved on .server shutdown without delay. Closes #23699.

(cherry picked from commit 464b0b059b)
This commit is contained in:
Treeston
2019-08-09 12:03:46 +02:00
committed by Shauren
parent 66f5275d26
commit f434241305
5 changed files with 2 additions and 33 deletions

View File

@@ -239,25 +239,6 @@ Channel* ChannelMgr::GetChannel(uint32 channelId, std::string const& name, Playe
return result;
}
void ChannelMgr::LeftChannel(std::string const& name)
{
std::wstring channelName;
if (!Utf8toWStr(name, channelName))
return;
wstrToLower(channelName);
auto itr = _customChannels.find(channelName);
if (itr == _customChannels.end())
return;
Channel* channel = itr->second;
if (!channel->GetNumPlayers())
{
_customChannels.erase(itr);
delete channel;
}
}
void ChannelMgr::LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry)
{
auto itr = _channels.find(CreateBuiltinChannelGuid(channelId, zoneEntry));

View File

@@ -46,7 +46,6 @@ class TC_GAME_API ChannelMgr
Channel* CreateCustomChannel(std::string const& name);
Channel* GetCustomChannel(std::string const& name) const;
Channel* GetChannel(uint32 channelId, std::string const& name, Player* player, bool notify = true, AreaTableEntry const* zoneEntry = nullptr) const;
void LeftChannel(std::string const& name);
void LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry);
private:

View File

@@ -4843,12 +4843,8 @@ void Player::CleanupChannels()
// delete channel if empty
if (ChannelMgr* cMgr = ChannelMgr::ForTeam(GetTeam()))
{
if (ch->IsConstant())
cMgr->LeftChannel(ch->GetChannelId(), ch->GetZoneEntry());
else
cMgr->LeftChannel(ch->GetName());
}
}
TC_LOG_DEBUG("chat.system", "Player::CleanupChannels: Channels of player '%s' (%s) cleaned up.", GetName().c_str(), GetGUID().ToString().c_str());
}

View File

@@ -103,8 +103,6 @@ void WorldSession::HandleLeaveChannel(WorldPackets::Channel::LeaveChannel& packe
if (packet.ZoneChannelID)
cMgr->LeftChannel(packet.ZoneChannelID, zone);
else
cMgr->LeftChannel(packet.ChannelName);
}
}

View File

@@ -3174,14 +3174,9 @@ void World::ShutdownServ(uint32 time, uint32 options, uint8 exitcode, const std:
m_ShutdownMask = options;
m_ExitCode = exitcode;
///- If the shutdown time is 0, set m_stopEvent (except if shutdown is 'idle' with remaining sessions)
///- If the shutdown time is 0, evaluate shutdown on next tick (no message)
if (time == 0)
{
if (!(options & SHUTDOWN_MASK_IDLE) || GetActiveAndQueuedSessionCount() == 0)
m_stopEvent = true; // exist code already set
else
m_ShutdownTimer = 1; //So that the session count is re-evaluated at next world tick
}
m_ShutdownTimer = 1;
///- Else set the shutdown timer and warn users
else
{