From 49a9bf95c9506fe10163ee2faddd6cabb15bf776 Mon Sep 17 00:00:00 2001 From: AriDEV Date: Sun, 14 Jan 2024 14:00:01 +0100 Subject: [PATCH] Server/PacketIO: Add CMSG_BATTLE_PET_WILD_REQUEST opcode. --- src/server/game/BattlePet/BattlePetMgr.h | 22 ++++++ src/server/game/Handlers/BattlePetHandler.cpp | 68 +++++++++++++++++++ src/server/game/Server/Protocol/Opcodes.cpp | 3 + src/server/game/Server/Protocol/Opcodes.h | 3 + src/server/game/Server/WorldSession.h | 1 + 5 files changed, 97 insertions(+) diff --git a/src/server/game/BattlePet/BattlePetMgr.h b/src/server/game/BattlePet/BattlePetMgr.h index 6c55829f279..c98603791cd 100644 --- a/src/server/game/BattlePet/BattlePetMgr.h +++ b/src/server/game/BattlePet/BattlePetMgr.h @@ -110,4 +110,26 @@ class BattlePetMgr uint64 m_loadout[BATTLE_PET_MAX_LOADOUT_SLOTS] = { }; }; +struct PetBattleRequest +{ + enum PetBattleType + { + PET_BATTLE_TYPE_PVE = 0, + PET_BATTLE_TYPE_PVP_DUEL = 1, + PET_BATTLE_TYPE_PVP_MATCHMAKING = 2 + }; + uint64 EnemyGUID; + uint32 LocationResult; // name dumped from client, use unknown + + G3D::Vector3 Origin; + G3D::Vector3 Positions[2]; + float Orientation; + + // Data for creation of pet battle + PetBattleType Type; + Player* Challenger; + Unit* Enemy; +}; + + #endif diff --git a/src/server/game/Handlers/BattlePetHandler.cpp b/src/server/game/Handlers/BattlePetHandler.cpp index 448a37ab60c..8eebb870d9e 100644 --- a/src/server/game/Handlers/BattlePetHandler.cpp +++ b/src/server/game/Handlers/BattlePetHandler.cpp @@ -433,3 +433,71 @@ void WorldSession::HandleBattlePetSummonCompanion(WorldPacket& recvData) } } } + +void WorldSession::HandleBattlePetWildRequest(WorldPacket& recvData) +{ + SF_LOG_DEBUG("network", "WORLD: Received CMSG_BATTLE_PET_WILD_REQUEST"); + ObjectGuid guid; + bool hasOrientation; + bool hasResult; + + PetBattleRequest petBattleRequest; + + for (uint8 i = 0; i < 2; i++) // team positions + { + recvData >> petBattleRequest.Positions[i].x; + recvData >> petBattleRequest.Positions[i].z; + recvData >> petBattleRequest.Positions[i].y; + } + + // origin position + recvData >> petBattleRequest.Origin.z; + recvData >> petBattleRequest.Origin.y; + recvData >> petBattleRequest.Origin.x; + + recvData.ReadGuidMask(guid, 0); + hasOrientation = recvData.ReadBit(); + recvData.ReadGuidMask(guid, 6, 3, 5, 2, 7, 1, 4); + hasResult = recvData.ReadBit(); + + recvData.ReadGuidBytes(guid, 3, 6, 5, 2, 7, 1, 0, 4); + + if (hasOrientation) + recvData >> petBattleRequest.Orientation; + + if (hasResult) + recvData >> petBattleRequest.LocationResult; + + Creature* wildBattlePet = ObjectAccessor::GetCreatureOrPetOrVehicle(*GetPlayer(), petBattleRequest.EnemyGUID); + petBattleRequest.Type = PetBattleRequest::PET_BATTLE_TYPE_PVE; + petBattleRequest.Challenger = GetPlayer(); + petBattleRequest.Enemy = wildBattlePet; + + + WorldPacket data(SMSG_BATTLE_PET_LOCATION_FINALIZE, 100); + data << petBattleRequest.Origin.x; + data << petBattleRequest.Origin.y; + + for (uint8 i = 0; i < 2; i++) // team positions + { + data << petBattleRequest.Positions[i].y; + data << petBattleRequest.Positions[i].x; + data << petBattleRequest.Positions[i].z; + } + + data << petBattleRequest.Origin.z; + + data.WriteBit(petBattleRequest.Orientation); + data.WriteBit(petBattleRequest.LocationResult); + + if (petBattleRequest.LocationResult) + data << uint32(petBattleRequest.LocationResult); + if (petBattleRequest.Orientation) + data << float(petBattleRequest.Orientation); + _player->SendDirectMessage(&data); + + + //WorldPacket data2(SMSG_BATTLE_PET_UPDATE_INIT, 1000); + //SMSG_BATTLE_PET_UPDATE_INIT starts the pet battle itself. +} + diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp index bb3e7787b71..6a2ccf9fb2a 100644 --- a/src/server/game/Server/Protocol/Opcodes.cpp +++ b/src/server/game/Server/Protocol/Opcodes.cpp @@ -93,6 +93,7 @@ void OpcodeTable::InitializeClientTable() DEFINE_OPCODE_HANDLER(CMSG_BATTLE_PET_SET_BATTLE_SLOT, 0x0163, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlePetSetBattleSlot ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(CMSG_BATTLE_PET_SET_FLAGS, 0x17AC, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlePetSetFlags ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(CMSG_BATTLE_PET_SUMMON_COMPANION, 0x1896, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlePetSummonCompanion ); // 5.4.8 18414 + DEFINE_OPCODE_HANDLER(CMSG_BATTLE_PET_WILD_REQUEST, 0x06C5, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBattlePetWildRequest ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(CMSG_BEGIN_TRADE, 0x1CE3, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBeginTradeOpcode ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(CMSG_BINDER_ACTIVATE, 0x1248, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBinderActivateOpcode ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(CMSG_BLACKMARKET_BID, 0x12C8, STATUS_LOGGEDIN, PROCESS_THREADUNSAFE, &WorldSession::HandleBlackMarketBidOnItem ); // 5.4.8 18414 @@ -680,6 +681,8 @@ void OpcodeTable::InitializeServerTable() DEFINE_OPCODE_HANDLER(SMSG_BATTLE_PET_PET_UPDATES, 0x041A, STATUS_NEVER ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(SMSG_BATTLE_PET_QUERY_NAME_RESPONSE, 0x1540, STATUS_NEVER ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(SMSG_BATTLE_PET_SLOT_UPDATE, 0x16AF, STATUS_NEVER ); // 5.4.8 18414 + DEFINE_OPCODE_HANDLER(SMSG_BATTLE_PET_LOCATION_FINALIZE, 0x082E, STATUS_NEVER ); // 5.4.8 18414 + DEFINE_OPCODE_HANDLER(SMSG_BATTLE_PET_UPDATE_INIT, 0x0E1E, STATUS_NEVER ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(SMSG_BINDER_CONFIRM, 0x1287, STATUS_NEVER ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(SMSG_BIND_POINT_UPDATE, 0x0E3B, STATUS_NEVER ); // 5.4.8 18414 DEFINE_OPCODE_HANDLER(SMSG_BLACKMARKET_BID_RESULT, 0x148A, STATUS_NEVER ); // 5.4.8 18414 diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h index 1e47fd5fa7c..5ccf89cb315 100644 --- a/src/server/game/Server/Protocol/Opcodes.h +++ b/src/server/game/Server/Protocol/Opcodes.h @@ -84,6 +84,7 @@ enum Opcodes CMSG_BATTLE_PET_SET_BATTLE_SLOT, CMSG_BATTLE_PET_SET_FLAGS, CMSG_BATTLE_PET_SUMMON_COMPANION, + CMSG_BATTLE_PET_WILD_REQUEST, CMSG_BEGIN_TRADE, CMSG_BINDER_ACTIVATE, CMSG_BLACKMARKET_BID, @@ -648,6 +649,8 @@ enum Opcodes SMSG_BATTLE_PET_PET_UPDATES, SMSG_BATTLE_PET_QUERY_NAME_RESPONSE, SMSG_BATTLE_PET_SLOT_UPDATE, + SMSG_BATTLE_PET_LOCATION_FINALIZE, + SMSG_BATTLE_PET_UPDATE_INIT, SMSG_BINDER_CONFIRM, SMSG_BINDZONEREPLY, SMSG_BIND_POINT_UPDATE, diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h index 11064fb7971..2bbafb17b21 100644 --- a/src/server/game/Server/WorldSession.h +++ b/src/server/game/Server/WorldSession.h @@ -1079,6 +1079,7 @@ class WorldSession void HandleBattlePetSetBattleSlot(WorldPacket& recvData); void HandleBattlePetSetFlags(WorldPacket& recvData); void HandleBattlePetSummonCompanion(WorldPacket& recvData); + void HandleBattlePetWildRequest(WorldPacket& recvData); // Titles void HandleSetTitleOpcode(WorldPacket& recvData);