Updated indentations

This commit is contained in:
Onii-chan
2020-08-22 17:11:41 +02:00
parent 70816e3e64
commit d618d1b353
4 changed files with 550 additions and 550 deletions

View File

@@ -6,84 +6,84 @@
#include <map> #include <map>
enum SHARDPACKETID { enum SHARDPACKETID {
// client 2 shard // client 2 shard
P_CL2FE_REQ_PC_ENTER = 318767105, P_CL2FE_REQ_PC_ENTER = 318767105,
P_CL2FE_REQ_PC_LOADING_COMPLETE = 318767245, P_CL2FE_REQ_PC_LOADING_COMPLETE = 318767245,
P_CL2FE_REP_LIVE_CHECK = 318767221, P_CL2FE_REP_LIVE_CHECK = 318767221,
P_CL2FE_REQ_NANO_ACTIVE = 318767119, P_CL2FE_REQ_NANO_ACTIVE = 318767119,
P_CL2FE_REQ_NANO_EQUIP = 318767117, P_CL2FE_REQ_NANO_EQUIP = 318767117,
P_CL2FE_REQ_NANO_UNEQUIP = 318767118, P_CL2FE_REQ_NANO_UNEQUIP = 318767118,
P_CL2FE_REQ_NANO_SKILL_USE = 318767121, P_CL2FE_REQ_NANO_SKILL_USE = 318767121,
P_CL2FE_REQ_NANO_TUNE = 318767120, P_CL2FE_REQ_NANO_TUNE = 318767120,
P_CL2FE_REQ_PC_FIRST_USE_FLAG_SET = 318767238, P_CL2FE_REQ_PC_FIRST_USE_FLAG_SET = 318767238,
P_CL2FE_REQ_PC_GIVE_NANO = 318767172, P_CL2FE_REQ_PC_GIVE_NANO = 318767172,
P_CL2FE_REQ_PC_MOVE = 318767107, P_CL2FE_REQ_PC_MOVE = 318767107,
P_CL2FE_REQ_PC_STOP = 318767108, P_CL2FE_REQ_PC_STOP = 318767108,
P_CL2FE_REQ_PC_JUMP = 318767109, P_CL2FE_REQ_PC_JUMP = 318767109,
P_CL2FE_REQ_PC_JUMPPAD = 318767165, P_CL2FE_REQ_PC_JUMPPAD = 318767165,
P_CL2FE_REQ_PC_LAUNCHER = 318767166, P_CL2FE_REQ_PC_LAUNCHER = 318767166,
P_CL2FE_REQ_PC_ZIPLINE = 318767167, P_CL2FE_REQ_PC_ZIPLINE = 318767167,
P_CL2FE_REQ_PC_MOVEPLATFORM = 318767168, P_CL2FE_REQ_PC_MOVEPLATFORM = 318767168,
P_CL2FE_REQ_PC_SLOPE = 318767169, P_CL2FE_REQ_PC_SLOPE = 318767169,
P_CL2FE_REQ_PC_GOTO = 318767124, P_CL2FE_REQ_PC_GOTO = 318767124,
P_CL2FE_GM_REQ_PC_SET_VALUE = 318767211, P_CL2FE_GM_REQ_PC_SET_VALUE = 318767211,
P_CL2FE_REQ_SEND_FREECHAT_MESSAGE = 318767111, P_CL2FE_REQ_SEND_FREECHAT_MESSAGE = 318767111,
P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT = 318767184, P_CL2FE_REQ_PC_AVATAR_EMOTES_CHAT = 318767184,
P_CL2FE_REQ_ITEM_MOVE = 318767114, P_CL2FE_REQ_ITEM_MOVE = 318767114,
P_CL2FE_REQ_PC_ITEM_DELETE = 318767129, P_CL2FE_REQ_PC_ITEM_DELETE = 318767129,
P_CL2FE_REQ_PC_GIVE_ITEM = 318767130, P_CL2FE_REQ_PC_GIVE_ITEM = 318767130,
P_CL2FE_REQ_PC_EXIT = 318767106, P_CL2FE_REQ_PC_EXIT = 318767106,
// shard 2 client // shard 2 client
P_FE2CL_REP_NANO_ACTIVE_SUCC = 822083624, P_FE2CL_REP_NANO_ACTIVE_SUCC = 822083624,
P_FE2CL_REP_PC_NANO_CREATE_SUCC = 822083667, P_FE2CL_REP_PC_NANO_CREATE_SUCC = 822083667,
P_FE2CL_REP_NANO_EQUIP_SUCC = 822083622, P_FE2CL_REP_NANO_EQUIP_SUCC = 822083622,
P_FE2CL_REP_NANO_UNEQUIP_SUCC = 822083623, P_FE2CL_REP_NANO_UNEQUIP_SUCC = 822083623,
P_FE2CL_NANO_SKILL_USE_SUCC = 822083627, P_FE2CL_NANO_SKILL_USE_SUCC = 822083627,
P_FE2CL_NANO_SKILL_USE = 822083628, P_FE2CL_NANO_SKILL_USE = 822083628,
P_FE2CL_REP_NANO_TUNE_SUCC = 822083625, P_FE2CL_REP_NANO_TUNE_SUCC = 822083625,
P_FE2CL_REP_PC_ENTER_SUCC = 822083586, P_FE2CL_REP_PC_ENTER_SUCC = 822083586,
P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC = 822083833, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC = 822083833,
P_FE2CL_REP_PC_GOTO_SUCC = 822083633, P_FE2CL_REP_PC_GOTO_SUCC = 822083633,
P_FE2CL_REQ_LIVE_CHECK = 822083792, P_FE2CL_REQ_LIVE_CHECK = 822083792,
P_FE2CL_PC_NEW = 822083587, P_FE2CL_PC_NEW = 822083587,
P_FE2CL_PC_MOVE = 822083592, P_FE2CL_PC_MOVE = 822083592,
P_FE2CL_PC_STOP = 822083593, P_FE2CL_PC_STOP = 822083593,
P_FE2CL_PC_JUMP = 822083594, P_FE2CL_PC_JUMP = 822083594,
P_FE2CL_PC_EXIT = 822083590, P_FE2CL_PC_EXIT = 822083590,
P_FE2CL_PC_JUMPPAD = 822083701, P_FE2CL_PC_JUMPPAD = 822083701,
P_FE2CL_PC_LAUNCHER = 822083702, P_FE2CL_PC_LAUNCHER = 822083702,
P_FE2CL_PC_ZIPLINE = 822083703, P_FE2CL_PC_ZIPLINE = 822083703,
P_FE2CL_PC_MOVEPLATFORM = 822083704, P_FE2CL_PC_MOVEPLATFORM = 822083704,
P_FE2CL_PC_SLOPE = 822083705, P_FE2CL_PC_SLOPE = 822083705,
P_FE2CL_NPC_ENTER = 822083595, P_FE2CL_NPC_ENTER = 822083595,
P_FE2CL_NPC_EXIT = 822083596, P_FE2CL_NPC_EXIT = 822083596,
P_FE2CL_ANNOUNCE_MSG = 822083778, P_FE2CL_ANNOUNCE_MSG = 822083778,
P_FE2CL_GM_REP_PC_SET_VALUE = 822083781, P_FE2CL_GM_REP_PC_SET_VALUE = 822083781,
P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC = 822083602, P_FE2CL_REP_SEND_FREECHAT_MESSAGE_SUCC = 822083602,
P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT = 822083730, P_FE2CL_REP_PC_AVATAR_EMOTES_CHAT = 822083730,
P_FE2CL_PC_ITEM_MOVE_SUCC = 822083610, P_FE2CL_PC_ITEM_MOVE_SUCC = 822083610,
P_FE2CL_PC_EQUIP_CHANGE = 822083611, P_FE2CL_PC_EQUIP_CHANGE = 822083611,
P_FE2CL_REP_PC_ITEM_DELETE_SUCC = 822083641, P_FE2CL_REP_PC_ITEM_DELETE_SUCC = 822083641,
P_FE2CL_REP_PC_GIVE_ITEM_SUCC = 822083681, P_FE2CL_REP_PC_GIVE_ITEM_SUCC = 822083681,
P_FE2CL_REP_PC_EXIT_SUCC = 822083589, P_FE2CL_REP_PC_EXIT_SUCC = 822083589,
P_FE2CL_REP_PC_CHANGE_LEVEL = 822083786, P_FE2CL_REP_PC_CHANGE_LEVEL = 822083786,
P_FE2CL_PC_MOTD_LOGIN = 822083793 P_FE2CL_PC_MOTD_LOGIN = 822083793
}; };
#define REGISTER_SHARD_PACKET(pactype, handlr) CNShardServer::ShardPackets[pactype] = handlr; #define REGISTER_SHARD_PACKET(pactype, handlr) CNShardServer::ShardPackets[pactype] = handlr;
class CNShardServer : public CNServer { class CNShardServer : public CNServer {
private: private:
static void handlePacket(CNSocket* sock, CNPacketData* data); static void handlePacket(CNSocket* sock, CNPacketData* data);
public: public:
static std::map<uint32_t, PacketHandler> ShardPackets; static std::map<uint32_t, PacketHandler> ShardPackets;
CNShardServer(uint16_t p); CNShardServer(uint16_t p);
void killConnection(CNSocket* cns); void killConnection(CNSocket* cns);
void onTimer(); void onTimer();
}; };
#endif #endif

