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
This commit is contained in:
Aokromes committed 2016-10-22 10:21:18 +02:00
1 parent 3316e638d4
commit 7315052d34
11 files changed
+1102 -688

No files matched your search

+36 -7
View File
@@ -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);