OpenFusion/src/NanoManager.cpp

24 lines
1011 B
C++
Raw Normal View History

2020-08-20 15:43:37 +00:00
#include "CNShardServer.hpp"
#include "CNStructs.hpp"
#include "NanoManager.hpp"
#include "PlayerManager.hpp"
void NanoManager::init() {
2020-08-21 00:37:34 +00:00
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_ACTIVE, nanoSummonHandler);
2020-08-20 15:43:37 +00:00
}
void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
2020-08-21 00:37:34 +00:00
if (data->size != sizeof(sP_CL2FE_REQ_NANO_ACTIVE))
2020-08-20 23:50:30 +00:00
return; // malformed packet
2020-08-21 00:37:34 +00:00
sP_CL2FE_REQ_NANO_ACTIVE* nano = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
PlayerView plr = PlayerManager::players[sock];
2020-08-20 15:43:37 +00:00
2020-08-21 00:37:34 +00:00
// 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()));
2020-08-20 15:43:37 +00:00
2020-08-21 00:37:34 +00:00
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << nano->iNanoSlotNum << std::endl;
}