View File

@@ -4,140 +4,140 @@
#include "PlayerManager.hpp" #include "PlayerManager.hpp"
void NanoManager::init() { void NanoManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_ACTIVE, nanoSummonHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_ACTIVE, nanoSummonHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_EQUIP, nanoEquipHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_EQUIP, nanoEquipHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_UNEQUIP, nanoUnEquipHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_UNEQUIP, nanoUnEquipHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO, nanoGMGiveHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GIVE_NANO, nanoGMGiveHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_TUNE, nanoSkillSetHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_TUNE, nanoSkillSetHandler);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_SKILL_USE, nanoSkillUseHandler); REGISTER_SHARD_PACKET(P_CL2FE_REQ_NANO_SKILL_USE, nanoSkillUseHandler);
} }
void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) { void NanoManager::nanoEquipHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_EQUIP)) if (data->size != sizeof(sP_CL2FE_REQ_NANO_EQUIP))
return; // malformed packet return; // malformed packet
sP_CL2FE_REQ_NANO_EQUIP* nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf; sP_CL2FE_REQ_NANO_EQUIP* nano = (sP_CL2FE_REQ_NANO_EQUIP*)data->buf;
sP_FE2CL_REP_NANO_EQUIP_SUCC* resp = (sP_FE2CL_REP_NANO_EQUIP_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC)); sP_FE2CL_REP_NANO_EQUIP_SUCC* resp = (sP_FE2CL_REP_NANO_EQUIP_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC));
resp->iNanoID = nano->iNanoID; resp->iNanoID = nano->iNanoID;
resp->iNanoSlotNum = nano->iNanoSlotNum; resp->iNanoSlotNum = nano->iNanoSlotNum;
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_EQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_EQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_EQUIP_SUCC), sock->getFEKey()));
} }
void NanoManager::nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) { void NanoManager::nanoUnEquipHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_UNEQUIP)) if (data->size != sizeof(sP_CL2FE_REQ_NANO_UNEQUIP))
return; // malformed packet return; // malformed packet
sP_CL2FE_REQ_NANO_UNEQUIP* nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf; sP_CL2FE_REQ_NANO_UNEQUIP* nano = (sP_CL2FE_REQ_NANO_UNEQUIP*)data->buf;
sP_FE2CL_REP_NANO_UNEQUIP_SUCC* resp = (sP_FE2CL_REP_NANO_UNEQUIP_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC)); sP_FE2CL_REP_NANO_UNEQUIP_SUCC* resp = (sP_FE2CL_REP_NANO_UNEQUIP_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC));
resp->iNanoSlotNum = nano->iNanoSlotNum; resp->iNanoSlotNum = nano->iNanoSlotNum;
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_UNEQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_UNEQUIP_SUCC, sizeof(sP_FE2CL_REP_NANO_UNEQUIP_SUCC), sock->getFEKey()));
} }
void NanoManager::nanoGMGiveHandler(CNSocket* sock, CNPacketData* data) { void NanoManager::nanoGMGiveHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GIVE_NANO)) if (data->size != sizeof(sP_CL2FE_REQ_PC_GIVE_NANO))
return; // ignore the malformed packet return; // ignore the malformed packet
// Cmd: /nano <nanoId> // Cmd: /nano <nanoId>
sP_CL2FE_REQ_PC_GIVE_NANO* nano = (sP_CL2FE_REQ_PC_GIVE_NANO*)data->buf; sP_CL2FE_REQ_PC_GIVE_NANO* nano = (sP_CL2FE_REQ_PC_GIVE_NANO*)data->buf;
Player plr = PlayerManager::getPlayer(sock); Player plr = PlayerManager::getPlayer(sock);
// Add nano to player // Add nano to player
addNano(sock, nano->iNanoID, 0); addNano(sock, nano->iNanoID, 0);
std::cout << U16toU8(plr.PCStyle.szFirstName) << U16toU8(plr.PCStyle.szLastName) << " requested to add nano id: " << nano->iNanoID << std::endl; std::cout << U16toU8(plr.PCStyle.szFirstName) << U16toU8(plr.PCStyle.szLastName) << " requested to add nano id: " << nano->iNanoID << std::endl;
} }
void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) { void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_ACTIVE)) if (data->size != sizeof(sP_CL2FE_REQ_NANO_ACTIVE))
return; // malformed packet return; // malformed packet
sP_CL2FE_REQ_NANO_ACTIVE* nano = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf; sP_CL2FE_REQ_NANO_ACTIVE* nano = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
PlayerView plr = PlayerManager::players[sock]; PlayerView plr = PlayerManager::players[sock];
// Send to client // Send to client
sP_FE2CL_REP_NANO_ACTIVE_SUCC* resp = (sP_FE2CL_REP_NANO_ACTIVE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_ACTIVE_SUCC)); 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; 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())); 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; std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << nano->iNanoSlotNum << std::endl;
} }
void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) { void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_SKILL_USE)) if (data->size != sizeof(sP_CL2FE_REQ_NANO_SKILL_USE))
return; // malformed packet return; // malformed packet
sP_CL2FE_REQ_NANO_SKILL_USE* skill = (sP_CL2FE_REQ_NANO_SKILL_USE*)data->buf; sP_CL2FE_REQ_NANO_SKILL_USE* skill = (sP_CL2FE_REQ_NANO_SKILL_USE*)data->buf;
PlayerView plr = PlayerManager::players[sock]; PlayerView plr = PlayerManager::players[sock];
// Send to client // Send to client
sP_FE2CL_NANO_SKILL_USE_SUCC* resp = (sP_FE2CL_NANO_SKILL_USE_SUCC*)xmalloc(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC)); sP_FE2CL_NANO_SKILL_USE_SUCC* resp = (sP_FE2CL_NANO_SKILL_USE_SUCC*)xmalloc(sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC));
resp->iArg1 = skill->iArg1; resp->iArg1 = skill->iArg1;
resp->iArg2 = skill->iArg2; resp->iArg2 = skill->iArg2;
resp->iArg3 = skill->iArg3; resp->iArg3 = skill->iArg3;
resp->iBulletID = skill->iBulletID; resp->iBulletID = skill->iBulletID;
resp->iTargetCnt = skill->iTargetCnt; resp->iTargetCnt = skill->iTargetCnt;
resp->iPC_ID = plr.plr.iID; resp->iPC_ID = plr.plr.iID;
resp->iNanoStamina = 150; // Hardcoded for now resp->iNanoStamina = 150; // Hardcoded for now
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_NANO_SKILL_USE_SUCC, sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_NANO_SKILL_USE_SUCC, sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC), sock->getFEKey()));
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano skill " << std::endl; std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano skill " << std::endl;
} }
void NanoManager::nanoSkillSetHandler(CNSocket* sock, CNPacketData* data) { void NanoManager::nanoSkillSetHandler(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_NANO_TUNE)) if (data->size != sizeof(sP_CL2FE_REQ_NANO_TUNE))
return; // malformed packet return; // malformed packet
sP_CL2FE_REQ_NANO_TUNE* skill = (sP_CL2FE_REQ_NANO_TUNE*)data->buf; sP_CL2FE_REQ_NANO_TUNE* skill = (sP_CL2FE_REQ_NANO_TUNE*)data->buf;
setNanoSkill(sock, skill->iNanoID, skill->iTuneID); setNanoSkill(sock, skill->iNanoID, skill->iTuneID);
} }
#pragma region Helper methods #pragma region Helper methods
void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) { void NanoManager::addNano(CNSocket* sock, int16_t nanoId, int16_t slot) {
Player plr = PlayerManager::getPlayer(sock); Player plr = PlayerManager::getPlayer(sock);
// Send to client // Send to client
sP_FE2CL_REP_PC_NANO_CREATE_SUCC* resp = new sP_FE2CL_REP_PC_NANO_CREATE_SUCC(); sP_FE2CL_REP_PC_NANO_CREATE_SUCC* resp = new sP_FE2CL_REP_PC_NANO_CREATE_SUCC();
resp->Nano.iID = nanoId; resp->Nano.iID = nanoId;
resp->Nano.iStamina = 150; resp->Nano.iStamina = 150;
resp->iQuestItemSlotNum = slot; resp->iQuestItemSlotNum = slot;
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_NANO_CREATE_SUCC, sizeof(sP_FE2CL_REP_PC_NANO_CREATE_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_PC_NANO_CREATE_SUCC, sizeof(sP_FE2CL_REP_PC_NANO_CREATE_SUCC), sock->getFEKey()));
// Update player // Update player
plr.Nanos[nanoId] = resp->Nano; plr.Nanos[nanoId] = resp->Nano;
PlayerManager::updatePlayer(sock, plr); PlayerManager::updatePlayer(sock, plr);
} }
void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId) { void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId) {
Player plr = PlayerManager::getPlayer(sock); Player plr = PlayerManager::getPlayer(sock);
sNano nano = plr.Nanos[nanoId]; sNano nano = plr.Nanos[nanoId];
nano.iSkillID = skillId; nano.iSkillID = skillId;
plr.Nanos[nanoId] = nano; plr.Nanos[nanoId] = nano;
// Send to client // Send to client
sP_FE2CL_REP_NANO_TUNE_SUCC* resp = (sP_FE2CL_REP_NANO_TUNE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC)); sP_FE2CL_REP_NANO_TUNE_SUCC* resp = (sP_FE2CL_REP_NANO_TUNE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC));
resp->iNanoID = nanoId; resp->iNanoID = nanoId;
resp->iSkillID = skillId; resp->iSkillID = skillId;
sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_TUNE_SUCC, sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)resp, P_FE2CL_REP_NANO_TUNE_SUCC, sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC), sock->getFEKey()));
std::cout << U16toU8(plr.PCStyle.szFirstName) << U16toU8(plr.PCStyle.szLastName) << " set skill id " << skillId << " for nano: " << nanoId << std::endl; std::cout << U16toU8(plr.PCStyle.szFirstName) << U16toU8(plr.PCStyle.szLastName) << " set skill id " << skillId << " for nano: " << nanoId << std::endl;
// Update the player // Update the player
PlayerManager::updatePlayer(sock, plr); PlayerManager::updatePlayer(sock, plr);
} }
void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) { void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
Player plr = PlayerManager::getPlayer(sock); Player plr = PlayerManager::getPlayer(sock);
sNano nano = plr.Nanos[nanoId]; sNano nano = plr.Nanos[nanoId];
nano.iSkillID = 0; nano.iSkillID = 0;
plr.Nanos[nanoId] = nano; plr.Nanos[nanoId] = nano;
// Update the player // Update the player
PlayerManager::updatePlayer(sock, plr); PlayerManager::updatePlayer(sock, plr);
} }
#pragma endregion #pragma endregion

