Implemented buddy warping

Buddy warping now works, if anything else needs to be added/redone in regards to this feel free to let me know ^
This commit is contained in:
SengokuNadeko 2020-09-22 13:02:00 -04:00 committed by GitHub
parent 90134cd1fa
commit e0e474924d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View File

@ -16,6 +16,7 @@ void BuddyManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_GET_BUDDY_STATE, reqPktGetBuddyState); REGISTER_SHARD_PACKET(P_CL2FE_REQ_GET_BUDDY_STATE, reqPktGetBuddyState);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_SET_BUDDY_BLOCK, reqBuddyBlock); REGISTER_SHARD_PACKET(P_CL2FE_REQ_SET_BUDDY_BLOCK, reqBuddyBlock);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_REMOVE_BUDDY, reqBuddyDelete); REGISTER_SHARD_PACKET(P_CL2FE_REQ_REMOVE_BUDDY, reqBuddyDelete);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_BUDDY_WARP, reqBuddyWarp);
} }
//Buddy request //Buddy request
@ -310,6 +311,32 @@ void BuddyManager::reqBuddyDelete(CNSocket* sock, CNPacketData* data) {
sock->sendPacket((void*)&resp, P_FE2CL_REP_REMOVE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REMOVE_BUDDY_SUCC)); sock->sendPacket((void*)&resp, P_FE2CL_REP_REMOVE_BUDDY_SUCC, sizeof(sP_FE2CL_REP_REMOVE_BUDDY_SUCC));
} }
//Warping to buddy
void BuddyManager::reqBuddyWarp(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_BUDDY_WARP))
return; //malformed packet
sP_CL2FE_REQ_PC_BUDDY_WARP* pkt = (sP_CL2FE_REQ_PC_BUDDY_WARP*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_BUDDY_WARP_OTHER_SHARD_SUCC, resp);
resp.iBuddyPCUID = pkt->iBuddyPCUID;
CNSocket* otherSock = sock;
for (auto pair : PlayerManager::players) {
if (pair.second.plr->PCStyle.iPC_UID == pkt->iBuddyPCUID) {
otherSock = pair.first;
}
}
Player* buddy = PlayerManager::getPlayer(otherSock);
PlayerManager::updatePlayerPosition(sock, buddy->x, buddy->y, buddy->z);
sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_BUDDY_WARP_OTHER_SHARD_SUCC, sizeof(sP_FE2CL_REP_PC_BUDDY_WARP_OTHER_SHARD_SUCC));
}
#pragma region Helper methods #pragma region Helper methods
void BuddyManager::requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr) { void BuddyManager::requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr) {

View File

@ -29,6 +29,9 @@ namespace BuddyManager {
//Blocking/removing buddies //Blocking/removing buddies
void reqBuddyBlock(CNSocket* sock, CNPacketData* data); void reqBuddyBlock(CNSocket* sock, CNPacketData* data);
void reqBuddyDelete(CNSocket* sock, CNPacketData* data); void reqBuddyDelete(CNSocket* sock, CNPacketData* data);
//Buddy warping
void reqBuddyWarp(CNSocket* sock, CNPacketData* data);
//helper methods //helper methods
void requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr); void requestedBuddy(CNSocket* sock, Player* plrReq, PlayerView& plr);