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:
1 parent
3316e638d4
commit
7315052d34
11 files changed
+1102
-688
No files matched your search
@@ -238,7 +238,7 @@ void CharacterDatabaseConnection::DoPrepareStatements()
|
||||
" ON DUPLICATE KEY UPDATE LogGuid = VALUES (LogGuid), EventType = VALUES (EventType), PlayerGuid = VALUES (PlayerGuid), Flags = VALUES (Flags), Value = VALUES (Value), Timestamp = VALUES (Timestamp)", CONNECTION_ASYNC);
|
||||
|
||||
// Chat channel handling
|
||||
PrepareStatement(CHAR_SEL_CHANNEL, "SELECT announce, ownership, password, bannedList FROM channels WHERE name = ? AND team = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_SEL_CHANNEL, "SELECT name, announce, ownership, password, bannedList FROM channels WHERE name = ? AND team = ?", CONNECTION_SYNCH);
|
||||
PrepareStatement(CHAR_INS_CHANNEL, "INSERT INTO channels(name, team, lastUsed) VALUES (?, ?, UNIX_TIMESTAMP())", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_CHANNEL, "UPDATE channels SET announce = ?, ownership = ?, password = ?, bannedList = ?, lastUsed = UNIX_TIMESTAMP() WHERE name = ? AND team = ?", CONNECTION_ASYNC);
|
||||
PrepareStatement(CHAR_UPD_CHANNEL_USAGE, "UPDATE channels SET lastUsed = UNIX_TIMESTAMP() WHERE name = ? AND team = ?", CONNECTION_ASYNC);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -150,9 +150,11 @@ class TC_GAME_API Channel
|
||||
};
|
||||
|
||||
public:
|
||||
Channel(std::string const& name, uint32 channel_id, uint32 team = 0);
|
||||
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
|
||||
|
||||
std::string const& GetName() const { return _channelName; }
|
||||
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
|
||||
|
||||
uint32 GetChannelId() const { return _channelId; }
|
||||
bool IsConstant() const { return _channelId != 0; }
|
||||
@@ -170,6 +172,8 @@ class TC_GAME_API Channel
|
||||
uint8 GetFlags() const { return _channelFlags; }
|
||||
bool HasFlag(uint8 flag) const { return (_channelFlags & flag) != 0; }
|
||||
|
||||
AreaTableEntry const* GetZoneEntry() const { return _zoneEntry; }
|
||||
|
||||
void JoinChannel(Player* player, std::string const& pass);
|
||||
void LeaveChannel(Player* player, bool send = true);
|
||||
|
||||
@@ -204,47 +208,15 @@ class TC_GAME_API Channel
|
||||
static void CleanOldChannelsInDB();
|
||||
|
||||
private:
|
||||
// initial packet data (notify type and channel name)
|
||||
void MakeNotifyPacket(WorldPacket* data, uint8 notify_type) const;
|
||||
// type specific packet data
|
||||
void MakeJoined(WorldPacket* data, ObjectGuid guid) const; //+ 0x00
|
||||
void MakeLeft(WorldPacket* data, ObjectGuid guid) const; //+ 0x01
|
||||
void MakeYouJoined(WorldPacket* data) const; //+ 0x02
|
||||
void MakeYouLeft(WorldPacket* data) const; //+ 0x03
|
||||
void MakeWrongPassword(WorldPacket* data) const; //? 0x04
|
||||
void MakeNotMember(WorldPacket* data) const; //? 0x05
|
||||
void MakeNotModerator(WorldPacket* data) const; //? 0x06
|
||||
void MakePasswordChanged(WorldPacket* data, ObjectGuid guid) const; //+ 0x07
|
||||
void MakeOwnerChanged(WorldPacket* data, ObjectGuid guid) const; //? 0x08
|
||||
void MakePlayerNotFound(WorldPacket* data, std::string const& name) const; //+ 0x09
|
||||
void MakeNotOwner(WorldPacket* data) const; //? 0x0A
|
||||
void MakeChannelOwner(WorldPacket* data) const; //? 0x0B
|
||||
void MakeModeChange(WorldPacket* data, ObjectGuid guid, uint8 oldflags) const; //+ 0x0C
|
||||
void MakeAnnouncementsOn(WorldPacket* data, ObjectGuid guid) const; //+ 0x0D
|
||||
void MakeAnnouncementsOff(WorldPacket* data, ObjectGuid guid) const; //+ 0x0E
|
||||
void MakeMuted(WorldPacket* data) const; //? 0x11
|
||||
void MakePlayerKicked(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const; //? 0x12
|
||||
void MakeBanned(WorldPacket* data) const; //? 0x13
|
||||
void MakePlayerBanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const; //? 0x14
|
||||
void MakePlayerUnbanned(WorldPacket* data, ObjectGuid bad, ObjectGuid good) const; //? 0x15
|
||||
void MakePlayerNotBanned(WorldPacket* data, std::string const& name) const; //? 0x16
|
||||
void MakePlayerAlreadyMember(WorldPacket* data, ObjectGuid guid) const; //+ 0x17
|
||||
void MakeInvite(WorldPacket* data, ObjectGuid guid) const; //? 0x18
|
||||
void MakeInviteWrongFaction(WorldPacket* data) const; //? 0x19
|
||||
void MakeWrongFaction(WorldPacket* data) const; //? 0x1A
|
||||
void MakeInvalidName(WorldPacket* data) const; //? 0x1B
|
||||
void MakeNotModerated(WorldPacket* data) const; //? 0x1C
|
||||
void MakePlayerInvited(WorldPacket* data, std::string const& name) const; //+ 0x1D
|
||||
void MakePlayerInviteBanned(WorldPacket* data, std::string const& name) const; //? 0x1E
|
||||
void MakeThrottled(WorldPacket* data) const; //? 0x1F
|
||||
void MakeNotInArea(WorldPacket* data) const; //? 0x20
|
||||
void MakeNotInLfg(WorldPacket* data) const; //? 0x21
|
||||
void MakeVoiceOn(WorldPacket* data, ObjectGuid guid) const; //+ 0x22
|
||||
void MakeVoiceOff(WorldPacket* data, ObjectGuid guid) const; //+ 0x23
|
||||
|
||||
void SendToAll(WorldPacket* data, ObjectGuid guid = ObjectGuid::Empty) const;
|
||||
void SendToAllButOne(WorldPacket* data, ObjectGuid who) const;
|
||||
void SendToOne(WorldPacket* data, ObjectGuid who) const;
|
||||
template<class Builder>
|
||||
void SendToAll(Builder&, ObjectGuid guid = ObjectGuid::Empty) const;
|
||||
|
||||
template<class Builder>
|
||||
void SendToAllButOne(Builder& builder, ObjectGuid who) const;
|
||||
|
||||
template<class Builder>
|
||||
void SendToOne(Builder& builder, ObjectGuid who) const;
|
||||
|
||||
bool IsOn(ObjectGuid who) const { return _playersStore.count(who) != 0; }
|
||||
bool IsBanned(ObjectGuid guid) const { return _bannedStore.count(guid) != 0; }
|
||||
@@ -258,39 +230,8 @@ class TC_GAME_API Channel
|
||||
return itr != _playersStore.end() ? itr->second.flags : 0;
|
||||
}
|
||||
|
||||
void SetModerator(ObjectGuid guid, bool set)
|
||||
{
|
||||
if (!IsOn(guid))
|
||||
return;
|
||||
|
||||
PlayerInfo& playerInfo = _playersStore.at(guid);
|
||||
if (playerInfo.IsModerator() != set)
|
||||
{
|
||||
uint8 oldFlag = GetPlayerFlags(guid);
|
||||
playerInfo.SetModerator(set);
|
||||
|
||||
WorldPacket data;
|
||||
MakeModeChange(&data, guid, oldFlag);
|
||||
SendToAll(&data);
|
||||
}
|
||||
}
|
||||
|
||||
void SetMute(ObjectGuid guid, bool set)
|
||||
{
|
||||
if (!IsOn(guid))
|
||||
return;
|
||||
|
||||
PlayerInfo& playerInfo = _playersStore.at(guid);
|
||||
if (playerInfo.IsMuted() != set)
|
||||
{
|
||||
uint8 oldFlag = GetPlayerFlags(guid);
|
||||
playerInfo.SetMuted(set);
|
||||
|
||||
WorldPacket data;
|
||||
MakeModeChange(&data, guid, oldFlag);
|
||||
SendToAll(&data);
|
||||
}
|
||||
}
|
||||
void SetModerator(ObjectGuid guid, bool set);
|
||||
void SetMute(ObjectGuid guid, bool set);
|
||||
|
||||
typedef std::map<ObjectGuid, PlayerInfo> PlayerContainer;
|
||||
typedef GuidUnorderedSet BannedContainer;
|
||||
@@ -308,6 +249,8 @@ class TC_GAME_API Channel
|
||||
std::string _channelPassword;
|
||||
PlayerContainer _playersStore;
|
||||
BannedContainer _bannedStore;
|
||||
|
||||
AreaTableEntry const* _zoneEntry;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,476 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _CHANNELAPPENDERS_H
|
||||
#define _CHANNELAPPENDERS_H
|
||||
|
||||
#include "Channel.h"
|
||||
|
||||
// initial packet data (notify type and channel name)
|
||||
template<class PacketModifier>
|
||||
class ChannelNameBuilder
|
||||
{
|
||||
public:
|
||||
ChannelNameBuilder(Channel const* source, PacketModifier const& modifier)
|
||||
: _source(source), _modifier(modifier){ }
|
||||
|
||||
void operator()(WorldPacket& data, LocaleConstant locale) const
|
||||
{
|
||||
// LocalizedPacketDo sends client DBC locale, we need to get available to server locale
|
||||
LocaleConstant localeIdx = sWorld->GetAvailableDbcLocale(locale);
|
||||
|
||||
data.Initialize(SMSG_CHANNEL_NOTIFY, 60); // guess size
|
||||
data << uint8(_modifier.NotificationType);
|
||||
data << _source->GetName(localeIdx);
|
||||
_modifier.Append(data);
|
||||
}
|
||||
|
||||
private:
|
||||
Channel const* _source;
|
||||
PacketModifier _modifier;
|
||||
};
|
||||
|
||||
struct JoinedAppend
|
||||
{
|
||||
explicit JoinedAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_JOINED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct LeftAppend
|
||||
{
|
||||
explicit LeftAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_LEFT_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct YouJoinedAppend
|
||||
{
|
||||
explicit YouJoinedAppend(Channel const* channel) : _channel(channel) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_YOU_JOINED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint8(_channel->GetFlags());
|
||||
data << uint32(_channel->GetChannelId());
|
||||
data << uint32(0);
|
||||
}
|
||||
|
||||
private:
|
||||
Channel const* _channel;
|
||||
};
|
||||
|
||||
struct YouLeftAppend
|
||||
{
|
||||
explicit YouLeftAppend(Channel const* channel) : _channel(channel) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_YOU_LEFT_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint32(_channel->GetChannelId());
|
||||
data << uint8(_channel->IsConstant());
|
||||
}
|
||||
|
||||
private:
|
||||
Channel const* _channel;
|
||||
};
|
||||
|
||||
struct WrongPasswordAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_WRONG_PASSWORD_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct NotMemberAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_NOT_MEMBER_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct NotModeratorAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_NOT_MODERATOR_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct PasswordChangedAppend
|
||||
{
|
||||
explicit PasswordChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PASSWORD_CHANGED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct OwnerChangedAppend
|
||||
{
|
||||
explicit OwnerChangedAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_OWNER_CHANGED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct PlayerNotFoundAppend
|
||||
{
|
||||
explicit PlayerNotFoundAppend(std::string const& playerName) : _playerName(playerName) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_NOT_FOUND_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << _playerName;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _playerName;
|
||||
};
|
||||
|
||||
struct NotOwnerAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_NOT_OWNER_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct ChannelOwnerAppend
|
||||
{
|
||||
explicit ChannelOwnerAppend(Channel const* channel, ObjectGuid const& ownerGuid) : _channel(channel), _ownerGuid(ownerGuid)
|
||||
{
|
||||
CharacterInfo const* cInfo = sWorld->GetCharacterInfo(_ownerGuid);
|
||||
if (!cInfo || cInfo->Name.empty())
|
||||
_ownerName = "PLAYER_NOT_FOUND";
|
||||
else
|
||||
_ownerName = cInfo->Name;
|
||||
}
|
||||
|
||||
static uint8 const NotificationType = CHAT_CHANNEL_OWNER_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << ((_channel->IsConstant() || !_ownerGuid) ? "Nobody" : _ownerName);
|
||||
}
|
||||
|
||||
private:
|
||||
Channel const* _channel;
|
||||
ObjectGuid _ownerGuid;
|
||||
|
||||
std::string _ownerName;
|
||||
};
|
||||
|
||||
struct ModeChangeAppend
|
||||
{
|
||||
explicit ModeChangeAppend(ObjectGuid const& guid, uint8 oldFlags, uint8 newFlags) : _guid(guid), _oldFlags(oldFlags), _newFlags(newFlags) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_MODE_CHANGE_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
data << uint8(_oldFlags);
|
||||
data << uint8(_newFlags);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
uint8 _oldFlags;
|
||||
uint8 _newFlags;
|
||||
};
|
||||
|
||||
struct AnnouncementsOnAppend
|
||||
{
|
||||
explicit AnnouncementsOnAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_ANNOUNCEMENTS_ON_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct AnnouncementsOffAppend
|
||||
{
|
||||
explicit AnnouncementsOffAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_ANNOUNCEMENTS_OFF_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct MutedAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_MUTED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct PlayerKickedAppend
|
||||
{
|
||||
explicit PlayerKickedAppend(ObjectGuid const& kicker, ObjectGuid const& kickee) : _kicker(kicker), _kickee(kickee) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_KICKED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_kickee);
|
||||
data << uint64(_kicker);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _kicker;
|
||||
ObjectGuid _kickee;
|
||||
};
|
||||
|
||||
struct BannedAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_BANNED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct PlayerBannedAppend
|
||||
{
|
||||
explicit PlayerBannedAppend(ObjectGuid const& moderator, ObjectGuid const& banned) : _moderator(moderator), _banned(banned) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_BANNED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_banned);
|
||||
data << uint64(_moderator);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _moderator;
|
||||
ObjectGuid _banned;
|
||||
};
|
||||
|
||||
struct PlayerUnbannedAppend
|
||||
{
|
||||
explicit PlayerUnbannedAppend(ObjectGuid const& moderator, ObjectGuid const& unbanned) : _moderator(moderator), _unbanned(unbanned) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_UNBANNED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_unbanned);
|
||||
data << uint64(_moderator);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _moderator;
|
||||
ObjectGuid _unbanned;
|
||||
};
|
||||
|
||||
struct PlayerNotBannedAppend
|
||||
{
|
||||
explicit PlayerNotBannedAppend(std::string const& playerName) : _playerName(playerName) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_NOT_BANNED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << _playerName;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _playerName;
|
||||
};
|
||||
|
||||
struct PlayerAlreadyMemberAppend
|
||||
{
|
||||
explicit PlayerAlreadyMemberAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_ALREADY_MEMBER_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct InviteAppend
|
||||
{
|
||||
explicit InviteAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_INVITE_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct InviteWrongFactionAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_INVITE_WRONG_FACTION_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct WrongFactionAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_WRONG_FACTION_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct InvalidNameAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_INVALID_NAME_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct NotModeratedAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_NOT_MODERATED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct PlayerInvitedAppend
|
||||
{
|
||||
explicit PlayerInvitedAppend(std::string const& playerName) : _playerName(playerName) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_INVITED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << _playerName;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _playerName;
|
||||
};
|
||||
|
||||
struct PlayerInviteBannedAppend
|
||||
{
|
||||
explicit PlayerInviteBannedAppend(std::string const& playerName) : _playerName(playerName) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_PLAYER_INVITE_BANNED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << _playerName;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _playerName;
|
||||
};
|
||||
|
||||
struct ThrottledAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_THROTTLED_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct NotInAreaAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_NOT_IN_AREA_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct NotInLFGAppend
|
||||
{
|
||||
static uint8 const NotificationType = CHAT_NOT_IN_LFG_NOTICE;
|
||||
|
||||
void Append(WorldPacket& /*data*/) const { }
|
||||
};
|
||||
|
||||
struct VoiceOnAppend
|
||||
{
|
||||
explicit VoiceOnAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_VOICE_ON_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
struct VoiceOffAppend
|
||||
{
|
||||
explicit VoiceOffAppend(ObjectGuid const& guid) : _guid(guid) { }
|
||||
|
||||
static uint8 const NotificationType = CHAT_VOICE_OFF_NOTICE;
|
||||
|
||||
void Append(WorldPacket& data) const
|
||||
{
|
||||
data << uint64(_guid);
|
||||
}
|
||||
|
||||
private:
|
||||
ObjectGuid _guid;
|
||||
};
|
||||
|
||||
#endif // _CHANNELAPPENDERS_H
|
||||
@@ -16,6 +16,7 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Channel.h"
|
||||
#include "ChannelMgr.h"
|
||||
#include "Player.h"
|
||||
#include "World.h"
|
||||
@@ -23,14 +24,18 @@
|
||||
|
||||
ChannelMgr::~ChannelMgr()
|
||||
{
|
||||
for (ChannelMap::iterator itr = channels.begin(); itr != channels.end(); ++itr)
|
||||
for (auto itr = _channels.begin(); itr != _channels.end(); ++itr)
|
||||
delete itr->second;
|
||||
|
||||
for (auto itr = _customChannels.begin(); itr != _customChannels.end(); ++itr)
|
||||
delete itr->second;
|
||||
}
|
||||
|
||||
ChannelMgr* ChannelMgr::forTeam(uint32 team)
|
||||
{
|
||||
static ChannelMgr allianceChannelMgr;
|
||||
static ChannelMgr hordeChannelMgr;
|
||||
static ChannelMgr allianceChannelMgr(ALLIANCE);
|
||||
static ChannelMgr hordeChannelMgr(HORDE);
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_CHANNEL))
|
||||
return &allianceChannelMgr; // cross-faction
|
||||
|
||||
@@ -43,69 +48,148 @@ ChannelMgr* ChannelMgr::forTeam(uint32 team)
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Channel* ChannelMgr::GetJoinChannel(std::string const& name, uint32 channelId)
|
||||
Channel* ChannelMgr::GetChannelForPlayerByNamePart(std::string const& namePart, Player* playerSearcher)
|
||||
{
|
||||
std::wstring wname;
|
||||
if (!Utf8toWStr(name, wname))
|
||||
std::wstring channelNamePart;
|
||||
if (!Utf8toWStr(namePart, channelNamePart))
|
||||
return nullptr;
|
||||
|
||||
wstrToLower(wname);
|
||||
|
||||
ChannelMap::const_iterator i = channels.find(wname);
|
||||
|
||||
if (i == channels.end())
|
||||
wstrToLower(channelNamePart);
|
||||
for (Channel* channel : playerSearcher->GetJoinedChannels())
|
||||
{
|
||||
Channel* nchan = new Channel(name, channelId, team);
|
||||
channels[wname] = nchan;
|
||||
return nchan;
|
||||
std::string chanName = channel->GetName(playerSearcher->GetSession()->GetSessionDbcLocale());
|
||||
|
||||
std::wstring channelNameW;
|
||||
if (!Utf8toWStr(chanName, channelNameW))
|
||||
continue;
|
||||
|
||||
wstrToLower(channelNameW);
|
||||
if (!channelNameW.compare(0, channelNamePart.size(), channelNamePart))
|
||||
return channel;
|
||||
}
|
||||
|
||||
return i->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Channel* ChannelMgr::GetChannel(std::string const& name, Player* player, bool pkt)
|
||||
Channel* ChannelMgr::GetJoinChannel(uint32 channelId, std::string const& name, AreaTableEntry const* zoneEntry /*= nullptr*/)
|
||||
{
|
||||
std::wstring wname;
|
||||
if (!Utf8toWStr(name, wname))
|
||||
return nullptr;
|
||||
|
||||
wstrToLower(wname);
|
||||
|
||||
ChannelMap::const_iterator i = channels.find(wname);
|
||||
|
||||
if (i == channels.end())
|
||||
if (channelId) // builtin
|
||||
{
|
||||
if (pkt)
|
||||
{
|
||||
WorldPacket data;
|
||||
MakeNotOnPacket(&data, name);
|
||||
player->GetSession()->SendPacket(&data);
|
||||
}
|
||||
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;
|
||||
|
||||
return nullptr;
|
||||
std::pair<uint32, uint32> key = std::make_pair(channelId, zoneId);
|
||||
|
||||
auto itr = _channels.find(key);
|
||||
if (itr != _channels.end())
|
||||
return itr->second;
|
||||
|
||||
Channel* newChannel = new Channel(channelId, _team, zoneEntry);
|
||||
_channels[key] = newChannel;
|
||||
return newChannel;
|
||||
}
|
||||
else // custom
|
||||
{
|
||||
std::wstring channelName;
|
||||
if (!Utf8toWStr(name, channelName))
|
||||
return nullptr;
|
||||
|
||||
wstrToLower(channelName);
|
||||
auto itr = _customChannels.find(channelName);
|
||||
if (itr != _customChannels.end())
|
||||
return itr->second;
|
||||
|
||||
Channel* newChannel = new Channel(name, _team);
|
||||
_customChannels[channelName] = newChannel;
|
||||
return newChannel;
|
||||
}
|
||||
}
|
||||
|
||||
Channel* ChannelMgr::GetChannel(uint32 channelId, std::string const& name, Player* player, bool pkt /*= true*/, AreaTableEntry const* zoneEntry /*= nullptr*/) const
|
||||
{
|
||||
Channel* ret = nullptr;
|
||||
bool send = false;
|
||||
|
||||
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);
|
||||
if (itr != _channels.end())
|
||||
ret = itr->second;
|
||||
else
|
||||
send = true;
|
||||
}
|
||||
else // custom
|
||||
{
|
||||
std::wstring channelName;
|
||||
if (!Utf8toWStr(name, channelName))
|
||||
return nullptr;
|
||||
|
||||
wstrToLower(channelName);
|
||||
auto itr = _customChannels.find(channelName);
|
||||
if (itr != _customChannels.end())
|
||||
ret = itr->second;
|
||||
else
|
||||
send = true;
|
||||
}
|
||||
|
||||
return i->second;
|
||||
if (send && pkt)
|
||||
{
|
||||
std::string channelName = name;
|
||||
Channel::GetChannelName(channelName, channelId, player->GetSession()->GetSessionDbcLocale(), zoneEntry);
|
||||
|
||||
WorldPacket data;
|
||||
ChannelMgr::MakeNotOnPacket(&data, channelName);
|
||||
player->SendDirectMessage(&data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ChannelMgr::LeftChannel(std::string const& name)
|
||||
{
|
||||
std::wstring wname;
|
||||
if (!Utf8toWStr(name, wname))
|
||||
std::wstring channelName;
|
||||
if (!Utf8toWStr(name, channelName))
|
||||
return;
|
||||
|
||||
wstrToLower(wname);
|
||||
|
||||
ChannelMap::const_iterator i = channels.find(wname);
|
||||
|
||||
if (i == channels.end())
|
||||
wstrToLower(channelName);
|
||||
auto itr = _customChannels.find(channelName);
|
||||
if (itr == _customChannels.end())
|
||||
return;
|
||||
|
||||
Channel* channel = i->second;
|
||||
|
||||
if (!channel->GetNumPlayers() && !channel->IsConstant())
|
||||
Channel* channel = itr->second;
|
||||
if (!channel->GetNumPlayers())
|
||||
{
|
||||
channels.erase(wname);
|
||||
_customChannels.erase(itr);
|
||||
delete channel;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == _channels.end())
|
||||
return;
|
||||
|
||||
Channel* channel = itr->second;
|
||||
if (!channel->GetNumPlayers())
|
||||
{
|
||||
_channels.erase(itr);
|
||||
delete channel;
|
||||
}
|
||||
}
|
||||
@@ -113,5 +197,5 @@ void ChannelMgr::LeftChannel(std::string const& name)
|
||||
void ChannelMgr::MakeNotOnPacket(WorldPacket* data, std::string const& name)
|
||||
{
|
||||
data->Initialize(SMSG_CHANNEL_NOTIFY, 1 + name.size());
|
||||
(*data) << uint8(5) << name;
|
||||
(*data) << uint8(CHAT_NOT_MEMBER_NOTICE) << name;
|
||||
}
|
||||
@@ -19,36 +19,34 @@
|
||||
#define __TRINITY_CHANNELMGR_H
|
||||
|
||||
#include "Common.h"
|
||||
#include "Channel.h"
|
||||
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "World.h"
|
||||
|
||||
#define MAX_CHANNEL_PASS_STR 31
|
||||
class Channel;
|
||||
|
||||
class TC_GAME_API ChannelMgr
|
||||
{
|
||||
typedef std::map<std::wstring, Channel*> ChannelMap;
|
||||
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
|
||||
|
||||
protected:
|
||||
ChannelMgr() : team(0) { }
|
||||
explicit ChannelMgr(uint32 team) : _team(team) { }
|
||||
~ChannelMgr();
|
||||
|
||||
public:
|
||||
static ChannelMgr* forTeam(uint32 team);
|
||||
void setTeam(uint32 newTeam) { team = newTeam; }
|
||||
static Channel* GetChannelForPlayerByNamePart(std::string const& namePart, Player* playerSearcher);
|
||||
|
||||
Channel* GetJoinChannel(std::string const& name, uint32 channel_id);
|
||||
Channel* GetChannel(std::string const& name, Player* p, bool pkt = true);
|
||||
Channel* GetJoinChannel(uint32 channelId, std::string const& name, AreaTableEntry const* zoneEntry = nullptr);
|
||||
Channel* GetChannel(uint32 channelId, std::string const& name, Player* player, bool pkt = true, AreaTableEntry const* zoneEntry = nullptr) const;
|
||||
void LeftChannel(std::string const& name);
|
||||
void LeftChannel(uint32 channelId, AreaTableEntry const* zoneEntry);
|
||||
|
||||
private:
|
||||
ChannelMap channels;
|
||||
uint32 team;
|
||||
CustomChannelContainer _customChannels;
|
||||
BuiltinChannelContainer _channels;
|
||||
uint32 const _team;
|
||||
|
||||
void MakeNotOnPacket(WorldPacket* data, std::string const& name);
|
||||
static void MakeNotOnPacket(WorldPacket* data, std::string const& name);
|
||||
ChannelMgr() = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -5194,8 +5194,15 @@ void Player::CleanupChannels()
|
||||
Channel* ch = *m_channels.begin();
|
||||
m_channels.erase(m_channels.begin()); // remove from player's channel list
|
||||
ch->LeaveChannel(this, false); // not send to client, not remove from player's channel list
|
||||
|
||||
// delete channel if empty
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetTeam()))
|
||||
cMgr->LeftChannel(ch->GetName()); // deleted channel if empty
|
||||
{
|
||||
if (ch->IsConstant())
|
||||
cMgr->LeftChannel(ch->GetChannelId(), ch->GetZoneEntry());
|
||||
else
|
||||
cMgr->LeftChannel(ch->GetName());
|
||||
}
|
||||
}
|
||||
TC_LOG_DEBUG("chat.system", "Player::CleanupChannels: Channels of player '%s' (%s) cleaned up.", GetName().c_str(), GetGUID().ToString().c_str());
|
||||
}
|
||||
@@ -5213,7 +5220,6 @@ void Player::UpdateLocalChannels(uint32 newZone)
|
||||
if (!cMgr)
|
||||
return;
|
||||
|
||||
std::string current_zone_name = current_zone->area_name;
|
||||
for (uint32 i = 0; i < sChatChannelsStore.GetNumRows(); ++i)
|
||||
{
|
||||
ChatChannelsEntry const* channelEntry = sChatChannelsStore.LookupEntry(i);
|
||||
@@ -5241,14 +5247,7 @@ void Player::UpdateLocalChannels(uint32 newZone)
|
||||
if (channelEntry->flags & CHANNEL_DBC_FLAG_CITY_ONLY && usedChannel)
|
||||
continue; // Already on the channel, as city channel names are not changing
|
||||
|
||||
std::string currentNameExt;
|
||||
if (channelEntry->flags & CHANNEL_DBC_FLAG_CITY_ONLY)
|
||||
currentNameExt = sObjectMgr->GetTrinityStringForDBCLocale(LANG_CHANNEL_CITY);
|
||||
else
|
||||
currentNameExt = current_zone_name;
|
||||
|
||||
std::string newChannelName = Trinity::StringFormat(channelEntry->pattern, currentNameExt.c_str());
|
||||
joinChannel = cMgr->GetJoinChannel(newChannelName, channelEntry->ChannelID);
|
||||
joinChannel = cMgr->GetJoinChannel(channelEntry->ChannelID, std::string(), current_zone);
|
||||
if (usedChannel)
|
||||
{
|
||||
if (joinChannel != usedChannel)
|
||||
@@ -5261,7 +5260,7 @@ void Player::UpdateLocalChannels(uint32 newZone)
|
||||
}
|
||||
}
|
||||
else
|
||||
joinChannel = cMgr->GetJoinChannel(channelEntry->pattern, channelEntry->ChannelID);
|
||||
joinChannel = cMgr->GetJoinChannel(channelEntry->ChannelID, std::string());
|
||||
}
|
||||
else
|
||||
removeChannel = usedChannel;
|
||||
@@ -5271,10 +5270,10 @@ void Player::UpdateLocalChannels(uint32 newZone)
|
||||
|
||||
if (removeChannel)
|
||||
{
|
||||
removeChannel->LeaveChannel(this, sendRemove); // Leave old channel
|
||||
std::string name = removeChannel->GetName(); // Store name, (*i)erase in LeftChannel
|
||||
LeftChannel(removeChannel); // Remove from player's channel list
|
||||
cMgr->LeftChannel(name); // Delete if empty
|
||||
removeChannel->LeaveChannel(this, sendRemove); // Leave old channel
|
||||
|
||||
LeftChannel(removeChannel); // Remove from player's channel list
|
||||
cMgr->LeftChannel(removeChannel->GetChannelId(), removeChannel->GetZoneEntry()); // Delete if empty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2070,6 +2070,9 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
void UpdateLocalChannels(uint32 newZone);
|
||||
void LeaveLFGChannel();
|
||||
|
||||
typedef std::list<Channel*> JoinedChannelsList;
|
||||
JoinedChannelsList const& GetJoinedChannels() const { return m_channels; }
|
||||
|
||||
void SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal);
|
||||
uint16 GetMaxSkillValue(uint32 skill) const; // max + perm. bonus + temp bonus
|
||||
uint16 GetPureMaxSkillValue(uint32 skill) const; // max
|
||||
@@ -2720,7 +2723,6 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
ResurrectionData* _resurrectionData;
|
||||
WorldSession* m_session;
|
||||
|
||||
typedef std::list<Channel*> JoinedChannelsList;
|
||||
JoinedChannelsList m_channels;
|
||||
|
||||
uint8 m_cinematic;
|
||||
|
||||
@@ -17,12 +17,15 @@
|
||||
*/
|
||||
|
||||
#include "ObjectMgr.h" // for normalizePlayerName
|
||||
#include "Channel.h"
|
||||
#include "ChannelMgr.h"
|
||||
#include "Player.h"
|
||||
#include "WorldSession.h"
|
||||
|
||||
#include <cctype>
|
||||
|
||||
static size_t const MAX_CHANNEL_PASS_STR = 31;
|
||||
|
||||
void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
|
||||
{
|
||||
uint32 channelId;
|
||||
@@ -40,13 +43,13 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
|
||||
TC_LOG_DEBUG("chat.system", "CMSG_JOIN_CHANNEL %s Channel: %u, unk1: %u, unk2: %u, channel: %s, password: %s",
|
||||
GetPlayerInfo().c_str(), channelId, unknown1, unknown2, channelName.c_str(), password.c_str());
|
||||
|
||||
AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetPlayer()->GetZoneId());
|
||||
if (channelId)
|
||||
{
|
||||
ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(channelId);
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetPlayer()->GetZoneId());
|
||||
if (!zone || !GetPlayer()->CanJoinConstantChannelInZone(channel, zone))
|
||||
return;
|
||||
}
|
||||
@@ -58,32 +61,44 @@ void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
{
|
||||
cMgr->setTeam(GetPlayer()->GetTeam());
|
||||
if (Channel* channel = cMgr->GetJoinChannel(channelName, channelId))
|
||||
if (Channel* channel = cMgr->GetJoinChannel(channelId, channelName, zone))
|
||||
channel->JoinChannel(GetPlayer(), password);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
|
||||
{
|
||||
uint32 unk;
|
||||
uint32 channelId;
|
||||
std::string channelName;
|
||||
recvPacket >> unk; // channel id?
|
||||
recvPacket >> channelId;
|
||||
uint32 length = recvPacket.ReadBits(8);
|
||||
channelName = recvPacket.ReadString(length);
|
||||
|
||||
TC_LOG_DEBUG("chat.system", "CMSG_LEAVE_CHANNEL %s Channel: %s, unk1: %u",
|
||||
GetPlayerInfo().c_str(), channelName.c_str(), unk);
|
||||
TC_LOG_DEBUG("chat.system", "CMSG_LEAVE_CHANNEL %s Channel: %s, channelId: %u",
|
||||
GetPlayerInfo().c_str(), channelName.c_str(), channelId);
|
||||
|
||||
if (channelName.empty())
|
||||
if (channelName.empty() && !channelId)
|
||||
return;
|
||||
|
||||
AreaTableEntry const* zone = sAreaTableStore.LookupEntry(GetPlayer()->GetZoneId());
|
||||
if (channelId)
|
||||
{
|
||||
ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(channelId);
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
if (!zone || !GetPlayer()->CanJoinConstantChannelInZone(channel, zone))
|
||||
return;
|
||||
}
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
{
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelId, channelName, GetPlayer(), true, zone))
|
||||
channel->LeaveChannel(GetPlayer(), true);
|
||||
cMgr->LeftChannel(channelName);
|
||||
|
||||
if (channelId)
|
||||
cMgr->LeftChannel(channelId, zone);
|
||||
else
|
||||
cMgr->LeftChannel(channelName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +111,8 @@ void WorldSession::HandleChannelList(WorldPacket& recvPacket)
|
||||
recvPacket.GetOpcode() == CMSG_CHANNEL_DISPLAY_LIST ? "CMSG_CHANNEL_DISPLAY_LIST" : "CMSG_CHANNEL_LIST",
|
||||
GetPlayerInfo().c_str(), channelName.c_str());
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->List(GetPlayer());
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->List(GetPlayer());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelPassword(WorldPacket& recvPacket)
|
||||
@@ -115,9 +129,8 @@ void WorldSession::HandleChannelPassword(WorldPacket& recvPacket)
|
||||
if (password.length() > MAX_CHANNEL_PASS_STR)
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->Password(GetPlayer(), password);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->Password(GetPlayer(), password);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket)
|
||||
@@ -134,9 +147,8 @@ void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->SetOwner(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->SetOwner(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelOwner(WorldPacket& recvPacket)
|
||||
@@ -147,9 +159,8 @@ void WorldSession::HandleChannelOwner(WorldPacket& recvPacket)
|
||||
TC_LOG_DEBUG("chat.system", "CMSG_CHANNEL_OWNER %s Channel: %s",
|
||||
GetPlayerInfo().c_str(), channelName.c_str());
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->SendWhoOwner(GetPlayer()->GetGUID());
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->SendWhoOwner(GetPlayer()->GetGUID());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelModerator(WorldPacket& recvPacket)
|
||||
@@ -166,9 +177,8 @@ void WorldSession::HandleChannelModerator(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->SetModerator(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->SetModerator(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket)
|
||||
@@ -185,9 +195,8 @@ void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->UnsetModerator(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->UnsetModerator(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelMute(WorldPacket& recvPacket)
|
||||
@@ -204,9 +213,8 @@ void WorldSession::HandleChannelMute(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->SetMute(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->SetMute(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket)
|
||||
@@ -223,9 +231,8 @@ void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->UnsetMute(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->UnsetMute(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelInvite(WorldPacket& recvPacket)
|
||||
@@ -242,9 +249,8 @@ void WorldSession::HandleChannelInvite(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->Invite(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->Invite(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelKick(WorldPacket& recvPacket)
|
||||
@@ -261,9 +267,8 @@ void WorldSession::HandleChannelKick(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->Kick(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->Kick(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelBan(WorldPacket& recvPacket)
|
||||
@@ -283,9 +288,8 @@ void WorldSession::HandleChannelBan(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->Ban(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->Ban(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelUnban(WorldPacket& recvPacket)
|
||||
@@ -302,9 +306,8 @@ void WorldSession::HandleChannelUnban(WorldPacket& recvPacket)
|
||||
if (!normalizePlayerName(targetName))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->UnBan(GetPlayer(), targetName);
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->UnBan(GetPlayer(), targetName);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket)
|
||||
@@ -315,9 +318,8 @@ void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket)
|
||||
TC_LOG_DEBUG("chat.system", "CMSG_CHANNEL_ANNOUNCEMENTS %s Channel: %s",
|
||||
GetPlayerInfo().c_str(), channelName.c_str());
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->Announce(GetPlayer());
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->Announce(GetPlayer());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket)
|
||||
@@ -334,19 +336,17 @@ void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket)
|
||||
TC_LOG_DEBUG("chat.system", "CMSG_GET_CHANNEL_MEMBER_COUNT %s Channel: %s",
|
||||
GetPlayerInfo().c_str(), channelName.c_str());
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
{
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
{
|
||||
TC_LOG_DEBUG("chat.system", "SMSG_CHANNEL_MEMBER_COUNT %s Channel: %s Count: %u",
|
||||
GetPlayerInfo().c_str(), channelName.c_str(), channel->GetNumPlayers());
|
||||
TC_LOG_DEBUG("chat.system", "SMSG_CHANNEL_MEMBER_COUNT %s Channel: %s Count: %u",
|
||||
GetPlayerInfo().c_str(), channelName.c_str(), channel->GetNumPlayers());
|
||||
|
||||
WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, channel->GetName().size() + 1 + 4);
|
||||
data << channel->GetName();
|
||||
data << uint8(channel->GetFlags());
|
||||
data << uint32(channel->GetNumPlayers());
|
||||
SendPacket(&data);
|
||||
}
|
||||
std::string name = channel->GetName(GetSessionDbcLocale());
|
||||
WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, name.size() + 1 + 4);
|
||||
data << name;
|
||||
data << uint8(channel->GetFlags());
|
||||
data << uint32(channel->GetNumPlayers());
|
||||
SendPacket(&data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,8 +359,7 @@ void WorldSession::HandleSetChannelWatch(WorldPacket& recvPacket)
|
||||
GetPlayerInfo().c_str(), channelName.c_str());
|
||||
|
||||
/*
|
||||
if (ChannelMgr* cMgr = channelMgr(GetPlayer()->GetTeam()))
|
||||
if (Channel* channel = cMgr->GetChannel(channelName, GetPlayer()))
|
||||
channel->JoinNotify(GetPlayer());
|
||||
if (Channel* channel = ChannelMgr::GetChannelForPlayerByNamePart(channelName, GetPlayer()))
|
||||
channel->JoinNotify(GetPlayer());
|
||||
*/
|
||||
}
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "DatabaseEnv.h"
|
||||
#include "CellImpl.h"
|
||||
#include "Chat.h"
|
||||
#include "Channel.h"
|
||||
#include "ChannelMgr.h"
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "Group.h"
|
||||
@@ -494,13 +495,10 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
|
||||
}
|
||||
}
|
||||
|
||||
if (ChannelMgr* cMgr = ChannelMgr::forTeam(sender->GetTeam()))
|
||||
if (Channel* chn = ChannelMgr::GetChannelForPlayerByNamePart(channel, sender))
|
||||
{
|
||||
if (Channel* chn = cMgr->GetChannel(channel, sender))
|
||||
{
|
||||
sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
|
||||
chn->Say(sender->GetGUID(), msg.c_str(), lang);
|
||||
}
|
||||
sScriptMgr->OnPlayerChat(sender, type, lang, msg, chn);
|
||||
chn->Say(sender->GetGUID(), msg.c_str(), lang);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user