diff options
| author | Shauren <shauren.trinity@gmail.com> | 2019-10-26 11:17:33 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2019-10-27 00:12:41 +0200 |
| commit | ee2e49429f4383732b4e0f39b493470b9c1dd10c (patch) | |
| tree | 4204060b24b0469268971b8f1a45084eb0aee26b /src/server/game/Chat | |
| parent | 28eda522b1bef6d354d5a6b54fc0864ea503121a (diff) | |
Core/PacketIO: Update opcodes and packet structures to 8.2.5
Diffstat (limited to 'src/server/game/Chat')
| -rw-r--r-- | src/server/game/Chat/Channels/Channel.cpp | 7 | ||||
| -rw-r--r-- | src/server/game/Chat/Channels/Channel.h | 5 | ||||
| -rw-r--r-- | src/server/game/Chat/Channels/ChannelMgr.cpp | 67 | ||||
| -rw-r--r-- | src/server/game/Chat/Channels/ChannelMgr.h | 5 |
4 files changed, 55 insertions, 29 deletions
diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 781ffd0b2ea..3131f2b15d9 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -35,7 +35,7 @@ #include "WorldSession.h" #include <sstream> -Channel::Channel(uint32 channelId, uint32 team /*= 0*/, AreaTableEntry const* zoneEntry /*= nullptr*/) : +Channel::Channel(ObjectGuid const& guid, uint32 channelId, uint32 team /*= 0*/, AreaTableEntry const* zoneEntry /*= nullptr*/) : _announceEnabled(false), // no join/leave announces _ownershipEnabled(false), // no ownership handout _persistentChannel(false), @@ -43,6 +43,7 @@ Channel::Channel(uint32 channelId, uint32 team /*= 0*/, AreaTableEntry const* zo _channelFlags(CHANNEL_FLAG_GENERAL), // for all built-in channels _channelId(channelId), _channelTeam(team), + _channelGuid(guid), _zoneEntry(zoneEntry) { ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId); @@ -58,7 +59,7 @@ Channel::Channel(uint32 channelId, uint32 team /*= 0*/, AreaTableEntry const* zo _channelFlags |= CHANNEL_FLAG_NOT_LFG; } -Channel::Channel(std::string const& name, uint32 team /*= 0*/) : +Channel::Channel(ObjectGuid const& guid, std::string const& name, uint32 team /*= 0*/) : _announceEnabled(true), _ownershipEnabled(true), _persistentChannel(false), @@ -66,6 +67,7 @@ Channel::Channel(std::string const& name, uint32 team /*= 0*/) : _channelFlags(CHANNEL_FLAG_CUSTOM), _channelId(0), _channelTeam(team), + _channelGuid(guid), _channelName(name), _zoneEntry(nullptr) { @@ -251,6 +253,7 @@ void Channel::JoinChannel(Player* player, std::string const& pass) //notify->InstanceID = 0; notify->_ChannelFlags = _channelFlags; notify->_Channel = GetName(localeIdx); + notify->ChannelGUID = _channelGuid; return notify; }; diff --git a/src/server/game/Chat/Channels/Channel.h b/src/server/game/Chat/Channels/Channel.h index 3604958c20c..e94e18e51c4 100644 --- a/src/server/game/Chat/Channels/Channel.h +++ b/src/server/game/Chat/Channels/Channel.h @@ -172,8 +172,8 @@ class TC_GAME_API Channel }; public: - Channel(uint32 channelId, uint32 team = 0, AreaTableEntry const* zoneEntry = nullptr); // built-in channel ctor - Channel(std::string const& name, uint32 team = 0); // custom player channel ctor + Channel(ObjectGuid const& guid, uint32 channelId, uint32 team = 0, AreaTableEntry const* zoneEntry = nullptr); // built-in channel ctor + Channel(ObjectGuid const& guid, std::string const& name, uint32 team = 0); // custom player channel ctor static void GetChannelName(std::string& channelName, uint32 channelId, LocaleConstant locale, AreaTableEntry const* zoneEntry); std::string GetName(LocaleConstant locale = DEFAULT_LOCALE) const; @@ -269,6 +269,7 @@ class TC_GAME_API Channel uint8 _channelFlags; uint32 _channelId; uint32 _channelTeam; + ObjectGuid _channelGuid; ObjectGuid _ownerGuid; std::string _channelName; std::string _channelPassword; diff --git a/src/server/game/Chat/Channels/ChannelMgr.cpp b/src/server/game/Chat/Channels/ChannelMgr.cpp index 26db8fa5b98..ed84917602a 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.cpp +++ b/src/server/game/Chat/Channels/ChannelMgr.cpp @@ -21,6 +21,7 @@ #include "ChannelPackets.h" #include "DB2Stores.h" #include "Player.h" +#include "Realm.h" #include "World.h" #include "WorldSession.h" @@ -77,18 +78,13 @@ Channel* ChannelMgr::GetJoinChannel(uint32 channelId, std::string const& name, A { if (channelId) // builtin { - ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId); - uint32 zoneId = zoneEntry ? zoneEntry->ID : 0; - if (channelEntry->Flags & (CHANNEL_DBC_FLAG_GLOBAL | CHANNEL_DBC_FLAG_CITY_ONLY)) - zoneId = 0; - - std::pair<uint32, uint32> key = std::make_pair(channelId, zoneId); - auto itr = _channels.find(key); + ObjectGuid channelGuid = CreateBuiltinChannelGuid(channelId, zoneEntry); + auto itr = _channels.find(channelGuid); if (itr != _channels.end()) return itr->second; - 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 @@ -103,7 +99,7 @@ Channel* ChannelMgr::GetJoinChannel(uint32 channelId, std::string const& name, A if (itr != _customChannels.end()) return itr->second; - Channel* newChannel = new Channel(name, _team); + Channel* newChannel = new Channel(CreateCustomChannelGuid(), name, _team); _customChannels[channelName] = newChannel; return newChannel; } @@ -114,13 +110,7 @@ Channel* ChannelMgr::GetChannel(uint32 channelId, std::string const& name, Playe Channel* result = nullptr; if (channelId) // builtin { - ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId); - uint32 zoneId = zoneEntry ? zoneEntry->ID : 0; - if (channelEntry->Flags & (CHANNEL_DBC_FLAG_GLOBAL | CHANNEL_DBC_FLAG_CITY_ONLY)) - zoneId = 0; - - std::pair<uint32, uint32> key = std::make_pair(channelId, zoneId); - auto itr = _channels.find(key); + auto itr = _channels.find(CreateBuiltinChannelGuid(channelId, zoneEntry)); if (itr != _channels.end()) result = itr->second; } @@ -169,13 +159,7 @@ void ChannelMgr::LeftChannel(std::string const& name) void ChannelMgr::LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry) { - ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId); - uint32 zoneId = zoneEntry ? zoneEntry->ID : 0; - if (channelEntry->Flags & (CHANNEL_DBC_FLAG_GLOBAL | CHANNEL_DBC_FLAG_CITY_ONLY)) - zoneId = 0; - - std::pair<uint32, uint32> key = std::make_pair(channelId, zoneId); - auto itr = _channels.find(key); + auto itr = _channels.find(CreateBuiltinChannelGuid(channelId, zoneEntry)); if (itr == _channels.end()) return; @@ -194,3 +178,38 @@ void ChannelMgr::SendNotOnChannelNotify(Player const* player, std::string const& notify._Channel = name; player->SendDirectMessage(notify.Write()); } + +ObjectGuid ChannelMgr::CreateCustomChannelGuid() +{ + uint64 high = 0; + high |= uint64(HighGuid::ChatChannel) << 58; + high |= uint64(realm.Id.Realm) << 42; + high |= uint64(_team == ALLIANCE ? 3 : 5) << 4; + + ObjectGuid channelGuid; + channelGuid.SetRawValue(high, _guidGenerator.Generate()); + return channelGuid; +} + +ObjectGuid ChannelMgr::CreateBuiltinChannelGuid(uint32 channelId, AreaTableEntry const* zoneEntry /*= nullptr*/) const +{ + + ChatChannelsEntry const* channelEntry = sChatChannelsStore.AssertEntry(channelId); + uint32 zoneId = zoneEntry ? zoneEntry->ID : 0; + if (channelEntry->Flags & (CHANNEL_DBC_FLAG_GLOBAL | CHANNEL_DBC_FLAG_CITY_ONLY)) + zoneId = 0; + + uint64 high = 0; + high |= uint64(HighGuid::ChatChannel) << 58; + high |= uint64(realm.Id.Realm) << 42; + high |= uint64(1) << 25; // built-in + if (channelEntry->Flags & CHANNEL_DBC_FLAG_CITY_ONLY2) + high |= uint64(1) << 24; // trade + + high |= uint64(zoneId) << 10; + high |= uint64(_team == ALLIANCE ? 3 : 5) << 4; + + ObjectGuid channelGuid; + channelGuid.SetRawValue(high, channelId); + return channelGuid; +} diff --git a/src/server/game/Chat/Channels/ChannelMgr.h b/src/server/game/Chat/Channels/ChannelMgr.h index 09bed7da3b9..2f9907705b2 100644 --- a/src/server/game/Chat/Channels/ChannelMgr.h +++ b/src/server/game/Chat/Channels/ChannelMgr.h @@ -30,7 +30,7 @@ struct AreaTableEntry; class TC_GAME_API ChannelMgr { typedef std::unordered_map<std::wstring, Channel*> CustomChannelContainer; // custom channels only differ in name - typedef std::unordered_map<std::pair<uint32 /*channelId*/, uint32 /*zoneId*/>, Channel*> BuiltinChannelContainer; // identify builtin (DBC) channels by zoneId instead, since name changes by client locale + typedef std::unordered_map<ObjectGuid, Channel*> BuiltinChannelContainer; protected: explicit ChannelMgr(uint32 team) : _team(team) { } @@ -49,8 +49,11 @@ class TC_GAME_API ChannelMgr CustomChannelContainer _customChannels; BuiltinChannelContainer _channels; uint32 const _team; + ObjectGuidGenerator<HighGuid::ChatChannel> _guidGenerator; static void SendNotOnChannelNotify(Player const* player, std::string const& name); + ObjectGuid CreateCustomChannelGuid(); + ObjectGuid CreateBuiltinChannelGuid(uint32 channelId, AreaTableEntry const* zoneEntry = nullptr) const; }; #endif |
