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
+6 -6
View File
@@ -172,7 +172,7 @@ namespace Game.Chat
}
}
public void JoinChannel(Player player, string pass)
public void JoinChannel(Player player, string pass = "")
{
ObjectGuid guid = player.GetGUID();
if (IsOn(guid))
@@ -193,7 +193,7 @@ namespace Game.Chat
return;
}
if (!string.IsNullOrEmpty(_channelPassword) && pass != _channelPassword)
if (!CheckPassword(pass))
{
var builder = new ChannelNameBuilder(this, new WrongPasswordAppend());
SendToOne(builder, guid);
@@ -892,11 +892,11 @@ namespace Game.Chat
public bool IsLFG() { return GetFlags().HasAnyFlag(ChannelFlags.Lfg); }
bool IsAnnounce() { return _announceEnabled; }
void SetAnnounce(bool nannounce) { _announceEnabled = nannounce; }
string GetPassword() { return _channelPassword; }
void SetPassword(string npassword) { _channelPassword = npassword; }
void SetAnnounce(bool announce) { _announceEnabled = announce; }
public void SetPassword(string npassword) { _channelPassword = npassword; }
public bool CheckPassword(string password) { return _channelPassword.IsEmpty() || (_channelPassword == password); }
public uint GetNumPlayers() { return (uint)_playersStore.Count; }
public ChannelFlags GetFlags() { return _channelFlags; }
+23 -21
View File
@@ -67,31 +67,33 @@ namespace Game.Chat
return null;
}
public Channel GetJoinChannel(uint channelId, string name, AreaTableRecord zoneEntry = null)
public Channel GetSystemChannel(uint channelId, AreaTableRecord zoneEntry = null)
{
if (channelId != 0) // builtin
{
ObjectGuid channelGuid = CreateBuiltinChannelGuid(channelId, zoneEntry);
var channel = _channels.LookupByKey(channelGuid);
if (channel != null)
return channel;
ObjectGuid channelGuid = CreateBuiltinChannelGuid(channelId, zoneEntry);
var currentChannel = _channels.LookupByKey(channelGuid);
if (currentChannel != null)
return currentChannel;
Channel newChannel = new(channelGuid, channelId, _team, zoneEntry);
_channels[channelGuid] = newChannel;
return newChannel;
}
else // custom
{
var channel = _customChannels.LookupByKey(name.ToLower());
if (channel != null)
return channel;
Channel newChannel = new(CreateCustomChannelGuid(), name, _team);
_customChannels[name.ToLower()] = newChannel;
return newChannel;
}
Channel newChannel = new Channel(channelGuid, channelId, _team, zoneEntry);
_channels[channelGuid] = newChannel;
return newChannel;
}
public Channel CreateCustomChannel(string name)
{
if (_customChannels.ContainsKey(name.ToLower()))
return null;
Channel newChannel = new(CreateCustomChannelGuid(), name, _team);
_customChannels[name.ToLower()] = newChannel;
return newChannel;
}
public Channel GetCustomChannel(string name)
{
return _customChannels.LookupByKey(name.ToLower());
}
public Channel GetChannel(uint channelId, string name, Player player, bool notify = true, AreaTableRecord zoneEntry = null)
{
Channel result = null;