From 14d556976d9b49a480d838f04ecba44ecc93a840 Mon Sep 17 00:00:00 2001 From: CakeLancelot Date: Thu, 20 Aug 2020 11:26:26 -0500 Subject: [PATCH] Add zipline, slide, cannon, and jump pad packets Cannon still looks wonky from other player's PoV, something's up with the rotation - will investigate later. --- src/CNShardServer.hpp | 8 +++ src/PlayerManager.cpp | 132 ++++++++++++++++++++++++++++++++++++++++++ src/PlayerManager.hpp | 4 ++ 3 files changed, 144 insertions(+) diff --git a/src/CNShardServer.hpp b/src/CNShardServer.hpp index c7f3a83..fd83cef 100644 --- a/src/CNShardServer.hpp +++ b/src/CNShardServer.hpp @@ -14,7 +14,11 @@ enum SHARDPACKETID { P_CL2FE_REQ_PC_MOVE = 318767107, P_CL2FE_REQ_PC_STOP = 318767108, P_CL2FE_REQ_PC_JUMP = 318767109, + P_CL2FE_REQ_PC_JUMPPAD = 318767165, + P_CL2FE_REQ_PC_LAUNCHER = 318767166, + P_CL2FE_REQ_PC_ZIPLINE = 318767167, P_CL2FE_REQ_PC_MOVEPLATFORM = 318767168, + P_CL2FE_REQ_PC_SLOPE = 318767169, P_CL2FE_REQ_PC_GOTO = 318767124, P_CL2FE_GM_REQ_PC_SET_VALUE = 318767211, P_CL2FE_REQ_SEND_FREECHAT_MESSAGE = 318767111, @@ -31,7 +35,11 @@ enum SHARDPACKETID { P_FE2CL_PC_STOP = 822083593, P_FE2CL_PC_JUMP = 822083594, P_FE2CL_PC_EXIT = 822083590, + P_FE2CL_PC_JUMPPAD = 822083701, + P_FE2CL_PC_LAUNCHER = 822083702, + P_FE2CL_PC_ZIPLINE = 822083703, P_FE2CL_PC_MOVEPLATFORM = 822083704, + P_FE2CL_PC_SLOPE = 822083705, P_FE2CL_REP_PC_GOTO_SUCC = 822083633, P_FE2CL_GM_REP_PC_SET_VALUE = 822083781, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC = 822083602, diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 41437d6..4a5b095 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -18,7 +18,11 @@ void PlayerManager::init() { REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_MOVE, PlayerManager::movePlayer); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_STOP, PlayerManager::stopPlayer); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_JUMP, PlayerManager::jumpPlayer); + REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_JUMPPAD, PlayerManager::jumppadPlayer); + REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_LAUNCHER, PlayerManager::launchPlayer); + REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ZIPLINE, PlayerManager::ziplinePlayer); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_MOVEPLATFORM, PlayerManager::movePlatformPlayer); + REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_SLOPE, PlayerManager::moveSlopePlayer); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GOTO, PlayerManager::gotoPlayer); REGISTER_SHARD_PACKET(P_CL2FE_GM_REQ_PC_SET_VALUE, PlayerManager::setSpecialPlayer); REGISTER_SHARD_PACKET(P_CL2FE_REP_LIVE_CHECK, PlayerManager::heartbeatPlayer); @@ -317,6 +321,103 @@ void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) { } } +void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) { + if (data->size != sizeof(sP_CL2FE_REQ_PC_JUMPPAD)) + return; // ignore the malformed packet + + sP_CL2FE_REQ_PC_JUMPPAD* jumppadData = (sP_CL2FE_REQ_PC_JUMPPAD*)data->buf; + updatePlayerPosition(sock, jumppadData->iX, jumppadData->iY, jumppadData->iZ); + + uint64_t tm = getTime(); + + for (CNSocket* otherSock : players[sock].viewable) { + sP_FE2CL_PC_JUMPPAD* jumppadResponse = (sP_FE2CL_PC_JUMPPAD*)xmalloc(sizeof(sP_FE2CL_PC_JUMPPAD)); + + jumppadResponse->iPC_ID = players[sock].plr.iID; + jumppadResponse->cKeyValue = jumppadData->cKeyValue; + + jumppadResponse->iX = jumppadData->iX; + jumppadResponse->iY = jumppadData->iY; + jumppadResponse->iZ = jumppadData->iZ; + jumppadResponse->iVX = jumppadData->iVX; + jumppadResponse->iVY = jumppadData->iVY; + jumppadResponse->iVZ = jumppadData->iVZ; + + jumppadResponse->iCliTime = jumppadData->iCliTime; + jumppadResponse->iSvrTime = tm; + + otherSock->sendPacket(new CNPacketData((void*)jumppadResponse, P_FE2CL_PC_JUMPPAD, sizeof(sP_FE2CL_PC_JUMPPAD), otherSock->getFEKey())); + } +} + +void PlayerManager::launchPlayer(CNSocket* sock, CNPacketData* data) { + if (data->size != sizeof(sP_CL2FE_REQ_PC_LAUNCHER)) + return; // ignore the malformed packet + + sP_CL2FE_REQ_PC_LAUNCHER* launchData = (sP_CL2FE_REQ_PC_LAUNCHER*)data->buf; + updatePlayerPosition(sock, launchData->iX, launchData->iY, launchData->iZ); + + uint64_t tm = getTime(); + + for (CNSocket* otherSock : players[sock].viewable) { + sP_FE2CL_PC_LAUNCHER* launchResponse = (sP_FE2CL_PC_LAUNCHER*)xmalloc(sizeof(sP_FE2CL_PC_LAUNCHER)); + + launchResponse->iPC_ID = players[sock].plr.iID; + + launchResponse->iX = launchData->iX; + launchResponse->iY = launchData->iY; + launchResponse->iZ = launchData->iZ; + launchResponse->iVX = launchData->iVX; + launchResponse->iVY = launchData->iVY; + launchResponse->iVZ = launchData->iVZ; + launchResponse->iSpeed = launchData->iSpeed; + launchResponse->iAngle = launchData->iAngle; + + launchResponse->iCliTime = launchData->iCliTime; + launchResponse->iSvrTime = tm; + + otherSock->sendPacket(new CNPacketData((void*)launchResponse, P_FE2CL_PC_LAUNCHER, sizeof(sP_FE2CL_PC_LAUNCHER), otherSock->getFEKey())); + } +} + +void PlayerManager::ziplinePlayer(CNSocket* sock, CNPacketData* data) { + if (data->size != sizeof(sP_CL2FE_REQ_PC_ZIPLINE)) + return; // ignore the malformed packet + + sP_CL2FE_REQ_PC_ZIPLINE* ziplineData = (sP_CL2FE_REQ_PC_ZIPLINE*)data->buf; + updatePlayerPosition(sock, ziplineData->iX, ziplineData->iY, ziplineData->iZ); + + uint64_t tm = getTime(); + + for (CNSocket* otherSock : players[sock].viewable) { + + sP_FE2CL_PC_ZIPLINE* ziplineResponse = (sP_FE2CL_PC_ZIPLINE*)xmalloc(sizeof(sP_FE2CL_PC_ZIPLINE)); + + ziplineResponse->iPC_ID = players[sock].plr.iID; + ziplineResponse->iCliTime = ziplineData->iCliTime; + ziplineResponse->iSvrTime = tm; + ziplineResponse->iX = ziplineData->iX; + ziplineResponse->iY = ziplineData->iY; + ziplineResponse->iZ = ziplineData->iZ; + ziplineResponse->fVX = ziplineData->fVX; + ziplineResponse->fVY = ziplineData->fVY; + ziplineResponse->fVZ = ziplineData->fVZ; + ziplineResponse->fMovDistance = ziplineData->fMovDistance; + ziplineResponse->fMaxDistance = ziplineData->fMaxDistance; + ziplineResponse->fDummy = ziplineData->fDummy; //wtf is this for? + ziplineResponse->iStX = ziplineData->iStX; + ziplineResponse->iStY = ziplineData->iStY; + ziplineResponse->iStZ = ziplineData->iStZ; + ziplineResponse->bDown = ziplineData->bDown; + ziplineResponse->iSpeed = ziplineData->iSpeed; + ziplineResponse->iAngle = ziplineData->iAngle; + ziplineResponse->iRollMax = ziplineData->iRollMax; + ziplineResponse->iRoll = ziplineData->iRoll; + + otherSock->sendPacket(new CNPacketData((void*)ziplineResponse, P_FE2CL_PC_ZIPLINE, sizeof(sP_FE2CL_PC_ZIPLINE), otherSock->getFEKey())); + } +} + void PlayerManager::movePlatformPlayer(CNSocket* sock, CNPacketData* data) { if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVEPLATFORM)) return; // ignore the malformed packet @@ -352,6 +453,37 @@ void PlayerManager::movePlatformPlayer(CNSocket* sock, CNPacketData* data) { } } +void PlayerManager::moveSlopePlayer(CNSocket* sock, CNPacketData* data) { + if (data->size != sizeof(sP_CL2FE_REQ_PC_SLOPE)) + return; // ignore the malformed packet + + sP_CL2FE_REQ_PC_SLOPE* slopeData = (sP_CL2FE_REQ_PC_SLOPE*)data->buf; + updatePlayerPosition(sock, slopeData->iX, slopeData->iY, slopeData->iZ); + + uint64_t tm = getTime(); + + for (CNSocket* otherSock : players[sock].viewable) { + + sP_FE2CL_PC_SLOPE* slopeResponse = (sP_FE2CL_PC_SLOPE*)xmalloc(sizeof(sP_FE2CL_PC_SLOPE)); + + slopeResponse->iPC_ID = players[sock].plr.iID; + slopeResponse->iCliTime = slopeData->iCliTime; + slopeResponse->iSvrTime = tm; + slopeResponse->iX = slopeData->iX; + slopeResponse->iY = slopeData->iY; + slopeResponse->iZ = slopeData->iZ; + slopeResponse->iAngle = slopeData->iAngle; + slopeResponse->fVX = slopeData->fVX; + slopeResponse->fVY = slopeData->fVY; + slopeResponse->fVZ = slopeData->fVZ; + slopeResponse->iSpeed = slopeData->iSpeed; + slopeResponse->cKeyValue = slopeData->cKeyValue; + slopeResponse->iSlopeID = slopeData->iSlopeID; + + otherSock->sendPacket(new CNPacketData((void*)slopeResponse, P_FE2CL_PC_SLOPE, sizeof(sP_FE2CL_PC_SLOPE), otherSock->getFEKey())); + } +} + void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) { if (data->size != sizeof(sP_CL2FE_REQ_PC_GOTO)) return; // ignore the malformed packet diff --git a/src/PlayerManager.hpp b/src/PlayerManager.hpp index a8e95db..77e8a4a 100644 --- a/src/PlayerManager.hpp +++ b/src/PlayerManager.hpp @@ -31,7 +31,11 @@ namespace PlayerManager { void movePlayer(CNSocket* sock, CNPacketData* data); void stopPlayer(CNSocket* sock, CNPacketData* data); void jumpPlayer(CNSocket* sock, CNPacketData* data); + void jumppadPlayer(CNSocket* sock, CNPacketData* data); + void launchPlayer(CNSocket* sock, CNPacketData* data); + void ziplinePlayer(CNSocket* sock, CNPacketData* data); void movePlatformPlayer(CNSocket* sock, CNPacketData* data); + void moveSlopePlayer(CNSocket* sock, CNPacketData* data); void gotoPlayer(CNSocket* sock, CNPacketData* data); void setSpecialPlayer(CNSocket* sock, CNPacketData* data); void heartbeatPlayer(CNSocket* sock, CNPacketData* data);