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.

This commit is contained in:
Treeston
2019-08-09 12:03:46 +02:00
parent 31b4b897e4
commit 464b0b059b
5 changed files with 3 additions and 34 deletions
+1 -20
View File
@@ -89,7 +89,7 @@ ChannelMgr::~ChannelMgr()
channel->SetAnnounce(dbAnnounce);
channel->SetOwnership(dbOwnership);
channel->SetPassword(dbPass);
ASSERT_NOTNULL(forTeam(team))->_customChannels.emplace(channelName, channel);
mgr->_customChannels.emplace(channelName, channel);
++count;
} while (result->NextRow());
@@ -249,25 +249,6 @@ Channel* ChannelMgr::GetChannel(uint32 channelId, std::string const& name, Playe
return ret;
}
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)
{
ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId);
@@ -47,7 +47,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 pkt = true, AreaTableEntry const* zoneEntry = nullptr) const;
void LeftChannel(std::string const& name);
void LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry);
private:
@@ -5062,12 +5062,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());
}
@@ -117,8 +117,6 @@ void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
if (channelId)
cMgr->LeftChannel(channelId, zone);
else
cMgr->LeftChannel(channelName);
}
}
+2 -7
View File
@@ -2914,14 +2914,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
{