diff options
17 files changed, 245 insertions, 173 deletions
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index c9dbee66445..166eff5e495 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -38,7 +38,6 @@ #include "Util.h" #include "WorldPacket.h" #include "Transport.h" -#include "BattlegroundPackets.h" #include "MiscPackets.h" namespace Trinity @@ -180,6 +179,8 @@ Battleground::Battleground() m_queueId = 0; + m_LastPlayerPositionBroadcast = 0; + m_HonorMode = BG_NORMAL; StartDelayTimes[BG_STARTING_EVENT_FIRST] = BG_START_DELAY_2M; @@ -254,6 +255,7 @@ void Battleground::Update(uint32 diff) break; case STATUS_IN_PROGRESS: _ProcessOfflineQueue(); + _ProcessPlayerPositionBroadcast(diff); // after 47 minutes without one team losing, the arena closes with no winner and no rating change if (isArena()) { @@ -315,6 +317,19 @@ inline void Battleground::_CheckSafePositions(uint32 diff) } } +void Battleground::_ProcessPlayerPositionBroadcast(uint32 diff) +{ + m_LastPlayerPositionBroadcast += diff; + if (m_LastPlayerPositionBroadcast >= PLAYER_POSITION_UPDATE_INTERVAL) + { + m_LastPlayerPositionBroadcast = 0; + + WorldPackets::Battleground::BattlegroundPlayerPositions playerPositions; + GetPlayerPositionData(&playerPositions.FlagCarriers); + SendPacketToAll(playerPositions.Write()); + } +} + inline void Battleground::_ProcessOfflineQueue() { // remove offline players from bg after 5 minutes diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h index c1e4b3ad4ec..b2f8aec7fae 100644 --- a/src/server/game/Battlegrounds/Battleground.h +++ b/src/server/game/Battlegrounds/Battleground.h @@ -27,6 +27,7 @@ #include "Object.h" #include "GameObject.h" #include "Packets/WorldStatePackets.h" +#include "Packets/BattlegroundPackets.h" class Creature; class GameObject; @@ -40,14 +41,6 @@ class BattlegroundMap; struct PvPDifficultyEntry; struct WorldSafeLocsEntry; -namespace WorldPackets -{ - namespace Battleground - { - class PVPLogData; - } -} - enum BattlegroundCriteriaId { BG_CRITERIA_CHECK_RESILIENT_VICTORY, @@ -135,7 +128,8 @@ enum BattlegroundTimeIntervals RESPAWN_IMMEDIATELY = 0, // secs BUFF_RESPAWN_TIME = 180, // secs BATTLEGROUND_COUNTDOWN_MAX = 120, // secs - ARENA_COUNTDOWN_MAX = 60 // secs + ARENA_COUNTDOWN_MAX = 60, // secs + PLAYER_POSITION_UPDATE_INTERVAL = 5 // secs }; enum BattlegroundStartTimeIntervals @@ -216,6 +210,20 @@ enum BGHonorMode #define BG_AWARD_ARENA_POINTS_MIN_LEVEL 71 #define ARENA_TIMELIMIT_POINTS_LOSS -16 +enum BattlegroundPlayerPositionConstants +{ + PLAYER_POSITION_ICON_NONE = 0, + PLAYER_POSITION_ICON_HORDE_FLAG = 1, + PLAYER_POSITION_ICON_ALLIANCE_FLAG = 2, + + PLAYER_POSITION_ARENA_SLOT_NONE = 1, + PLAYER_POSITION_ARENA_SLOT_1 = 2, + PLAYER_POSITION_ARENA_SLOT_2 = 3, + PLAYER_POSITION_ARENA_SLOT_3 = 4, + PLAYER_POSITION_ARENA_SLOT_4 = 5, + PLAYER_POSITION_ARENA_SLOT_5 = 6 +}; + /* This class is used to: 1. Add player to battleground @@ -491,12 +499,44 @@ class Battleground Player* _GetPlayer(BattlegroundPlayerMap::const_iterator itr, const char* context) const { return _GetPlayer(itr->first, itr->second.OfflineRemoveTime != 0, context); } Player* _GetPlayerForTeam(uint32 teamId, BattlegroundPlayerMap::const_iterator itr, const char* context) const; + /* Pre- and post-update hooks */ + + /** + * @brief Pre-update hook. + * + * Will be called before battleground update is started. Depending on + * the result of this call actual update body may be skipped. + * + * @param diff a time difference between two worldserver update loops in + * milliseconds. + * + * @return @c true if update must be performed, @c false otherwise. + * + * @see Update(), PostUpdateImpl(). + */ + virtual bool PreUpdateImpl(uint32 /* diff */) { return true; } + + /** + * @brief Post-update hook. + * + * Will be called after battleground update has passed. May be used to + * implement custom update effects in subclasses. + * + * @param diff a time difference between two worldserver update loops in + * milliseconds. + * + * @see Update(), PreUpdateImpl(). + */ + virtual void PostUpdateImpl(uint32 /* diff */) { } + void _ProcessOfflineQueue(); void _ProcessResurrect(uint32 diff); void _ProcessProgress(uint32 diff); void _ProcessLeave(uint32 diff); void _ProcessJoin(uint32 diff); void _CheckSafePositions(uint32 diff); + void _ProcessPlayerPositionBroadcast(uint32 diff); + virtual void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* /*positions*/) const { } // Scorekeeping BattlegroundScoreMap PlayerScores; // Player scores @@ -547,36 +587,7 @@ class Battleground uint32 m_PrematureCountDownTimer; std::string m_Name; uint64 m_queueId; - - /* Pre- and post-update hooks */ - - /** - * @brief Pre-update hook. - * - * Will be called before battleground update is started. Depending on - * the result of this call actual update body may be skipped. - * - * @param diff a time difference between two worldserver update loops in - * milliseconds. - * - * @return @c true if update must be performed, @c false otherwise. - * - * @see Update(), PostUpdateImpl(). - */ - virtual bool PreUpdateImpl(uint32 /* diff */) { return true; } - - /** - * @brief Post-update hook. - * - * Will be called after battleground update has passed. May be used to - * implement custom update effects in subclasses. - * - * @param diff a time difference between two worldserver update loops in - * milliseconds. - * - * @see Update(), PreUpdateImpl(). - */ - virtual void PostUpdateImpl(uint32 /* diff */) { } + uint32 m_LastPlayerPositionBroadcast; // Player lists GuidVector m_ResurrectQueue; // Player GUID diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp index b1b98063771..3524588dc4c 100644 --- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp +++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp @@ -37,7 +37,6 @@ #include "BattlegroundIC.h" #include "BattlegroundTP.h" #include "BattlegroundBFG.h" -#include "BattlegroundPackets.h" #include "Chat.h" #include "Map.h" #include "MapInstanced.h" diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp index 8c646859740..06dd5ff6996 100644 --- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp +++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp @@ -20,7 +20,6 @@ #include "ArenaTeamMgr.h" #include "BattlegroundMgr.h" #include "BattlegroundQueue.h" -#include "BattlegroundPackets.h" #include "Chat.h" #include "Group.h" #include "Log.h" diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp index 081c8baa3be..52091991c67 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.cpp @@ -117,6 +117,20 @@ void BattlegroundEY::PostUpdateImpl(uint32 diff) } } +void BattlegroundEY::GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const +{ + if (Player* player = ObjectAccessor::GetObjectInMap(m_FlagKeeper, GetBgMap(), (Player*)nullptr)) + { + WorldPackets::Battleground::BattlegroundPlayerPosition position; + position.Guid = player->GetGUID(); + position.Pos.x = player->GetPositionX(); + position.Pos.y = player->GetPositionY(); + position.IconID = player->GetTeam() == ALLIANCE ? PLAYER_POSITION_ICON_ALLIANCE_FLAG : PLAYER_POSITION_ICON_HORDE_FLAG; + position.ArenaSlot = PLAYER_POSITION_ARENA_SLOT_NONE; + positions->push_back(position); + } +} + void BattlegroundEY::StartingEventCloseDoors() { SpawnBGObject(BG_EY_OBJECT_DOOR_A, RESPAWN_IMMEDIATELY); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h index d6a2991f01d..9e9061177ae 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundEY.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundEY.h @@ -393,8 +393,9 @@ class BattlegroundEY : public Battleground bool IsAllNodesControlledByTeam(uint32 team) const override; uint32 GetPrematureWinner() override; - private: +protected: void PostUpdateImpl(uint32 diff) override; + void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const override; void EventPlayerCapturedFlag(Player* Source, uint32 BgObjectType); void EventTeamCapturedPoint(Player* Source, uint32 Point); @@ -402,6 +403,7 @@ class BattlegroundEY : public Battleground void UpdatePointsCount(uint32 Team); void UpdatePointsIcons(uint32 Team, uint32 Point); + private: /* Point status updating procedures */ void CheckSomeoneLeftPoint(); void CheckSomeoneJoinedPoint(); diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp index c51027968bb..b5b5c80d938 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.cpp @@ -193,6 +193,31 @@ void BattlegroundWS::PostUpdateImpl(uint32 diff) } } +void BattlegroundWS::GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const +{ + if (Player* player = ObjectAccessor::GetObjectInMap(m_FlagKeepers[TEAM_ALLIANCE], GetBgMap(), (Player*)nullptr)) + { + WorldPackets::Battleground::BattlegroundPlayerPosition position; + position.Guid = player->GetGUID(); + position.Pos.x = player->GetPositionX(); + position.Pos.y = player->GetPositionY(); + position.IconID = PLAYER_POSITION_ICON_ALLIANCE_FLAG; + position.ArenaSlot = PLAYER_POSITION_ARENA_SLOT_NONE; + positions->push_back(position); + } + + if (Player* player = ObjectAccessor::GetObjectInMap(m_FlagKeepers[TEAM_HORDE], GetBgMap(), (Player*)nullptr)) + { + WorldPackets::Battleground::BattlegroundPlayerPosition position; + position.Guid = player->GetGUID(); + position.Pos.x = player->GetPositionX(); + position.Pos.y = player->GetPositionY(); + position.IconID = PLAYER_POSITION_ICON_HORDE_FLAG; + position.ArenaSlot = PLAYER_POSITION_ARENA_SLOT_NONE; + positions->push_back(position); + } +} + void BattlegroundWS::StartingEventCloseDoors() { for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i <= BG_WS_OBJECT_DOOR_H_4; ++i) diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h index 3736c01b045..1f473a2a138 100644 --- a/src/server/game/Battlegrounds/Zones/BattlegroundWS.h +++ b/src/server/game/Battlegrounds/Zones/BattlegroundWS.h @@ -246,6 +246,10 @@ class BattlegroundWS : public Battleground /* Achievements*/ bool CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* source, Unit const* target = nullptr, uint32 miscvalue1 = 0) override; + protected: + void PostUpdateImpl(uint32 diff) override; + void GetPlayerPositionData(std::vector<WorldPackets::Battleground::BattlegroundPlayerPosition>* positions) const override; + private: ObjectGuid m_FlagKeepers[2]; // 0 - alliance, 1 - horde ObjectGuid m_DroppedFlagGUID[2]; @@ -261,7 +265,5 @@ class BattlegroundWS : public Battleground bool _bothFlagsKept; uint8 _flagDebuffState; // 0 - no debuffs, 1 - focused assault, 2 - brutal assault uint8 _minutesElapsed; - - void PostUpdateImpl(uint32 diff) override; }; #endif diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index dec95ba4d24..acfa0c8be2e 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -22016,10 +22016,15 @@ bool Player::CanReportAfkDueToLimit() ///This player has been blamed to be inactive in a battleground void Player::ReportedAfkBy(Player* reporter) { + WorldPackets::Battleground::ReportPvPPlayerAFKResult reportAfkResult; + reportAfkResult.Offender = GetGUID(); Battleground* bg = GetBattleground(); // Battleground also must be in progress! if (!bg || bg != reporter->GetBattleground() || GetTeam() != reporter->GetTeam() || bg->GetStatus() != STATUS_IN_PROGRESS) + { + reporter->SendDirectMessage(reportAfkResult.Write()); return; + } // check if player has 'Idle' or 'Inactive' debuff if (m_bgData.bgAfkReporter.find(reporter->GetGUID()) == m_bgData.bgAfkReporter.end() && !HasAura(43680) && !HasAura(43681) && reporter->CanReportAfkDueToLimit()) @@ -22031,8 +22036,13 @@ void Player::ReportedAfkBy(Player* reporter) // cast 'Idle' spell CastSpell(this, 43680, true); m_bgData.bgAfkReporter.clear(); + reportAfkResult.NumBlackMarksOnOffender = m_bgData.bgAfkReporter.size(); + reportAfkResult.NumPlayersIHaveReported = reporter->m_bgData.bgAfkReportedCount; + reportAfkResult.Result = WorldPackets::Battleground::ReportPvPPlayerAFKResult::PVP_REPORT_AFK_SUCCESS; } } + + reporter->SendDirectMessage(reportAfkResult.Write()); } WorldLocation Player::GetStartPosition() const diff --git a/src/server/game/Handlers/BattleGroundHandler.cpp b/src/server/game/Handlers/BattleGroundHandler.cpp index 2b49b4673bf..ced3265a31c 100644 --- a/src/server/game/Handlers/BattleGroundHandler.cpp +++ b/src/server/game/Handlers/BattleGroundHandler.cpp @@ -37,7 +37,6 @@ #include "Battlefield.h" #include "BattlefieldMgr.h" #include "NPCPackets.h" -#include "BattlegroundPackets.h" void WorldSession::HandleBattlemasterHelloOpcode(WorldPackets::NPC::Hello& hello) { @@ -221,96 +220,6 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPackets::Battleground::Batt sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } -void WorldSession::HandleBattlegroundPlayerPositionsOpcode(WorldPacket& /*recvData*/) -{ - Battleground* bg = _player->GetBattleground(); - if (!bg) // can't be received if player not in battleground - return; - - uint32 acount = 0; - uint32 hcount = 0; - Player* aplr = NULL; - Player* hplr = NULL; - ObjectGuid guid = bg->GetFlagPickerGUID(TEAM_ALLIANCE); - if (!guid.IsEmpty()) - { - aplr = ObjectAccessor::FindPlayer(guid); - if (aplr) - ++acount; - } - - guid = bg->GetFlagPickerGUID(TEAM_HORDE); - if (!guid.IsEmpty()) - { - hplr = ObjectAccessor::FindPlayer(guid); - if (hplr) - ++hcount; - } - - ObjectGuid aguid = aplr ? aplr->GetGUID() : ObjectGuid::Empty; - ObjectGuid hguid = hplr ? hplr->GetGUID() : ObjectGuid::Empty; - - WorldPacket data(SMSG_BATTLEGROUND_PLAYER_POSITIONS); - - data.WriteBits(acount, 22); - for (uint8 i = 0; i < acount; i++) - { - data.WriteBit(aguid[3]); - data.WriteBit(aguid[5]); - data.WriteBit(aguid[1]); - data.WriteBit(aguid[6]); - data.WriteBit(aguid[7]); - data.WriteBit(aguid[0]); - data.WriteBit(aguid[2]); - data.WriteBit(aguid[4]); - } - - data.WriteBits(hcount, 22); - for (uint8 i = 0; i < hcount; i++) - { - data.WriteBit(hguid[6]); - data.WriteBit(hguid[5]); - data.WriteBit(hguid[4]); - data.WriteBit(hguid[7]); - data.WriteBit(hguid[2]); - data.WriteBit(hguid[1]); - data.WriteBit(hguid[0]); - data.WriteBit(hguid[3]); - } - - data.FlushBits(); - - for (uint8 i = 0; i < hcount; i++) - { - data.WriteByteSeq(hguid[2]); - data.WriteByteSeq(hguid[1]); - data << float(hplr->GetPositionY()); - data.WriteByteSeq(hguid[5]); - data.WriteByteSeq(hguid[4]); - data.WriteByteSeq(hguid[7]); - data.WriteByteSeq(hguid[0]); - data.WriteByteSeq(hguid[6]); - data.WriteByteSeq(hguid[3]); - data << float(hplr->GetPositionX()); - } - - for (uint8 i = 0; i < acount; i++) - { - data.WriteByteSeq(aguid[6]); - data << float(aplr->GetPositionX()); - data.WriteByteSeq(aguid[5]); - data.WriteByteSeq(aguid[3]); - data << float(aplr->GetPositionY()); - data.WriteByteSeq(aguid[1]); - data.WriteByteSeq(aguid[7]); - data.WriteByteSeq(aguid[0]); - data.WriteByteSeq(aguid[2]); - data.WriteByteSeq(aguid[4]); - } - - SendPacket(&data); -} - void WorldSession::HandlePVPLogDataOpcode(WorldPackets::Battleground::PVPLogDataRequest& /*pvpLogDataRequest*/) { Battleground* bg = _player->GetBattleground(); @@ -673,12 +582,9 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData) sBattlegroundMgr->ScheduleQueueUpdate(matchmakerRating, arenatype, bgQueueTypeId, bgTypeId, bracketEntry->GetBracketId()); } -void WorldSession::HandleReportPvPAFK(WorldPacket& recvData) +void WorldSession::HandleReportPvPAFK(WorldPackets::Battleground::ReportPvPPlayerAFK& reportPvPPlayerAFK) { - ObjectGuid playerGuid; - recvData >> playerGuid; - Player* reportedPlayer = ObjectAccessor::FindPlayer(playerGuid); - + Player* reportedPlayer = ObjectAccessor::FindPlayer(reportPvPPlayerAFK.Offender); if (!reportedPlayer) { TC_LOG_DEBUG("bg.battleground", "WorldSession::HandleReportPvPAFK: player not found"); diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp index acb202d4f52..d7a9278b75f 100644 --- a/src/server/game/Handlers/CharacterHandler.cpp +++ b/src/server/game/Handlers/CharacterHandler.cpp @@ -21,7 +21,6 @@ #include "ArenaTeamMgr.h" #include "AuthenticationPackets.h" #include "Battleground.h" -#include "BattlegroundPackets.h" #include "BattlenetServerManager.h" #include "CalendarMgr.h" #include "CharacterPackets.h" diff --git a/src/server/game/Server/Packets/BattlegroundPackets.cpp b/src/server/game/Server/Packets/BattlegroundPackets.cpp index a6aeb370ebe..ac65f2d6361 100644 --- a/src/server/game/Server/Packets/BattlegroundPackets.cpp +++ b/src/server/game/Server/Packets/BattlegroundPackets.cpp @@ -221,3 +221,35 @@ WorldPacket const* WorldPackets::Battleground::PVPOptionsEnabled::Write() _worldPacket.FlushBits(); return &_worldPacket; } + +void WorldPackets::Battleground::ReportPvPPlayerAFK::Read() +{ + _worldPacket >> Offender; +} + +WorldPacket const* WorldPackets::Battleground::ReportPvPPlayerAFKResult::Write() +{ + _worldPacket << Offender; + _worldPacket << uint8(Result); + _worldPacket << uint8(NumBlackMarksOnOffender); + _worldPacket << uint8(NumPlayersIHaveReported); + return &_worldPacket; +} + +ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Battleground::BattlegroundPlayerPosition const& playerPosition) +{ + data << playerPosition.Guid; + data << playerPosition.Pos; + data << int8(playerPosition.IconID); + data << int8(playerPosition.ArenaSlot); + return data; +} + +WorldPacket const* WorldPackets::Battleground::BattlegroundPlayerPositions::Write() +{ + _worldPacket << uint32(FlagCarriers.size()); + for (BattlegroundPlayerPosition const& pos : FlagCarriers) + _worldPacket << pos; + + return &_worldPacket; +} diff --git a/src/server/game/Server/Packets/BattlegroundPackets.h b/src/server/game/Server/Packets/BattlegroundPackets.h index efecef094ce..eaf38f0208d 100644 --- a/src/server/game/Server/Packets/BattlegroundPackets.h +++ b/src/server/game/Server/Packets/BattlegroundPackets.h @@ -19,8 +19,9 @@ #define BattlegroundPackets_h__ #include "ObjectGuid.h" -#include "Packet.h" #include "LFGPackets.h" +#include "PacketUtilities.h" +#include "Packet.h" namespace WorldPackets { @@ -279,13 +280,62 @@ namespace WorldPackets bool RatedBattlegrounds = false; }; - class RequestBattlefieldStatus final : public ClientPacket + class RequestBattlefieldStatus final : public ClientPacket { public: RequestBattlefieldStatus(WorldPacket&& packet) : ClientPacket(CMSG_REQUEST_BATTLEFIELD_STATUS, std::move(packet)) { } void Read() override { } }; + + class ReportPvPPlayerAFK final : public ClientPacket + { + public: + ReportPvPPlayerAFK(WorldPacket&& packet) : ClientPacket(CMSG_REPORT_PVP_PLAYER_AFK, std::move(packet)) { } + + void Read() override; + + ObjectGuid Offender; + }; + + class ReportPvPPlayerAFKResult final : public ServerPacket + { + public: + ReportPvPPlayerAFKResult() : ServerPacket(SMSG_REPORT_PVP_PLAYER_AFK_RESULT, 16 + 1 + 1 + 1) { } + + WorldPacket const* Write() override; + + enum ResultCode : uint8 + { + PVP_REPORT_AFK_SUCCESS = 0, + PVP_REPORT_AFK_GENERIC_FAILURE = 1, // there are more error codes but they are impossible to receive without modifying the client + PVP_REPORT_AFK_SYSTEM_ENABLED = 5, + PVP_REPORT_AFK_SYSTEM_DISABLED = 6 + }; + + ObjectGuid Offender; + uint8 NumPlayersIHaveReported = 0; + uint8 NumBlackMarksOnOffender = 0; + uint8 Result = PVP_REPORT_AFK_GENERIC_FAILURE; + }; + + struct BattlegroundPlayerPosition + { + ObjectGuid Guid; + G3D::Vector2 Pos; + int8 IconID = 0; + int8 ArenaSlot = 0; + }; + + class BattlegroundPlayerPositions final : public ServerPacket + { + public: + BattlegroundPlayerPositions() : ServerPacket(SMSG_BATTLEGROUND_PLAYER_POSITIONS, 4) { } + + WorldPacket const* Write() override; + + std::vector<BattlegroundPlayerPosition> FlagCarriers; + }; } } diff --git a/src/server/game/Server/Packets/PacketUtilities.h b/src/server/game/Server/Packets/PacketUtilities.h index 6246b637a71..32d9f8b8cab 100644 --- a/src/server/game/Server/Packets/PacketUtilities.h +++ b/src/server/game/Server/Packets/PacketUtilities.h @@ -15,22 +15,39 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#pragma once +#ifndef PacketUtilities_h__ +#define PacketUtilities_h__ -namespace WorldPackets +#include "ByteBuffer.h" +#include <G3D/Vector2.h> +#include <G3D/Vector3.h> + +inline ByteBuffer& operator<<(ByteBuffer& data, G3D::Vector2 const& v) { - inline ByteBuffer& operator<<(ByteBuffer& data, G3D::Vector3 const& v) - { - data << v.x << v.y << v.z; - return data; - } + data << v.x << v.y; + return data; +} - inline ByteBuffer& operator>>(ByteBuffer& data, G3D::Vector3& v) - { - data >> v.x >> v.y >> v.z; - return data; - } +inline ByteBuffer& operator>>(ByteBuffer& data, G3D::Vector2& v) +{ + data >> v.x >> v.y; + return data; +} + +inline ByteBuffer& operator<<(ByteBuffer& data, G3D::Vector3 const& v) +{ + data << v.x << v.y << v.z; + return data; +} + +inline ByteBuffer& operator>>(ByteBuffer& data, G3D::Vector3& v) +{ + data >> v.x >> v.y >> v.z; + return data; +} +namespace WorldPackets +{ template <typename T> struct CompactArray { @@ -93,3 +110,5 @@ namespace WorldPackets return data; } } + +#endif // PacketUtilities_h__ diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index bef173fb653..b72c6f73e84 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -663,7 +663,7 @@ void OpcodeTable::Initialize() DEFINE_HANDLER(CMSG_REPAIR_ITEM, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Item::RepairItem, &WorldSession::HandleRepairItemOpcode); DEFINE_OPCODE_HANDLER_OLD(CMSG_REPLACE_TROPHY, STATUS_UNHANDLED, PROCESS_INPLACE, &WorldSession::Handle_NULL ); DEFINE_HANDLER(CMSG_REPOP_REQUEST, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Misc::RepopRequest, &WorldSession::HandleRepopRequest); - DEFINE_OPCODE_HANDLER_OLD(CMSG_REPORT_PVP_PLAYER_AFK, STATUS_UNHANDLED, PROCESS_THREADUNSAFE, &WorldSession::HandleReportPvPAFK ); + DEFINE_HANDLER(CMSG_REPORT_PVP_PLAYER_AFK, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battleground::ReportPvPPlayerAFK, &WorldSession::HandleReportPvPAFK); DEFINE_HANDLER(CMSG_REQUEST_ACCOUNT_DATA, STATUS_AUTHED, PROCESS_THREADUNSAFE, WorldPackets::ClientConfig::RequestAccountData, &WorldSession::HandleRequestAccountData); DEFINE_HANDLER(CMSG_REQUEST_BATTLEFIELD_STATUS, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, WorldPackets::Battleground::RequestBattlefieldStatus, &WorldSession::HandleRequestBattlefieldStatusOpcode); DEFINE_HANDLER(CMSG_REQUEST_CATEGORY_COOLDOWNS, STATUS_LOGGEDIN, PROCESS_INPLACE, WorldPackets::Spells::RequestCategoryCooldowns, &WorldSession::HandleRequestCategoryCooldowns); @@ -898,7 +898,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_INIT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_PLAYER_JOINED, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_PLAYER_LEFT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_PLAYER_POSITIONS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_PLAYER_POSITIONS, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLEGROUND_POINTS, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLENET_CHALLENGE_ABORT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_BATTLENET_CHALLENGE_START, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); @@ -1496,7 +1496,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_PROC_RESIST, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_PROPOSE_LEVEL_GRANT, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_PVP_CREDIT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_PVP_LOG_DATA, STATUS_NEVER, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_PVP_LOG_DATA, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_PVP_OPTIONS_ENABLED, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_PVP_SEASON, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_QUERY_BATTLE_PET_NAME_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); @@ -1555,7 +1555,7 @@ void OpcodeTable::Initialize() DEFINE_SERVER_OPCODE_HANDLER(SMSG_REMOVE_ITEM_PASSIVE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REMOVE_LOSS_OF_CONTROL, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REPLACE_TROPHY_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); - DEFINE_SERVER_OPCODE_HANDLER(SMSG_REPORT_PVP_PLAYER_AFK_RESULT, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); + DEFINE_SERVER_OPCODE_HANDLER(SMSG_REPORT_PVP_PLAYER_AFK_RESULT, STATUS_NEVER, CONNECTION_TYPE_INSTANCE); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REQUEST_CEMETERY_LIST_RESPONSE, STATUS_NEVER, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_REQUEST_PVP_REWARDS_RESPONSE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); DEFINE_SERVER_OPCODE_HANDLER(SMSG_RESEARCH_COMPLETE, STATUS_UNHANDLED, CONNECTION_TYPE_REALM); diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index d889fa70730..7a6a681cbd5 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -116,6 +116,7 @@ namespace WorldPackets class BattlefieldListRequest; class GetPVPOptionsEnabled; class RequestBattlefieldStatus; + class ReportPvPPlayerAFK; } namespace BlackMarket @@ -1277,13 +1278,12 @@ class WorldSession //Battleground void HandleBattlemasterHelloOpcode(WorldPackets::NPC::Hello& hello); void HandleBattlemasterJoinOpcode(WorldPackets::Battleground::BattlemasterJoin& battlemasterJoin); - void HandleBattlegroundPlayerPositionsOpcode(WorldPacket& recvData); void HandlePVPLogDataOpcode(WorldPackets::Battleground::PVPLogDataRequest& pvpLogDataRequest); void HandleBattleFieldPortOpcode(WorldPackets::Battleground::BattlefieldPort& battlefieldPort); void HandleBattlefieldListOpcode(WorldPackets::Battleground::BattlefieldListRequest& battlefieldList); void HandleBattlefieldLeaveOpcode(WorldPackets::Battleground::BattlefieldLeave& battlefieldLeave); void HandleBattlemasterJoinArena(WorldPacket& recvData); - void HandleReportPvPAFK(WorldPacket& recvData); + void HandleReportPvPAFK(WorldPackets::Battleground::ReportPvPPlayerAFK& reportPvPPlayerAFK); void HandleRequestRatedBattlefieldInfo(WorldPacket& recvData); void HandleGetPVPOptionsEnabled(WorldPackets::Battleground::GetPVPOptionsEnabled& getPvPOptionsEnabled); void HandleRequestPvpReward(WorldPacket& recvData); diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h index 4ac35c9feeb..0fa500c7c65 100644 --- a/src/server/shared/Packets/ByteBuffer.h +++ b/src/server/shared/Packets/ByteBuffer.h @@ -814,15 +814,4 @@ inline void ByteBuffer::read_skip<std::string>() read_skip<char*>(); } -namespace boost -{ - namespace asio - { - inline const_buffers_1 buffer(ByteBuffer const& packet) - { - return buffer(packet.contents(), packet.size()); - } - } -} - #endif |