Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Server/PacketIO: Add CMSG_BATTLE_PET_WILD_REQUEST opcode.
Browse files Browse the repository at this point in the history
  • Loading branch information
AriDEV3 committed Jan 14, 2024
1 parent 14c88e2 commit 49a9bf9
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/server/game/BattlePet/BattlePetMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
68 changes: 68 additions & 0 deletions src/server/game/Handlers/BattlePetHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

3 changes: 3 additions & 0 deletions src/server/game/Server/Protocol/Opcodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/server/game/Server/Protocol/Opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/server/game/Server/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 49a9bf9

Please sign in to comment.