View File

@@ -4,18 +4,18 @@
#include "CNShardServer.hpp" #include "CNShardServer.hpp"
namespace NanoManager { namespace NanoManager {
void init(); void init();
void nanoSummonHandler(CNSocket* sock, CNPacketData* data); void nanoSummonHandler(CNSocket* sock, CNPacketData* data);
void nanoEquipHandler(CNSocket* sock, CNPacketData* data); void nanoEquipHandler(CNSocket* sock, CNPacketData* data);
void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data); void nanoUnEquipHandler(CNSocket* sock, CNPacketData* data);
void nanoGMGiveHandler(CNSocket* sock, CNPacketData* data); void nanoGMGiveHandler(CNSocket* sock, CNPacketData* data);
void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data); void nanoSkillUseHandler(CNSocket* sock, CNPacketData* data);
void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data); void nanoSkillSetHandler(CNSocket* sock, CNPacketData* data);
// Helper methods // Helper methods
void addNano(CNSocket* sock, int16_t nanoId, int16_t slot); void addNano(CNSocket* sock, int16_t nanoId, int16_t slot);
void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId); void setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId);
void resetNanoSkill(CNSocket* sock, int16_t nanoId); void resetNanoSkill(CNSocket* sock, int16_t nanoId);
} }
#endif #endif

View File

