Core/Chat: Rewrite some custom channel handling. Channel creation now properly saves passwords.

Port From (https://github.com/TrinityCore/TrinityCore/commit/ea753efb9370455979c8af8ebaafa734b77d6052)
This commit is contained in:
hondacrx
2021-12-27 17:23:39 -05:00
parent 855c9611e0
commit 12f472cee1
4 changed files with 56 additions and 34 deletions
+24 -4
View File
@@ -41,7 +41,7 @@ namespace Game
return;
}
if (string.IsNullOrEmpty(packet.ChannelName))
if (packet.ChannelName.IsEmpty())
return;
if (packet.ChannelName.IsNumber())
@@ -50,9 +50,29 @@ namespace Game
ChannelManager cMgr = ChannelManager.ForTeam(GetPlayer().GetTeam());
if (cMgr != null)
{
Channel channel = cMgr.GetJoinChannel((uint)packet.ChatChannelId, packet.ChannelName, zone);
if (channel != null)
channel.JoinChannel(GetPlayer(), packet.Password);
if (packet.ChatChannelId != 0)
{
// system channel
Channel channel = cMgr.GetSystemChannel((uint)packet.ChatChannelId, zone);
if (channel != null)
channel.JoinChannel(GetPlayer());
}
else
{
// custom channel
Channel channel = cMgr.GetCustomChannel(packet.ChannelName);
if (channel != null)
channel.JoinChannel(GetPlayer(), packet.Password);
else
{
channel = cMgr.CreateCustomChannel(packet.ChannelName);
if (channel != null)
{
channel.SetPassword(packet.Password);
channel.JoinChannel(GetPlayer(), packet.Password);
}
}
}
}
}