Core/PacketIO: Update opcodes and packet structures to 8.2.5

Port From (https://github.com/TrinityCore/TrinityCore/commit/ee2e49429f4383732b4e0f39b493470b9c1dd10c)
This commit is contained in:
hondacrx
2019-10-28 14:33:43 -04:00
parent 1e2ce61e5c
commit c6e53b2ba7
34 changed files with 1792 additions and 1280 deletions
+6 -2
View File
@@ -30,11 +30,12 @@ namespace Game.Chat
{
public class Channel
{
public Channel(uint channelId, Team team = 0, AreaTableRecord zoneEntry = null)
public Channel(ObjectGuid guid, uint channelId, Team team = 0, AreaTableRecord zoneEntry = null)
{
_channelFlags = ChannelFlags.General;
_channelId = channelId;
_channelTeam = team;
_channelGuid = guid;
_zoneEntry = zoneEntry;
ChatChannelsRecord channelEntry = CliDB.ChatChannelsStorage.LookupByKey(channelId);
@@ -50,12 +51,13 @@ namespace Game.Chat
_channelFlags |= ChannelFlags.NotLfg;
}
public Channel(string name, Team team = 0)
public Channel(ObjectGuid guid, string name, Team team = 0)
{
_announceEnabled = true;
_ownershipEnabled = true;
_channelFlags = ChannelFlags.Custom;
_channelTeam = team;
_channelGuid = guid;
_channelName = name;
// If storing custom channels in the db is enabled either load or save the channel
@@ -881,6 +883,7 @@ namespace Game.Chat
}
public uint GetChannelId() { return _channelId; }
public ObjectGuid GetChannelGuid() { return _channelGuid; }
public bool IsConstant() { return _channelId != 0; }
public bool IsLFG() { return GetFlags().HasAnyFlag(ChannelFlags.Lfg); }
@@ -924,6 +927,7 @@ namespace Game.Chat
ChannelFlags _channelFlags;
uint _channelId;
Team _channelTeam;
ObjectGuid _channelGuid;
ObjectGuid _ownerGuid;
string _channelName;
string _channelPassword;
@@ -71,6 +71,7 @@ namespace Game.Chat
//notify.InstanceID = 0;
notify.ChannelFlags = _source.GetFlags();
notify.Channel = _source.GetName(localeIdx);
notify.ChannelGUID = _source.GetChannelGuid();
return notify;
}
+47 -26
View File
@@ -29,6 +29,7 @@ namespace Game.Chat
public ChannelManager(Team team)
{
_team = team;
_guidGenerator = new ObjectGuidGenerator(HighGuid.ChatChannel);
}
public static ChannelManager ForTeam(Team team)
@@ -61,18 +62,13 @@ namespace Game.Chat
{
if (channelId != 0) // builtin
{
ChatChannelsRecord channelEntry = CliDB.ChatChannelsStorage.LookupByKey(channelId);
uint zoneId = zoneEntry != null ? zoneEntry.Id : 0;
if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.Global | ChannelDBCFlags.CityOnly))
zoneId = 0;
Tuple<uint, uint> key = Tuple.Create(channelId, zoneId);
var channel = _channels.LookupByKey(key);
ObjectGuid channelGuid = CreateBuiltinChannelGuid(channelId, zoneEntry);
var channel = _channels.LookupByKey(channelGuid);
if (channel != null)
return channel;
Channel newChannel = new Channel(channelId, _team, zoneEntry);
_channels[key] = newChannel;
Channel newChannel = new Channel(channelGuid, channelId, _team, zoneEntry);
_channels[channelGuid] = newChannel;
return newChannel;
}
else // custom
@@ -81,7 +77,7 @@ namespace Game.Chat
if (channel != null)
return channel;
Channel newChannel = new Channel(name, _team);
Channel newChannel = new Channel(CreateCustomChannelGuid(), name, _team);
_customChannels[name.ToLower()] = newChannel;
return newChannel;
}
@@ -92,13 +88,7 @@ namespace Game.Chat
Channel result = null;
if (channelId != 0) // builtin
{
ChatChannelsRecord channelEntry = CliDB.ChatChannelsStorage.LookupByKey(channelId);
uint zoneId = zoneEntry != null ? zoneEntry.Id : 0;
if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.Global | ChannelDBCFlags.CityOnly))
zoneId = 0;
Tuple<uint, uint> key = Tuple.Create(channelId, zoneId);
var channel = _channels.LookupByKey(key);
var channel = _channels.LookupByKey(CreateBuiltinChannelGuid(channelId, zoneEntry));
if (channel != null)
result = channel;
}
@@ -134,18 +124,13 @@ namespace Game.Chat
public void LeftChannel(uint channelId, AreaTableRecord zoneEntry)
{
ChatChannelsRecord channelEntry = CliDB.ChatChannelsStorage.LookupByKey(channelId);
uint zoneId = zoneEntry != null ? zoneEntry.Id : 0;
if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.Global | ChannelDBCFlags.CityOnly))
zoneId = 0;
Tuple<uint, uint> key = Tuple.Create(channelId, zoneId);
var channel = _channels.LookupByKey(key);
var guid = CreateBuiltinChannelGuid(channelId, zoneEntry);
var channel = _channels.LookupByKey(guid);
if (channel == null)
return;
if (channel.GetNumPlayers() == 0)
_channels.Remove(key);
_channels.Remove(guid);
}
public static void SendNotOnChannelNotify(Player player, string name)
@@ -156,9 +141,45 @@ namespace Game.Chat
player.SendPacket(notify);
}
ObjectGuid CreateCustomChannelGuid()
{
ulong high = 0;
high |= (ulong)HighGuid.ChatChannel << 58;
high |= (ulong)Global.WorldMgr.GetRealmId().Realm << 42;
high |= (ulong)(_team == Team.Alliance ? 3 : 5) << 4;
ObjectGuid channelGuid = new ObjectGuid();
channelGuid.SetRawValue(high, _guidGenerator.Generate());
return channelGuid;
}
ObjectGuid CreateBuiltinChannelGuid(uint channelId, AreaTableRecord zoneEntry = null)
{
ChatChannelsRecord channelEntry = CliDB.ChatChannelsStorage.LookupByKey(channelId);
uint zoneId = zoneEntry != null ? zoneEntry.Id : 0;
if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.Global | ChannelDBCFlags.CityOnly))
zoneId = 0;
ulong high = 0;
high |= (ulong)HighGuid.ChatChannel << 58;
high |= (ulong)Global.WorldMgr.GetRealmId().Realm << 42;
high |= 1ul << 25; // built-in
if (channelEntry.Flags.HasAnyFlag(ChannelDBCFlags.CityOnly2))
high |= 1ul << 24; // trade
high |= (ulong)(zoneId) << 10;
high |= (ulong)(_team == Team.Alliance ? 3 : 5) << 4;
ObjectGuid channelGuid = new ObjectGuid();
channelGuid.SetRawValue(high, channelId);
return channelGuid;
}
Dictionary<string, Channel> _customChannels = new Dictionary<string, Channel>();
Dictionary<Tuple<uint /*channelId*/, uint /*zoneId*/>, Channel> _channels = new Dictionary<Tuple<uint, uint>, Channel>();
Dictionary<ObjectGuid, Channel> _channels = new Dictionary<ObjectGuid, Channel>();
Team _team;
ObjectGuidGenerator _guidGenerator;
static ChannelManager allianceChannelMgr = new ChannelManager(Team.Alliance);
static ChannelManager hordeChannelMgr = new ChannelManager(Team.Horde);