@@ -13,557 +13,557 @@
std::map<CNSocket*, PlayerView> PlayerManager::players; std::map<CNSocket*, PlayerView> PlayerManager::players;
void PlayerManager::init() { void PlayerManager::init() {
// register packet types // register packet types
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ENTER, PlayerManager::enterPlayer); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_ENTER, PlayerManager::enterPlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_LOADING_COMPLETE, PlayerManager::loadPlayer); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_LOADING_COMPLETE, PlayerManager::loadPlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_MOVE, PlayerManager::movePlayer); 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_STOP, PlayerManager::stopPlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_JUMP, PlayerManager::jumpPlayer); 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_JUMPPAD, PlayerManager::jumppadPlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_LAUNCHER, PlayerManager::launchPlayer); 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_ZIPLINE, PlayerManager::ziplinePlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_MOVEPLATFORM, PlayerManager::movePlatformPlayer); 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_SLOPE, PlayerManager::moveSlopePlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_GOTO, PlayerManager::gotoPlayer); 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_GM_REQ_PC_SET_VALUE, PlayerManager::setSpecialPlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REP_LIVE_CHECK, PlayerManager::heartbeatPlayer); REGISTER_SHARD_PACKET(P_CL2FE_REP_LIVE_CHECK, PlayerManager::heartbeatPlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EXIT, PlayerManager::exitGame); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EXIT, PlayerManager::exitGame);
} }
void PlayerManager::addPlayer(CNSocket* key, Player plr) { void PlayerManager::addPlayer(CNSocket* key, Player plr) {
players[key] = PlayerView(); players[key] = PlayerView();
players[key].viewable = std::list<CNSocket*>(); players[key].viewable = std::list<CNSocket*>();
players[key].plr = plr; players[key].plr = plr;
players[key].lastHeartbeat = 0; players[key].lastHeartbeat = 0;
std::cout << U16toU8(plr.PCStyle.szFirstName) << " " << U16toU8(plr.PCStyle.szLastName) << " has joined!" << std::endl; std::cout << U16toU8(plr.PCStyle.szFirstName) << " " << U16toU8(plr.PCStyle.szLastName) << " has joined!" << std::endl;
std::cout << players.size() << " players" << std::endl; std::cout << players.size() << " players" << std::endl;
} }
void PlayerManager::removePlayer(CNSocket* key) { void PlayerManager::removePlayer(CNSocket* key) {
PlayerView cachedView = players[key]; PlayerView cachedView = players[key];
// if players have them in their viewable lists, remove it // if players have them in their viewable lists, remove it
for (CNSocket* otherSock : players[key].viewable) { for (CNSocket* otherSock : players[key].viewable) {
players[otherSock].viewable.remove(key); // gone players[otherSock].viewable.remove(key); // gone
// now sent PC_EXIT packet // now sent PC_EXIT packet
sP_FE2CL_PC_EXIT* exitPacket = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT)); sP_FE2CL_PC_EXIT* exitPacket = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT));
exitPacket->iID = players[key].plr.iID; exitPacket->iID = players[key].plr.iID;
otherSock->sendPacket(new CNPacketData((void*)exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), otherSock->getFEKey()));
} }
players.erase(key); players.erase(key);
std::cout << U16toU8(cachedView.plr.PCStyle.szFirstName) << U16toU8(cachedView.plr.PCStyle.szLastName) << " has left!" << std::endl; std::cout << U16toU8(cachedView.plr.PCStyle.szFirstName) << U16toU8(cachedView.plr.PCStyle.szLastName) << " has left!" << std::endl;
std::cout << players.size() << " players" << std::endl; std::cout << players.size() << " players" << std::endl;
} }
Player PlayerManager::getPlayer(CNSocket* key) { Player PlayerManager::getPlayer(CNSocket* key) {
return players[key].plr; return players[key].plr;
} }
void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) { void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
players[sock].plr.x = X; players[sock].plr.x = X;
players[sock].plr.y = Y; players[sock].plr.y = Y;
players[sock].plr.z = Z; players[sock].plr.z = Z;
std::vector<CNSocket*> noView; std::vector<CNSocket*> noView;
std::vector<CNSocket*> yesView; std::vector<CNSocket*> yesView;
// TODO: oh god this is sooooo perfomance heavy the more players you have // TODO: oh god this is sooooo perfomance heavy the more players you have
for (auto pair : players) { for (auto pair : players) {
if (pair.first == sock) if (pair.first == sock)
continue; // ignore our own connection continue; // ignore our own connection
int diffX = abs(pair.second.plr.x - X); // the map is like a grid, X and Y are your position on the map, Z is the height. very different from other games... int diffX = abs(pair.second.plr.x - X); // the map is like a grid, X and Y are your position on the map, Z is the height. very different from other games...
int diffY = abs(pair.second.plr.y - Y); int diffY = abs(pair.second.plr.y - Y);
if (diffX < settings::VIEWDISTANCE && diffY < settings::VIEWDISTANCE) { if (diffX < settings::VIEWDISTANCE && diffY < settings::VIEWDISTANCE) {
yesView.push_back(pair.first); yesView.push_back(pair.first);
} }
else { else {
noView.push_back(pair.first); noView.push_back(pair.first);
} }
} }
std::list<CNSocket*>::iterator i = players[sock].viewable.begin(); std::list<CNSocket*>::iterator i = players[sock].viewable.begin();
while (i != players[sock].viewable.end()) { while (i != players[sock].viewable.end()) {
CNSocket* otherSock = *i; CNSocket* otherSock = *i;
if (std::find(noView.begin(), noView.end(), otherSock) != noView.end()) { if (std::find(noView.begin(), noView.end(), otherSock) != noView.end()) {
// sock shouldn't be visible, send PC_EXIT packet & remove them // sock shouldn't be visible, send PC_EXIT packet & remove them
sP_FE2CL_PC_EXIT* exitPacket = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT)); sP_FE2CL_PC_EXIT* exitPacket = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT));
sP_FE2CL_PC_EXIT* exitPacketOther = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT)); sP_FE2CL_PC_EXIT* exitPacketOther = (sP_FE2CL_PC_EXIT*)xmalloc(sizeof(sP_FE2CL_PC_EXIT));
exitPacket->iID = players[sock].plr.iID; exitPacket->iID = players[sock].plr.iID;
exitPacketOther->iID = players[otherSock].plr.iID; exitPacketOther->iID = players[otherSock].plr.iID;
otherSock->sendPacket(new CNPacketData((void*)exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)exitPacket, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), otherSock->getFEKey()));
sock->sendPacket(new CNPacketData((void*)exitPacketOther, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)exitPacketOther, P_FE2CL_PC_EXIT, sizeof(sP_FE2CL_PC_EXIT), sock->getFEKey()));
players[sock].viewable.erase(i++); players[sock].viewable.erase(i++);
players[otherSock].viewable.remove(sock); players[otherSock].viewable.remove(sock);
continue; continue;
} }
++i; ++i;
} }
for (CNSocket* otherSock : yesView) { for (CNSocket* otherSock : yesView) {
if (std::find(players[sock].viewable.begin(), players[sock].viewable.end(), otherSock) == players[sock].viewable.end()) { if (std::find(players[sock].viewable.begin(), players[sock].viewable.end(), otherSock) == players[sock].viewable.end()) {
// this needs to be added to the viewable players, send PC_ENTER // this needs to be added to the viewable players, send PC_ENTER
sP_FE2CL_PC_NEW* newPlayer = (sP_FE2CL_PC_NEW*)xmalloc(sizeof(sP_FE2CL_PC_NEW)); // current connection to other player sP_FE2CL_PC_NEW* newPlayer = (sP_FE2CL_PC_NEW*)xmalloc(sizeof(sP_FE2CL_PC_NEW)); // current connection to other player
sP_FE2CL_PC_NEW* newOtherPlayer = (sP_FE2CL_PC_NEW*)xmalloc(sizeof(sP_FE2CL_PC_NEW)); // other player to current connection sP_FE2CL_PC_NEW* newOtherPlayer = (sP_FE2CL_PC_NEW*)xmalloc(sizeof(sP_FE2CL_PC_NEW)); // other player to current connection
Player otherPlr = players[otherSock].plr; Player otherPlr = players[otherSock].plr;
Player plr = players[sock].plr; Player plr = players[sock].plr;
newPlayer->PCAppearanceData.iID = plr.iID; newPlayer->PCAppearanceData.iID = plr.iID;
newPlayer->PCAppearanceData.iHP = plr.HP; newPlayer->PCAppearanceData.iHP = plr.HP;
newPlayer->PCAppearanceData.iLv = plr.level; newPlayer->PCAppearanceData.iLv = plr.level;
newPlayer->PCAppearanceData.iX = plr.x; newPlayer->PCAppearanceData.iX = plr.x;
newPlayer->PCAppearanceData.iY = plr.y; newPlayer->PCAppearanceData.iY = plr.y;
newPlayer->PCAppearanceData.iZ = plr.z; newPlayer->PCAppearanceData.iZ = plr.z;
newPlayer->PCAppearanceData.iAngle = plr.angle; newPlayer->PCAppearanceData.iAngle = plr.angle;
newPlayer->PCAppearanceData.PCStyle = plr.PCStyle; newPlayer->PCAppearanceData.PCStyle = plr.PCStyle;
memcpy(newPlayer->PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT); memcpy(newPlayer->PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
newOtherPlayer->PCAppearanceData.iID = otherPlr.iID; newOtherPlayer->PCAppearanceData.iID = otherPlr.iID;
newOtherPlayer->PCAppearanceData.iHP = otherPlr.HP; newOtherPlayer->PCAppearanceData.iHP = otherPlr.HP;
newOtherPlayer->PCAppearanceData.iLv = otherPlr.level; newOtherPlayer->PCAppearanceData.iLv = otherPlr.level;
newOtherPlayer->PCAppearanceData.iX = otherPlr.x; newOtherPlayer->PCAppearanceData.iX = otherPlr.x;
newOtherPlayer->PCAppearanceData.iY = otherPlr.y; newOtherPlayer->PCAppearanceData.iY = otherPlr.y;
newOtherPlayer->PCAppearanceData.iZ = otherPlr.z; newOtherPlayer->PCAppearanceData.iZ = otherPlr.z;
newOtherPlayer->PCAppearanceData.iAngle = otherPlr.angle; newOtherPlayer->PCAppearanceData.iAngle = otherPlr.angle;
newOtherPlayer->PCAppearanceData.PCStyle = otherPlr.PCStyle; newOtherPlayer->PCAppearanceData.PCStyle = otherPlr.PCStyle;
memcpy(newOtherPlayer->PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT); memcpy(newOtherPlayer->PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
sock->sendPacket(new CNPacketData((void*)newOtherPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)newOtherPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW), sock->getFEKey()));
otherSock->sendPacket(new CNPacketData((void*)newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW), otherSock->getFEKey()));
players[sock].viewable.push_back(otherSock); players[sock].viewable.push_back(otherSock);
players[otherSock].viewable.push_back(sock); players[otherSock].viewable.push_back(sock);
} }
} }
NPCManager::updatePlayerNPCS(sock, players[sock]); NPCManager::updatePlayerNPCS(sock, players[sock]);
} }
void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_ENTER)) if (data->size != sizeof(sP_CL2FE_REQ_PC_ENTER))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_ENTER* enter = (sP_CL2FE_REQ_PC_ENTER*)data->buf; sP_CL2FE_REQ_PC_ENTER* enter = (sP_CL2FE_REQ_PC_ENTER*)data->buf;
sP_FE2CL_REP_PC_ENTER_SUCC* response = (sP_FE2CL_REP_PC_ENTER_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_ENTER_SUCC)); sP_FE2CL_REP_PC_ENTER_SUCC* response = (sP_FE2CL_REP_PC_ENTER_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_ENTER_SUCC));
sP_FE2CL_PC_MOTD_LOGIN* motd = (sP_FE2CL_PC_MOTD_LOGIN*)xmalloc(sizeof(sP_FE2CL_PC_MOTD_LOGIN)); sP_FE2CL_PC_MOTD_LOGIN* motd = (sP_FE2CL_PC_MOTD_LOGIN*)xmalloc(sizeof(sP_FE2CL_PC_MOTD_LOGIN));
// TODO: check if serialkey exists, if it doesn't send sP_FE2CL_REP_PC_ENTER_FAIL // TODO: check if serialkey exists, if it doesn't send sP_FE2CL_REP_PC_ENTER_FAIL
Player plr = CNSharedData::getPlayer(enter->iEnterSerialKey); Player plr = CNSharedData::getPlayer(enter->iEnterSerialKey);
DEBUGLOG( DEBUGLOG(
std::cout << "P_CL2FE_REQ_PC_ENTER:" << std::endl; std::cout << "P_CL2FE_REQ_PC_ENTER:" << std::endl;
std::cout << "\tID: " << U16toU8(enter->szID) << std::endl; std::cout << "\tID: " << U16toU8(enter->szID) << std::endl;
std::cout << "\tSerial: " << enter->iEnterSerialKey << std::endl; std::cout << "\tSerial: " << enter->iEnterSerialKey << std::endl;
std::cout << "\tTemp: " << enter->iTempValue << std::endl; std::cout << "\tTemp: " << enter->iTempValue << std::endl;
std::cout << "\tPC_UID: " << plr.PCStyle.iPC_UID << std::endl; std::cout << "\tPC_UID: " << plr.PCStyle.iPC_UID << std::endl;
) )
response->iID = rand(); response->iID = rand();
response->uiSvrTime = getTime(); response->uiSvrTime = getTime();
response->PCLoadData2CL.iUserLevel = 1; response->PCLoadData2CL.iUserLevel = 1;
response->PCLoadData2CL.iHP = 1000 * plr.level; response->PCLoadData2CL.iHP = 1000 * plr.level;
response->PCLoadData2CL.iLevel = plr.level; response->PCLoadData2CL.iLevel = plr.level;
response->PCLoadData2CL.iMentor = 1; response->PCLoadData2CL.iMentor = 1;
response->PCLoadData2CL.iMentorCount = 4; response->PCLoadData2CL.iMentorCount = 4;
response->PCLoadData2CL.iMapNum = 0; response->PCLoadData2CL.iMapNum = 0;
response->PCLoadData2CL.iX = plr.x; response->PCLoadData2CL.iX = plr.x;
response->PCLoadData2CL.iY = plr.y; response->PCLoadData2CL.iY = plr.y;
response->PCLoadData2CL.iZ = plr.z; response->PCLoadData2CL.iZ = plr.z;
response->PCLoadData2CL.iActiveNanoSlotNum = -1; response->PCLoadData2CL.iActiveNanoSlotNum = -1;
response->PCLoadData2CL.iFatigue = 50; response->PCLoadData2CL.iFatigue = 50;
response->PCLoadData2CL.PCStyle = plr.PCStyle; response->PCLoadData2CL.PCStyle = plr.PCStyle;
response->PCLoadData2CL.PCStyle2 = plr.PCStyle2; response->PCLoadData2CL.PCStyle2 = plr.PCStyle2;
for (int i = 0; i < AEQUIP_COUNT; i++) for (int i = 0; i < AEQUIP_COUNT; i++)
response->PCLoadData2CL.aEquip[i] = plr.Equip[i]; response->PCLoadData2CL.aEquip[i] = plr.Equip[i];
// protocol-agnostic sItemBase usage // protocol-agnostic sItemBase usage
sItemBase item; sItemBase item;
memset(&item, 0, sizeof(sItemBase)); memset(&item, 0, sizeof(sItemBase));
item.iID = 495; item.iID = 495;
for (int i = 0; i < AINVEN_COUNT; i++) { for (int i = 0; i < AINVEN_COUNT; i++) {
switch (i) { switch (i) {
case 6: case 8: case 11: case 13: case 20: case 6: case 8: case 11: case 13: case 20:
case 24: case 26: case 27: case 28: case 24: case 26: case 27: case 28:
plr.Inven[i] = item; plr.Inven[i] = item;
break; break;
default: default:
memset(&plr.Inven[i], 0, sizeof(sItemBase)); memset(&plr.Inven[i], 0, sizeof(sItemBase));
} }
response->PCLoadData2CL.aInven[i] = plr.Inven[i]; response->PCLoadData2CL.aInven[i] = plr.Inven[i];
} }
// don't ask.. // don't ask..
for (int i = 1; i < 37; i++) { for (int i = 1; i < 37; i++) {
response->PCLoadData2CL.aNanoBank[i].iID = i; response->PCLoadData2CL.aNanoBank[i].iID = i;
response->PCLoadData2CL.aNanoBank[i].iSkillID = 1; response->PCLoadData2CL.aNanoBank[i].iSkillID = 1;
response->PCLoadData2CL.aNanoBank[i].iStamina = 150; response->PCLoadData2CL.aNanoBank[i].iStamina = 150;
} }
//response->PCLoadData2CL.aNanoSlots[0] = 1; //response->PCLoadData2CL.aNanoSlots[0] = 1;
//response->PCLoadData2CL.aNanoSlots[1] = 2; //response->PCLoadData2CL.aNanoSlots[1] = 2;
//response->PCLoadData2CL.aNanoSlots[2] = 3; //response->PCLoadData2CL.aNanoSlots[2] = 3;
response->PCLoadData2CL.aQuestFlag[0] = -1; response->PCLoadData2CL.aQuestFlag[0] = -1;
plr.iID = response->iID; plr.iID = response->iID;
plr.SerialKey = enter->iEnterSerialKey; plr.SerialKey = enter->iEnterSerialKey;
plr.HP = response->PCLoadData2CL.iHP; plr.HP = response->PCLoadData2CL.iHP;
motd->iType = 1; motd->iType = 1;
U8toU16(settings::MOTDSTRING, (char16_t*)motd->szSystemMsg); U8toU16(settings::MOTDSTRING, (char16_t*)motd->szSystemMsg);
sock->setEKey(CNSocketEncryption::createNewKey(response->uiSvrTime, response->iID + 1, response->PCLoadData2CL.iFusionMatter + 1)); sock->setEKey(CNSocketEncryption::createNewKey(response->uiSvrTime, response->iID + 1, response->PCLoadData2CL.iFusionMatter + 1));
sock->setFEKey(plr.FEKey); sock->setFEKey(plr.FEKey);
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_ENTER_SUCC, sizeof(sP_FE2CL_REP_PC_ENTER_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_ENTER_SUCC, sizeof(sP_FE2CL_REP_PC_ENTER_SUCC), sock->getFEKey()));
// transmit MOTD after entering the game, so the client hopefully changes modes on time // transmit MOTD after entering the game, so the client hopefully changes modes on time
sock->sendPacket(new CNPacketData((void*)motd, P_FE2CL_PC_MOTD_LOGIN, sizeof(sP_FE2CL_PC_MOTD_LOGIN), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)motd, P_FE2CL_PC_MOTD_LOGIN, sizeof(sP_FE2CL_PC_MOTD_LOGIN), sock->getFEKey()));
addPlayer(sock, plr); addPlayer(sock, plr);
} }
void PlayerManager::loadPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::loadPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_LOADING_COMPLETE)) if (data->size != sizeof(sP_CL2FE_REQ_PC_LOADING_COMPLETE))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_LOADING_COMPLETE* complete = (sP_CL2FE_REQ_PC_LOADING_COMPLETE*)data->buf; sP_CL2FE_REQ_PC_LOADING_COMPLETE* complete = (sP_CL2FE_REQ_PC_LOADING_COMPLETE*)data->buf;
sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC* response = (sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC)); sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC* response = (sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC));
DEBUGLOG( DEBUGLOG(
std::cout << "P_CL2FE_REQ_PC_LOADING_COMPLETE:" << std::endl; std::cout << "P_CL2FE_REQ_PC_LOADING_COMPLETE:" << std::endl;
std::cout << "\tPC_ID: " << complete->iPC_ID << std::endl; std::cout << "\tPC_ID: " << complete->iPC_ID << std::endl;
) )
response->iPC_ID = complete->iPC_ID; response->iPC_ID = complete->iPC_ID;
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC, sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC, sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC), sock->getFEKey()));
} }
void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::movePlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVE)) if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVE))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_MOVE* moveData = (sP_CL2FE_REQ_PC_MOVE*)data->buf; sP_CL2FE_REQ_PC_MOVE* moveData = (sP_CL2FE_REQ_PC_MOVE*)data->buf;
updatePlayerPosition(sock, moveData->iX, moveData->iY, moveData->iZ); updatePlayerPosition(sock, moveData->iX, moveData->iY, moveData->iZ);
players[sock].plr.angle = moveData->iAngle; players[sock].plr.angle = moveData->iAngle;
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_MOVE* moveResponse = (sP_FE2CL_PC_MOVE*)xmalloc(sizeof(sP_FE2CL_PC_MOVE)); sP_FE2CL_PC_MOVE* moveResponse = (sP_FE2CL_PC_MOVE*)xmalloc(sizeof(sP_FE2CL_PC_MOVE));
moveResponse->iID = players[sock].plr.iID; moveResponse->iID = players[sock].plr.iID;
moveResponse->cKeyValue = moveData->cKeyValue; moveResponse->cKeyValue = moveData->cKeyValue;
moveResponse->iX = moveData->iX; moveResponse->iX = moveData->iX;
moveResponse->iY = moveData->iY; moveResponse->iY = moveData->iY;
moveResponse->iZ = moveData->iZ; moveResponse->iZ = moveData->iZ;
moveResponse->iAngle = moveData->iAngle; moveResponse->iAngle = moveData->iAngle;
moveResponse->fVX = moveData->fVX; moveResponse->fVX = moveData->fVX;
moveResponse->fVY = moveData->fVY; moveResponse->fVY = moveData->fVY;
moveResponse->fVZ = moveData->fVZ; moveResponse->fVZ = moveData->fVZ;
moveResponse->iSpeed = moveData->iSpeed; moveResponse->iSpeed = moveData->iSpeed;
moveResponse->iCliTime = moveData->iCliTime; // maybe don't send this??? seems unneeded... moveResponse->iCliTime = moveData->iCliTime; // maybe don't send this??? seems unneeded...
moveResponse->iSvrTime = tm; moveResponse->iSvrTime = tm;
otherSock->sendPacket(new CNPacketData((void*)moveResponse, P_FE2CL_PC_MOVE, sizeof(sP_FE2CL_PC_MOVE), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)moveResponse, P_FE2CL_PC_MOVE, sizeof(sP_FE2CL_PC_MOVE), otherSock->getFEKey()));
} }
} }
void PlayerManager::stopPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::stopPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_STOP)) if (data->size != sizeof(sP_CL2FE_REQ_PC_STOP))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_STOP* stopData = (sP_CL2FE_REQ_PC_STOP*)data->buf; sP_CL2FE_REQ_PC_STOP* stopData = (sP_CL2FE_REQ_PC_STOP*)data->buf;
updatePlayerPosition(sock, stopData->iX, stopData->iY, stopData->iZ); updatePlayerPosition(sock, stopData->iX, stopData->iY, stopData->iZ);
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_STOP* stopResponse = (sP_FE2CL_PC_STOP*)xmalloc(sizeof(sP_FE2CL_PC_STOP)); sP_FE2CL_PC_STOP* stopResponse = (sP_FE2CL_PC_STOP*)xmalloc(sizeof(sP_FE2CL_PC_STOP));
stopResponse->iID = players[sock].plr.iID; stopResponse->iID = players[sock].plr.iID;
stopResponse->iX = stopData->iX; stopResponse->iX = stopData->iX;
stopResponse->iY = stopData->iY; stopResponse->iY = stopData->iY;
stopResponse->iZ = stopData->iZ; stopResponse->iZ = stopData->iZ;
stopResponse->iCliTime = stopData->iCliTime; // maybe don't send this??? seems unneeded... stopResponse->iCliTime = stopData->iCliTime; // maybe don't send this??? seems unneeded...
stopResponse->iSvrTime = tm; stopResponse->iSvrTime = tm;
otherSock->sendPacket(new CNPacketData((void*)stopResponse, P_FE2CL_PC_STOP, sizeof(sP_FE2CL_PC_STOP), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)stopResponse, P_FE2CL_PC_STOP, sizeof(sP_FE2CL_PC_STOP), otherSock->getFEKey()));
} }
} }
void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::jumpPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_JUMP)) if (data->size != sizeof(sP_CL2FE_REQ_PC_JUMP))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_JUMP* jumpData = (sP_CL2FE_REQ_PC_JUMP*)data->buf; sP_CL2FE_REQ_PC_JUMP* jumpData = (sP_CL2FE_REQ_PC_JUMP*)data->buf;
updatePlayerPosition(sock, jumpData->iX, jumpData->iY, jumpData->iZ); updatePlayerPosition(sock, jumpData->iX, jumpData->iY, jumpData->iZ);
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_JUMP* jumpResponse = (sP_FE2CL_PC_JUMP*)xmalloc(sizeof(sP_FE2CL_PC_JUMP)); sP_FE2CL_PC_JUMP* jumpResponse = (sP_FE2CL_PC_JUMP*)xmalloc(sizeof(sP_FE2CL_PC_JUMP));
jumpResponse->iID = players[sock].plr.iID; jumpResponse->iID = players[sock].plr.iID;
jumpResponse->cKeyValue = jumpData->cKeyValue; jumpResponse->cKeyValue = jumpData->cKeyValue;
jumpResponse->iX = jumpData->iX; jumpResponse->iX = jumpData->iX;
jumpResponse->iY = jumpData->iY; jumpResponse->iY = jumpData->iY;
jumpResponse->iZ = jumpData->iZ; jumpResponse->iZ = jumpData->iZ;
jumpResponse->iAngle = jumpData->iAngle; jumpResponse->iAngle = jumpData->iAngle;
jumpResponse->iVX = jumpData->iVX; jumpResponse->iVX = jumpData->iVX;
jumpResponse->iVY = jumpData->iVY; jumpResponse->iVY = jumpData->iVY;
jumpResponse->iVZ = jumpData->iVZ; jumpResponse->iVZ = jumpData->iVZ;
jumpResponse->iSpeed = jumpData->iSpeed; jumpResponse->iSpeed = jumpData->iSpeed;
jumpResponse->iCliTime = jumpData->iCliTime; // maybe don't send this??? seems unneeded... jumpResponse->iCliTime = jumpData->iCliTime; // maybe don't send this??? seems unneeded...
jumpResponse->iSvrTime = tm; jumpResponse->iSvrTime = tm;
otherSock->sendPacket(new CNPacketData((void*)jumpResponse, P_FE2CL_PC_JUMP, sizeof(sP_FE2CL_PC_JUMP), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)jumpResponse, P_FE2CL_PC_JUMP, sizeof(sP_FE2CL_PC_JUMP), otherSock->getFEKey()));
} }
} }
void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::jumppadPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_JUMPPAD)) if (data->size != sizeof(sP_CL2FE_REQ_PC_JUMPPAD))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_JUMPPAD* jumppadData = (sP_CL2FE_REQ_PC_JUMPPAD*)data->buf; sP_CL2FE_REQ_PC_JUMPPAD* jumppadData = (sP_CL2FE_REQ_PC_JUMPPAD*)data->buf;
updatePlayerPosition(sock, jumppadData->iX, jumppadData->iY, jumppadData->iZ); updatePlayerPosition(sock, jumppadData->iX, jumppadData->iY, jumppadData->iZ);
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_JUMPPAD* jumppadResponse = (sP_FE2CL_PC_JUMPPAD*)xmalloc(sizeof(sP_FE2CL_PC_JUMPPAD)); sP_FE2CL_PC_JUMPPAD* jumppadResponse = (sP_FE2CL_PC_JUMPPAD*)xmalloc(sizeof(sP_FE2CL_PC_JUMPPAD));
jumppadResponse->iPC_ID = players[sock].plr.iID; jumppadResponse->iPC_ID = players[sock].plr.iID;
jumppadResponse->cKeyValue = jumppadData->cKeyValue; jumppadResponse->cKeyValue = jumppadData->cKeyValue;
jumppadResponse->iX = jumppadData->iX; jumppadResponse->iX = jumppadData->iX;
jumppadResponse->iY = jumppadData->iY; jumppadResponse->iY = jumppadData->iY;
jumppadResponse->iZ = jumppadData->iZ; jumppadResponse->iZ = jumppadData->iZ;
jumppadResponse->iVX = jumppadData->iVX; jumppadResponse->iVX = jumppadData->iVX;
jumppadResponse->iVY = jumppadData->iVY; jumppadResponse->iVY = jumppadData->iVY;
jumppadResponse->iVZ = jumppadData->iVZ; jumppadResponse->iVZ = jumppadData->iVZ;
jumppadResponse->iCliTime = jumppadData->iCliTime; jumppadResponse->iCliTime = jumppadData->iCliTime;
jumppadResponse->iSvrTime = tm; jumppadResponse->iSvrTime = tm;
otherSock->sendPacket(new CNPacketData((void*)jumppadResponse, P_FE2CL_PC_JUMPPAD, sizeof(sP_FE2CL_PC_JUMPPAD), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)jumppadResponse, P_FE2CL_PC_JUMPPAD, sizeof(sP_FE2CL_PC_JUMPPAD), otherSock->getFEKey()));
} }
} }
void PlayerManager::launchPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::launchPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_LAUNCHER)) if (data->size != sizeof(sP_CL2FE_REQ_PC_LAUNCHER))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_LAUNCHER* launchData = (sP_CL2FE_REQ_PC_LAUNCHER*)data->buf; sP_CL2FE_REQ_PC_LAUNCHER* launchData = (sP_CL2FE_REQ_PC_LAUNCHER*)data->buf;
updatePlayerPosition(sock, launchData->iX, launchData->iY, launchData->iZ); updatePlayerPosition(sock, launchData->iX, launchData->iY, launchData->iZ);
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_LAUNCHER* launchResponse = (sP_FE2CL_PC_LAUNCHER*)xmalloc(sizeof(sP_FE2CL_PC_LAUNCHER)); sP_FE2CL_PC_LAUNCHER* launchResponse = (sP_FE2CL_PC_LAUNCHER*)xmalloc(sizeof(sP_FE2CL_PC_LAUNCHER));
launchResponse->iPC_ID = players[sock].plr.iID; launchResponse->iPC_ID = players[sock].plr.iID;
launchResponse->iX = launchData->iX; launchResponse->iX = launchData->iX;
launchResponse->iY = launchData->iY; launchResponse->iY = launchData->iY;
launchResponse->iZ = launchData->iZ; launchResponse->iZ = launchData->iZ;
launchResponse->iVX = launchData->iVX; launchResponse->iVX = launchData->iVX;
launchResponse->iVY = launchData->iVY; launchResponse->iVY = launchData->iVY;
launchResponse->iVZ = launchData->iVZ; launchResponse->iVZ = launchData->iVZ;
launchResponse->iSpeed = launchData->iSpeed; launchResponse->iSpeed = launchData->iSpeed;
launchResponse->iAngle = launchData->iAngle; launchResponse->iAngle = launchData->iAngle;
launchResponse->iCliTime = launchData->iCliTime; launchResponse->iCliTime = launchData->iCliTime;
launchResponse->iSvrTime = tm; launchResponse->iSvrTime = tm;
otherSock->sendPacket(new CNPacketData((void*)launchResponse, P_FE2CL_PC_LAUNCHER, sizeof(sP_FE2CL_PC_LAUNCHER), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)launchResponse, P_FE2CL_PC_LAUNCHER, sizeof(sP_FE2CL_PC_LAUNCHER), otherSock->getFEKey()));
} }
} }
void PlayerManager::ziplinePlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::ziplinePlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_ZIPLINE)) if (data->size != sizeof(sP_CL2FE_REQ_PC_ZIPLINE))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_ZIPLINE* ziplineData = (sP_CL2FE_REQ_PC_ZIPLINE*)data->buf; sP_CL2FE_REQ_PC_ZIPLINE* ziplineData = (sP_CL2FE_REQ_PC_ZIPLINE*)data->buf;
updatePlayerPosition(sock, ziplineData->iX, ziplineData->iY, ziplineData->iZ); updatePlayerPosition(sock, ziplineData->iX, ziplineData->iY, ziplineData->iZ);
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_ZIPLINE* ziplineResponse = (sP_FE2CL_PC_ZIPLINE*)xmalloc(sizeof(sP_FE2CL_PC_ZIPLINE)); sP_FE2CL_PC_ZIPLINE* ziplineResponse = (sP_FE2CL_PC_ZIPLINE*)xmalloc(sizeof(sP_FE2CL_PC_ZIPLINE));
ziplineResponse->iPC_ID = players[sock].plr.iID; ziplineResponse->iPC_ID = players[sock].plr.iID;
ziplineResponse->iCliTime = ziplineData->iCliTime; ziplineResponse->iCliTime = ziplineData->iCliTime;
ziplineResponse->iSvrTime = tm; ziplineResponse->iSvrTime = tm;
ziplineResponse->iX = ziplineData->iX; ziplineResponse->iX = ziplineData->iX;
ziplineResponse->iY = ziplineData->iY; ziplineResponse->iY = ziplineData->iY;
ziplineResponse->iZ = ziplineData->iZ; ziplineResponse->iZ = ziplineData->iZ;
ziplineResponse->fVX = ziplineData->fVX; ziplineResponse->fVX = ziplineData->fVX;
ziplineResponse->fVY = ziplineData->fVY; ziplineResponse->fVY = ziplineData->fVY;
ziplineResponse->fVZ = ziplineData->fVZ; ziplineResponse->fVZ = ziplineData->fVZ;
ziplineResponse->fMovDistance = ziplineData->fMovDistance; ziplineResponse->fMovDistance = ziplineData->fMovDistance;
ziplineResponse->fMaxDistance = ziplineData->fMaxDistance; ziplineResponse->fMaxDistance = ziplineData->fMaxDistance;
ziplineResponse->fDummy = ziplineData->fDummy; //wtf is this for? ziplineResponse->fDummy = ziplineData->fDummy; //wtf is this for?
ziplineResponse->iStX = ziplineData->iStX; ziplineResponse->iStX = ziplineData->iStX;
ziplineResponse->iStY = ziplineData->iStY; ziplineResponse->iStY = ziplineData->iStY;
ziplineResponse->iStZ = ziplineData->iStZ; ziplineResponse->iStZ = ziplineData->iStZ;
ziplineResponse->bDown = ziplineData->bDown; ziplineResponse->bDown = ziplineData->bDown;
ziplineResponse->iSpeed = ziplineData->iSpeed; ziplineResponse->iSpeed = ziplineData->iSpeed;
ziplineResponse->iAngle = ziplineData->iAngle; ziplineResponse->iAngle = ziplineData->iAngle;
ziplineResponse->iRollMax = ziplineData->iRollMax; ziplineResponse->iRollMax = ziplineData->iRollMax;
ziplineResponse->iRoll = ziplineData->iRoll; ziplineResponse->iRoll = ziplineData->iRoll;
otherSock->sendPacket(new CNPacketData((void*)ziplineResponse, P_FE2CL_PC_ZIPLINE, sizeof(sP_FE2CL_PC_ZIPLINE), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)ziplineResponse, P_FE2CL_PC_ZIPLINE, sizeof(sP_FE2CL_PC_ZIPLINE), otherSock->getFEKey()));
} }
} }
void PlayerManager::movePlatformPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::movePlatformPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVEPLATFORM)) if (data->size != sizeof(sP_CL2FE_REQ_PC_MOVEPLATFORM))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_MOVEPLATFORM* platformData = (sP_CL2FE_REQ_PC_MOVEPLATFORM*)data->buf; sP_CL2FE_REQ_PC_MOVEPLATFORM* platformData = (sP_CL2FE_REQ_PC_MOVEPLATFORM*)data->buf;
updatePlayerPosition(sock, platformData->iX, platformData->iY, platformData->iZ); updatePlayerPosition(sock, platformData->iX, platformData->iY, platformData->iZ);
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_MOVEPLATFORM* platResponse = (sP_FE2CL_PC_MOVEPLATFORM*)xmalloc(sizeof(sP_FE2CL_PC_MOVEPLATFORM)); sP_FE2CL_PC_MOVEPLATFORM* platResponse = (sP_FE2CL_PC_MOVEPLATFORM*)xmalloc(sizeof(sP_FE2CL_PC_MOVEPLATFORM));
platResponse->iPC_ID = players[sock].plr.iID; platResponse->iPC_ID = players[sock].plr.iID;
platResponse->iCliTime = platformData->iCliTime; platResponse->iCliTime = platformData->iCliTime;
platResponse->iSvrTime = tm; platResponse->iSvrTime = tm;
platResponse->iX = platformData->iX; platResponse->iX = platformData->iX;
platResponse->iY = platformData->iY; platResponse->iY = platformData->iY;
platResponse->iZ = platformData->iZ; platResponse->iZ = platformData->iZ;
platResponse->iAngle = platformData->iAngle; platResponse->iAngle = platformData->iAngle;
platResponse->fVX = platformData->fVX; platResponse->fVX = platformData->fVX;
platResponse->fVY = platformData->fVY; platResponse->fVY = platformData->fVY;
platResponse->fVZ = platformData->fVZ; platResponse->fVZ = platformData->fVZ;
platResponse->iLcX = platformData->iLcX; platResponse->iLcX = platformData->iLcX;
platResponse->iLcY = platformData->iLcY; platResponse->iLcY = platformData->iLcY;
platResponse->iLcZ = platformData->iLcZ; platResponse->iLcZ = platformData->iLcZ;
platResponse->iSpeed = platformData->iSpeed; platResponse->iSpeed = platformData->iSpeed;
platResponse->bDown = platformData->bDown; platResponse->bDown = platformData->bDown;
platResponse->cKeyValue = platformData->cKeyValue; platResponse->cKeyValue = platformData->cKeyValue;
platResponse->iPlatformID = platformData->iPlatformID; platResponse->iPlatformID = platformData->iPlatformID;
otherSock->sendPacket(new CNPacketData((void*)platResponse, P_FE2CL_PC_MOVEPLATFORM, sizeof(sP_FE2CL_PC_MOVEPLATFORM), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)platResponse, P_FE2CL_PC_MOVEPLATFORM, sizeof(sP_FE2CL_PC_MOVEPLATFORM), otherSock->getFEKey()));
} }
} }
void PlayerManager::moveSlopePlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::moveSlopePlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_SLOPE)) if (data->size != sizeof(sP_CL2FE_REQ_PC_SLOPE))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_SLOPE* slopeData = (sP_CL2FE_REQ_PC_SLOPE*)data->buf; sP_CL2FE_REQ_PC_SLOPE* slopeData = (sP_CL2FE_REQ_PC_SLOPE*)data->buf;
updatePlayerPosition(sock, slopeData->iX, slopeData->iY, slopeData->iZ); updatePlayerPosition(sock, slopeData->iX, slopeData->iY, slopeData->iZ);
uint64_t tm = getTime(); uint64_t tm = getTime();
for (CNSocket* otherSock : players[sock].viewable) { for (CNSocket* otherSock : players[sock].viewable) {
sP_FE2CL_PC_SLOPE* slopeResponse = (sP_FE2CL_PC_SLOPE*)xmalloc(sizeof(sP_FE2CL_PC_SLOPE)); sP_FE2CL_PC_SLOPE* slopeResponse = (sP_FE2CL_PC_SLOPE*)xmalloc(sizeof(sP_FE2CL_PC_SLOPE));
slopeResponse->iPC_ID = players[sock].plr.iID; slopeResponse->iPC_ID = players[sock].plr.iID;
slopeResponse->iCliTime = slopeData->iCliTime; slopeResponse->iCliTime = slopeData->iCliTime;
slopeResponse->iSvrTime = tm; slopeResponse->iSvrTime = tm;
slopeResponse->iX = slopeData->iX; slopeResponse->iX = slopeData->iX;
slopeResponse->iY = slopeData->iY; slopeResponse->iY = slopeData->iY;
slopeResponse->iZ = slopeData->iZ; slopeResponse->iZ = slopeData->iZ;
slopeResponse->iAngle = slopeData->iAngle; slopeResponse->iAngle = slopeData->iAngle;
slopeResponse->fVX = slopeData->fVX; slopeResponse->fVX = slopeData->fVX;
slopeResponse->fVY = slopeData->fVY; slopeResponse->fVY = slopeData->fVY;
slopeResponse->fVZ = slopeData->fVZ; slopeResponse->fVZ = slopeData->fVZ;
slopeResponse->iSpeed = slopeData->iSpeed; slopeResponse->iSpeed = slopeData->iSpeed;
slopeResponse->cKeyValue = slopeData->cKeyValue; slopeResponse->cKeyValue = slopeData->cKeyValue;
slopeResponse->iSlopeID = slopeData->iSlopeID; slopeResponse->iSlopeID = slopeData->iSlopeID;
otherSock->sendPacket(new CNPacketData((void*)slopeResponse, P_FE2CL_PC_SLOPE, sizeof(sP_FE2CL_PC_SLOPE), otherSock->getFEKey())); otherSock->sendPacket(new CNPacketData((void*)slopeResponse, P_FE2CL_PC_SLOPE, sizeof(sP_FE2CL_PC_SLOPE), otherSock->getFEKey()));
} }
} }
void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_GOTO)) if (data->size != sizeof(sP_CL2FE_REQ_PC_GOTO))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_REQ_PC_GOTO* gotoData = (sP_CL2FE_REQ_PC_GOTO*)data->buf; sP_CL2FE_REQ_PC_GOTO* gotoData = (sP_CL2FE_REQ_PC_GOTO*)data->buf;
sP_FE2CL_REP_PC_GOTO_SUCC* response = (sP_FE2CL_REP_PC_GOTO_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_GOTO_SUCC)); sP_FE2CL_REP_PC_GOTO_SUCC* response = (sP_FE2CL_REP_PC_GOTO_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_GOTO_SUCC));
DEBUGLOG( DEBUGLOG(
std::cout << "P_CL2FE_REQ_PC_GOTO:" << std::endl; std::cout << "P_CL2FE_REQ_PC_GOTO:" << std::endl;
std::cout << "\tX: " << gotoData->iToX << std::endl; std::cout << "\tX: " << gotoData->iToX << std::endl;
std::cout << "\tY: " << gotoData->iToY << std::endl; std::cout << "\tY: " << gotoData->iToY << std::endl;
std::cout << "\tZ: " << gotoData->iToZ << std::endl; std::cout << "\tZ: " << gotoData->iToZ << std::endl;
) )
response->iX = gotoData->iToX; response->iX = gotoData->iToX;
response->iY = gotoData->iToY; response->iY = gotoData->iToY;
response->iZ = gotoData->iToZ; response->iZ = gotoData->iToZ;
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_GOTO_SUCC, sizeof(sP_FE2CL_REP_PC_GOTO_SUCC), sock->getFEKey()));
} }
void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_GM_REQ_PC_SET_VALUE)) if (data->size != sizeof(sP_CL2FE_GM_REQ_PC_SET_VALUE))
return; // ignore the malformed packet return; // ignore the malformed packet
sP_CL2FE_GM_REQ_PC_SET_VALUE* setData = (sP_CL2FE_GM_REQ_PC_SET_VALUE*)data->buf; sP_CL2FE_GM_REQ_PC_SET_VALUE* setData = (sP_CL2FE_GM_REQ_PC_SET_VALUE*)data->buf;
sP_FE2CL_GM_REP_PC_SET_VALUE* response = (sP_FE2CL_GM_REP_PC_SET_VALUE*)xmalloc(sizeof(sP_FE2CL_GM_REP_PC_SET_VALUE)); sP_FE2CL_GM_REP_PC_SET_VALUE* response = (sP_FE2CL_GM_REP_PC_SET_VALUE*)xmalloc(sizeof(sP_FE2CL_GM_REP_PC_SET_VALUE));
DEBUGLOG( DEBUGLOG(
std::cout << "P_CL2FE_GM_REQ_PC_SET_VALUE:" << std::endl; std::cout << "P_CL2FE_GM_REQ_PC_SET_VALUE:" << std::endl;
std::cout << "\tPC_ID: " << setData->iPC_ID << std::endl; std::cout << "\tPC_ID: " << setData->iPC_ID << std::endl;
std::cout << "\tSetValueType: " << setData->iSetValueType << std::endl; std::cout << "\tSetValueType: " << setData->iSetValueType << std::endl;
std::cout << "\tSetValue: " << setData->iSetValue << std::endl; std::cout << "\tSetValue: " << setData->iSetValue << std::endl;
) )
response->iPC_ID = setData->iPC_ID; response->iPC_ID = setData->iPC_ID;
response->iSetValue = setData->iSetValue; response->iSetValue = setData->iSetValue;
response->iSetValueType = setData->iSetValueType; response->iSetValueType = setData->iSetValueType;
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_GM_REP_PC_SET_VALUE, sizeof(sP_FE2CL_GM_REP_PC_SET_VALUE), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_GM_REP_PC_SET_VALUE, sizeof(sP_FE2CL_GM_REP_PC_SET_VALUE), sock->getFEKey()));
} }
void PlayerManager::heartbeatPlayer(CNSocket* sock, CNPacketData* data) { void PlayerManager::heartbeatPlayer(CNSocket* sock, CNPacketData* data) {
players[sock].lastHeartbeat = getTime(); players[sock].lastHeartbeat = getTime();
} }
void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) { void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_PC_EXIT* exitData = (sP_CL2FE_REQ_PC_EXIT*)data->buf; sP_CL2FE_REQ_PC_EXIT* exitData = (sP_CL2FE_REQ_PC_EXIT*)data->buf;
sP_FE2CL_REP_PC_EXIT_SUCC* response = (sP_FE2CL_REP_PC_EXIT_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_EXIT_SUCC)); sP_FE2CL_REP_PC_EXIT_SUCC* response = (sP_FE2CL_REP_PC_EXIT_SUCC*)xmalloc(sizeof(sP_FE2CL_REP_PC_EXIT_SUCC));
response->iID = exitData->iID; response->iID = exitData->iID;
response->iExitCode = 1; response->iExitCode = 1;
sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC), sock->getFEKey())); sock->sendPacket(new CNPacketData((void*)response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC), sock->getFEKey()));
} }
void PlayerManager::updatePlayer(CNSocket* key, Player plr) { void PlayerManager::updatePlayer(CNSocket* key, Player plr) {
PlayerView plrv = players[key]; PlayerView plrv = players[key];
plrv.plr = plr; plrv.plr = plr;
players[key] = plrv; players[key] = plrv;
} }