diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2016-10-07 00:59:56 -0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-10-07 00:59:56 -0300 |
| commit | 66688a7855a8862666a39b9a958073aaa2489447 (patch) | |
| tree | e9efaffe69a0299dc596c254a669ab6d39674688 /src/server/scripts/Commands | |
| parent | ce45e1bf95a03be6b1f42c785e4c01dd55999d33 (diff) | |
Core/Channel: revamp channel system (#17980)
* Core/Channel: change the way channels are stored and sent to client.
- Fixes multiple channels per zone when using different locales
- Connected clients will receive locally the name of the channel for their apropiate locale (if available)
- In other cases default locale name will be sent, so as to prevent breaking channel chat for those players
Closes #8411
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_message.cpp | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index 69ff04ffb46..4b3caae686b 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -24,6 +24,7 @@ EndScriptData */ #include "ScriptMgr.h" #include "Chat.h" +#include "Channel.h" #include "ChannelMgr.h" #include "Language.h" #include "Player.h" @@ -63,21 +64,49 @@ public: if (!*args) return false; char const* channelStr = strtok((char*)args, " "); - char const* argStr = strtok(NULL, ""); + char const* argStr = strtok(nullptr, ""); if (!channelStr || !argStr) return false; + uint32 channelId = 0; + for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i) + { + ChatChannelsEntry const* entry = sChatChannelsStore.LookupEntry(i); + if (!entry) + continue; + + if (strstr(entry->pattern[handler->GetSessionDbcLocale()], channelStr)) + { + channelId = i; + break; + } + } + + AreaTableEntry const* zoneEntry = nullptr; + for (uint32 i = 0; i < sAreaTableStore.GetNumRows(); ++i) + { + AreaTableEntry const* entry = sAreaTableStore.LookupEntry(i); + if (!entry) + continue; + + if (strstr(entry->area_name[handler->GetSessionDbcLocale()], channelStr)) + { + zoneEntry = entry; + break; + } + } + Player* player = handler->GetSession()->GetPlayer(); - Channel* channcel = NULL; + Channel* channel = nullptr; if (ChannelMgr* cMgr = ChannelMgr::forTeam(player->GetTeam())) - channcel = cMgr->GetChannel(channelStr, player); + channel = cMgr->GetChannel(channelId, channelStr, player, false, zoneEntry); if (strcmp(argStr, "on") == 0) { - if (channcel) - channcel->SetOwnership(true); + if (channel) + channel->SetOwnership(true); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_OWNERSHIP); stmt->setUInt8 (0, 1); stmt->setString(1, channelStr); @@ -86,8 +115,8 @@ public: } else if (strcmp(argStr, "off") == 0) { - if (channcel) - channcel->SetOwnership(false); + if (channel) + channel->SetOwnership(false); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_UPD_CHANNEL_OWNERSHIP); stmt->setUInt8 (0, 0); stmt->setString(1, channelStr); |
