mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 01:37:37 +01:00
Merge branch 'master' into 4.x
Conflicts: src/server/authserver/Server/AuthSocket.cpp src/server/game/Entities/Object/Object.cpp src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Handlers/AuctionHouseHandler.cpp src/server/game/Handlers/CharacterHandler.cpp src/server/game/Handlers/MovementHandler.cpp src/server/game/Miscellaneous/SharedDefines.h src/server/game/Spells/Spell.cpp src/server/game/Spells/SpellEffects.cpp
This commit is contained in:
302
src/server/game/Handlers/ChannelHandler.cpp
Executable file
302
src/server/game/Handlers/ChannelHandler.cpp
Executable file
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
|
||||
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||
*
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
#include "ObjectMgr.h" // for normalizePlayerName
|
||||
#include "ChannelMgr.h"
|
||||
|
||||
void WorldSession::HandleJoinChannel(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
|
||||
uint32 channelId;
|
||||
uint8 unknown1, unknown2;
|
||||
std::string channelName, pass;
|
||||
|
||||
recvPacket >> channelId;
|
||||
recvPacket >> unknown1 >> unknown2;
|
||||
recvPacket >> pass;
|
||||
recvPacket >> channelName;
|
||||
|
||||
if (channelId)
|
||||
{
|
||||
ChatChannelsEntry const* channel = sChatChannelsStore.LookupEntry(channelId);
|
||||
if (!channel)
|
||||
return;
|
||||
|
||||
AreaTableEntry const* current_zone = GetAreaEntryByAreaID(_player->GetZoneId());
|
||||
if (!current_zone)
|
||||
return;
|
||||
|
||||
if (!_player->CanJoinConstantChannelInZone(channel, current_zone))
|
||||
return;
|
||||
}
|
||||
|
||||
if (channelName.empty())
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
{
|
||||
cMgr->team = _player->GetTeam();
|
||||
if (Channel* chn = cMgr->GetJoinChannel(channelName, channelId))
|
||||
chn->Join(_player->GetGUID(), pass.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleLeaveChannel(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
|
||||
uint32 unk;
|
||||
std::string channelname;
|
||||
recvPacket >> unk; // channel id?
|
||||
recvPacket >> channelname;
|
||||
|
||||
if (channelname.empty())
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
{
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->Leave(_player->GetGUID(), true);
|
||||
cMgr->LeftChannel(channelname);
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelList(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname;
|
||||
recvPacket >> channelname;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->List(_player);
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelPassword(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, pass;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> pass;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->Password(_player->GetGUID(), pass.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelSetOwner(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, newp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> newp;
|
||||
|
||||
if (!normalizePlayerName(newp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->SetOwner(_player->GetGUID(), newp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelOwner(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname;
|
||||
recvPacket >> channelname;
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->SendWhoOwner(_player->GetGUID());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelModerator(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->SetModerator(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelUnmoderator(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->UnsetModerator(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelMute(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->SetMute(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelUnmute(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->UnsetMute(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelInvite(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->Invite(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelKick(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->Kick(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelBan(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->Ban(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelUnban(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
|
||||
std::string channelname, otp;
|
||||
recvPacket >> channelname;
|
||||
|
||||
recvPacket >> otp;
|
||||
|
||||
if (!normalizePlayerName(otp))
|
||||
return;
|
||||
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->UnBan(_player->GetGUID(), otp.c_str());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelAnnouncements(WorldPacket& recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname;
|
||||
recvPacket >> channelname;
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
chn->Announce(_player->GetGUID());
|
||||
}
|
||||
|
||||
void WorldSession::HandleChannelDisplayListQuery(WorldPacket &recvPacket)
|
||||
{
|
||||
// this should be OK because the 2 function _were_ the same
|
||||
HandleChannelList(recvPacket);
|
||||
}
|
||||
|
||||
void WorldSession::HandleGetChannelMemberCount(WorldPacket &recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname;
|
||||
recvPacket >> channelname;
|
||||
if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
{
|
||||
if (Channel* chn = cMgr->GetChannel(channelname, _player))
|
||||
{
|
||||
WorldPacket data(SMSG_CHANNEL_MEMBER_COUNT, chn->GetName().size()+1+1+4);
|
||||
data << chn->GetName();
|
||||
data << uint8(chn->GetFlags());
|
||||
data << uint32(chn->GetNumPlayers());
|
||||
SendPacket(&data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSession::HandleSetChannelWatch(WorldPacket &recvPacket)
|
||||
{
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "Opcode %u", recvPacket.GetOpcode());
|
||||
std::string channelname;
|
||||
recvPacket >> channelname;
|
||||
/*if (ChannelMgr* cMgr = channelMgr(_player->GetTeam()))
|
||||
if (Channel* chn = cMgr->GetChannel(channelName, _player))
|
||||
chn->JoinNotify(_player->GetGUID());*/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user