From 795107a27469f59c565b1511eaedb57d2a9c2442 Mon Sep 17 00:00:00 2001 From: Onii-chan Date: Thu, 20 Aug 2020 11:51:02 +0200 Subject: [PATCH] Added nano summon feature --- src/CNShardServer.hpp | 2 ++ src/NanoManager.cpp | 20 ++++++++++++++++++++ src/NanoManager.hpp | 11 +++++++++++ src/main.cpp | 2 ++ 4 files changed, 35 insertions(+) create mode 100644 src/NanoManager.cpp create mode 100644 src/NanoManager.hpp diff --git a/src/CNShardServer.hpp b/src/CNShardServer.hpp index 894d76b..c7f3a83 100644 --- a/src/CNShardServer.hpp +++ b/src/CNShardServer.hpp @@ -10,6 +10,7 @@ enum SHARDPACKETID { P_CL2FE_REQ_PC_ENTER = 318767105, P_CL2FE_REQ_PC_LOADING_COMPLETE = 318767245, P_CL2FE_REP_LIVE_CHECK = 318767221, + P_CL2FE_REQ_NANO_ACTIVE = 318767119, P_CL2FE_REQ_PC_MOVE = 318767107, P_CL2FE_REQ_PC_STOP = 318767108, P_CL2FE_REQ_PC_JUMP = 318767109, @@ -21,6 +22,7 @@ enum SHARDPACKETID { P_CL2FE_REQ_PC_EXIT = 318767106, // shard 2 client + P_FE2CL_REP_NANO_ACTIVE_SUCC = 822083624, P_FE2CL_REP_PC_ENTER_SUCC = 822083586, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC = 822083833, P_FE2CL_REQ_LIVE_CHECK = 822083792, diff --git a/src/NanoManager.cpp b/src/NanoManager.cpp new file mode 100644 index 0000000..4f7e5f8 --- /dev/null +++ b/src/NanoManager.cpp @@ -0,0 +1,20 @@ +#include "CNShardServer.hpp" +#include "CNStructs.hpp" +#include "NanoManager.hpp" +#include "PlayerManager.hpp" + +void NanoManager::init() { + REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_ACTIVE, nanoSummonHandler); +} + +void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) { + sP_CL2FE_REQ_NANO_ACTIVE* nano = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf; + PlayerView plr = PlayerManager::players[sock]; + + // Send to client + sP_FE2CL_REP_NANO_ACTIVE_SUCC* resp = (sP_FE2CL_REP_NANO_ACTIVE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC)); + resp->iActiveNanoSlotNum = nano->iNanoSlotNum; + sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_ACTIVE_SUCC, sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC), sock->getFEKey())); + + std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << nano->iNanoSlotNum << std::endl; +} \ No newline at end of file diff --git a/src/NanoManager.hpp b/src/NanoManager.hpp new file mode 100644 index 0000000..b583d7a --- /dev/null +++ b/src/NanoManager.hpp @@ -0,0 +1,11 @@ +#ifndef _NM_HPP +#define _NM_HPP + +#include "CNShardServer.hpp" + +namespace NanoManager { + void init(); + void nanoSummonHandler(CNSocket* sock, CNPacketData* data); +} + +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index ca15dc3..0fc3af6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,6 +2,7 @@ #include "CNShardServer.hpp" #include "PlayerManager.hpp" #include "ChatManager.hpp" +#include "NanoManager.hpp" #include "settings.hpp" @@ -28,6 +29,7 @@ int main() { std::cout << "[INFO] Intializing Packet Managers..." << std::endl; PlayerManager::init(); ChatManager::init(); + NanoManager::init(); std::cout << "[INFO] Starting Server Threads..." << std::endl; CNLoginServer loginServer(settings::LOGINPORT);