Add player revive, vehicle mount/dismount and more (#33)

This commit is contained in:
Onii-chan 2020-08-24 23:04:56 +02:00 committed by GitHub
parent 28ad1a0c25
commit afbf309c7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 198 additions and 37 deletions

View File

@ -25,6 +25,7 @@ SRC=\
src/CNStructs.cpp\ src/CNStructs.cpp\
src/Defines.cpp\ src/Defines.cpp\
src/main.cpp\ src/main.cpp\
src/MissionManager.cpp\
src/NanoManager.cpp\ src/NanoManager.cpp\
src/ItemManager.cpp\ src/ItemManager.cpp\
src/NPCManager.cpp\ src/NPCManager.cpp\
@ -43,6 +44,7 @@ HDR=\
src/Defines.hpp\ src/Defines.hpp\
src/contrib/INIReader.hpp\ src/contrib/INIReader.hpp\
src/contrib/JSON.hpp\ src/contrib/JSON.hpp\
src/MissionManager.hpp\
src/NanoManager.hpp\ src/NanoManager.hpp\
src/ItemManager.hpp\ src/ItemManager.hpp\
src/NPCManager.hpp\ src/NPCManager.hpp\

View File

@ -100,3 +100,13 @@ To make your landwalking experience more pleasant, you can make use of a few adm
* A `/jump` of about 50 will send you soaring * A `/jump` of about 50 will send you soaring
* [This map](res/dong_number_map.png) (credit to Danny O) is useful for `/warp` coordinates. * [This map](res/dong_number_map.png) (credit to Danny O) is useful for `/warp` coordinates.
* `/goto` is useful for more precise teleportation (ie. for getting into Infected Zones, etc.). * `/goto` is useful for more precise teleportation (ie. for getting into Infected Zones, etc.).
### Item commands
* /itemN [type] [itemId] [amount]
(Refer to the [item list](https://docs.google.com/spreadsheets/d/1mpoJ9iTHl_xLI4wQ_9UvIDYNcsDYscdkyaGizs43TCg/))
### Nano commands
* /nano [id] (1-36)
* /nano_equip [id] (1-36) [slot] (0-2)
* /nano_unequip [slot] (0-2)
* /nano_active [slot] (0-2)

55
src/MissionManager.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "CNShardServer.hpp"
#include "CNStructs.hpp"
#include "MissionManager.hpp"
#include "PlayerManager.hpp"
void MissionManager::init() {
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TASK_START, acceptMission);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TASK_END, completeMission);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID, setMission);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_TASK_STOP, quitMission);
}
void MissionManager::acceptMission(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TASK_START))
return; // malformed packet
sP_CL2FE_REQ_PC_TASK_START* missionData = (sP_CL2FE_REQ_PC_TASK_START*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_TASK_START_SUCC, response);
response.iTaskNum = missionData->iTaskNum;
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_START_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_START_SUCC));
}
void MissionManager::completeMission(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TASK_END))
return; // malformed packet
sP_CL2FE_REQ_PC_TASK_END* missionData = (sP_CL2FE_REQ_PC_TASK_END*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_TASK_END_SUCC, response);
response.iTaskNum = missionData->iTaskNum;
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_END_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_END_SUCC));
}
void MissionManager::setMission(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID))
return; // malformed packet
sP_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID* missionData = (sP_CL2FE_REQ_PC_SET_CURRENT_MISSION_ID*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_SET_CURRENT_MISSION_ID, response);
response.iCurrentMissionID = missionData->iCurrentMissionID;
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_SET_CURRENT_MISSION_ID, sizeof(sP_FE2CL_REP_PC_SET_CURRENT_MISSION_ID));
}
void MissionManager::quitMission(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_TASK_STOP))
return; // malformed packet
sP_CL2FE_REQ_PC_TASK_STOP* missionData = (sP_CL2FE_REQ_PC_TASK_STOP*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_TASK_STOP_SUCC, response);
response.iTaskNum = missionData->iTaskNum;
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_STOP_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_STOP_SUCC));
}

12
src/MissionManager.hpp Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "CNShardServer.hpp"
namespace MissionManager {
void init();
void acceptMission(CNSocket* sock, CNPacketData* data);
void completeMission(CNSocket* sock, CNPacketData* data);
void setMission(CNSocket* sock, CNPacketData* data);
void quitMission(CNSocket* sock, CNPacketData* data);
}

View File

@ -75,7 +75,7 @@ void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
return; // malformed packet return; // malformed packet
sP_CL2FE_REQ_NANO_ACTIVE* pkt = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf; sP_CL2FE_REQ_NANO_ACTIVE* pkt = (sP_CL2FE_REQ_NANO_ACTIVE*)data->buf;
PlayerView plr = PlayerManager::players[sock]; Player plr = PlayerManager::getPlayer(sock);
// Send to client // Send to client
INITSTRUCT(sP_FE2CL_REP_NANO_ACTIVE_SUCC, resp); INITSTRUCT(sP_FE2CL_REP_NANO_ACTIVE_SUCC, resp);
@ -85,28 +85,28 @@ void NanoManager::nanoSummonHandler(CNSocket* sock, CNPacketData* data) {
if (pkt->iNanoSlotNum > 2) if (pkt->iNanoSlotNum > 2)
return; return;
int nanoId = plr.plr.equippedNanos[pkt->iNanoSlotNum]; int nanoId = plr.equippedNanos[pkt->iNanoSlotNum];
if (nanoId > 36) if (nanoId > 36)
return; // sanity check return; // sanity check
sNano nano = plr.plr.Nanos[nanoId]; sNano nano = plr.Nanos[nanoId];
// Send to other players // Send to other players
INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1); INITSTRUCT(sP_FE2CL_NANO_ACTIVE, pkt1);
pkt1.iPC_ID = plr.plr.iID; pkt1.iPC_ID = plr.iID;
pkt1.Nano = nano; pkt1.Nano = nano;
for (CNSocket *s : PlayerManager::players[sock].viewable) for (CNSocket* s : PlayerManager::players[sock].viewable)
s->sendPacket((void*)&pkt1, P_FE2CL_NANO_ACTIVE, sizeof(sP_FE2CL_NANO_ACTIVE)); s->sendPacket((void*)&pkt1, P_FE2CL_NANO_ACTIVE, sizeof(sP_FE2CL_NANO_ACTIVE));
// update player // update player
plr.plr.nano = nanoId; plr.activeNano = nanoId;
PlayerManager::updatePlayer(sock, plr.plr); PlayerManager::updatePlayer(sock, plr);
DEBUGLOG( DEBUGLOG(
std::cout << U16toU8(plr.plr.PCStyle.szFirstName) << U16toU8(plr.plr.PCStyle.szLastName) << " requested to summon nano slot: " << pkt->iNanoSlotNum << std::endl; std::cout << U16toU8(plr.PCStyle.szFirstName) << U16toU8(plr.PCStyle.szLastName) << " requested to summon nano slot: " << pkt->iNanoSlotNum << std::endl;
) )
} }
@ -115,7 +115,7 @@ void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
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]; Player plr = PlayerManager::getPlayer(sock);
// Send to client // Send to client
INITSTRUCT(sP_FE2CL_NANO_SKILL_USE_SUCC, resp); INITSTRUCT(sP_FE2CL_NANO_SKILL_USE_SUCC, resp);
@ -124,14 +124,10 @@ void NanoManager::nanoSkillUseHandler(CNSocket* sock, CNPacketData* data) {
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.iID;
resp.iNanoStamina = 150; // Hardcoded for now resp.iNanoStamina = 150; // Hardcoded for now
sock->sendPacket((void*)&resp, P_FE2CL_NANO_SKILL_USE_SUCC, sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC)); sock->sendPacket((void*)&resp, P_FE2CL_NANO_SKILL_USE_SUCC, sizeof(sP_FE2CL_NANO_SKILL_USE_SUCC));
DEBUGLOG(
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) {
@ -179,21 +175,23 @@ void NanoManager::setNanoSkill(CNSocket* sock, int16_t nanoId, int16_t skillId)
sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_TUNE_SUCC, sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC)); sock->sendPacket((void*)&resp, P_FE2CL_REP_NANO_TUNE_SUCC, sizeof(sP_FE2CL_REP_NANO_TUNE_SUCC));
// Update the player
PlayerManager::updatePlayer(sock, plr);
DEBUGLOG( DEBUGLOG(
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
PlayerManager::updatePlayer(sock, plr);
} }
void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) { void NanoManager::resetNanoSkill(CNSocket* sock, int16_t nanoId) {
if (nanoId > 36) if (nanoId > 36)
return; return;
Player plr = PlayerManager::getPlayer(sock); Player plr = PlayerManager::getPlayer(sock);
sNano nano = plr.Nanos[nanoId]; sNano nano = plr.Nanos[nanoId];
// 0 is reset
nano.iSkillID = 0; nano.iSkillID = 0;
plr.Nanos[nanoId] = nano; plr.Nanos[nanoId] = nano;

View File

@ -17,9 +17,10 @@ struct Player {
int slot; // player slot, not nano slot int slot; // player slot, not nano slot
sPCStyle PCStyle; sPCStyle PCStyle;
sPCStyle2 PCStyle2; sPCStyle2 PCStyle2;
sNano Nanos[37]; sNano Nanos[37]; // acquired nanos
int equippedNanos[3]; int equippedNanos[3];
int nano; // active nano (index into Nanos) int activeNano; // active nano (index into Nanos)
int8_t iPCState;
int x, y, z, angle; int x, y, z, angle;
sItemBase Equip[AEQUIP_COUNT]; sItemBase Equip[AEQUIP_COUNT];

View File

@ -27,7 +27,12 @@ void PlayerManager::init() {
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_REGEN, PlayerManager::revivePlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EXIT, PlayerManager::exitGame); REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_EXIT, PlayerManager::exitGame);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_SPECIAL_STATE_SWITCH, PlayerManager::setSpecialSwitchPlayer);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VEHICLE_ON, PlayerManager::enterPlayerVehicle);
REGISTER_SHARD_PACKET(P_CL2FE_REQ_PC_VEHICLE_OFF, PlayerManager::exitPlayerVehicle);
} }
void PlayerManager::addPlayer(CNSocket* key, Player plr) { void PlayerManager::addPlayer(CNSocket* key, Player plr) {
@ -60,10 +65,6 @@ void PlayerManager::removePlayer(CNSocket* key) {
std::cout << players.size() << " players" << std::endl; std::cout << players.size() << " players" << std::endl;
} }
Player PlayerManager::getPlayer(CNSocket* key) {
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;
@ -125,7 +126,8 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
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;
newPlayer.PCAppearanceData.Nano = plr.Nanos[plr.nano]; newPlayer.PCAppearanceData.Nano = plr.Nanos[plr.activeNano];
newPlayer.PCAppearanceData.iPCState = plr.iPCState;
memcpy(newPlayer.PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT); memcpy(newPlayer.PCAppearanceData.ItemEquip, plr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
otherSock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW)); otherSock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
@ -138,7 +140,8 @@ void PlayerManager::updatePlayerPosition(CNSocket* sock, int X, int Y, int Z) {
newPlayer.PCAppearanceData.iZ = otherPlr.z; newPlayer.PCAppearanceData.iZ = otherPlr.z;
newPlayer.PCAppearanceData.iAngle = otherPlr.angle; newPlayer.PCAppearanceData.iAngle = otherPlr.angle;
newPlayer.PCAppearanceData.PCStyle = otherPlr.PCStyle; newPlayer.PCAppearanceData.PCStyle = otherPlr.PCStyle;
newPlayer.PCAppearanceData.Nano = otherPlr.Nanos[otherPlr.nano]; newPlayer.PCAppearanceData.Nano = otherPlr.Nanos[otherPlr.activeNano];
newPlayer.PCAppearanceData.iPCState = otherPlr.iPCState;
memcpy(newPlayer.PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT); memcpy(newPlayer.PCAppearanceData.ItemEquip, otherPlr.Equip, sizeof(sItemBase) * AEQUIP_COUNT);
sock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW)); sock->sendPacket((void*)&newPlayer, P_FE2CL_PC_NEW, sizeof(sP_FE2CL_PC_NEW));
@ -184,7 +187,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
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 = 3625; //TODO: Check player levelupdata and get this right response.PCLoadData2CL.iHP = 3625; //TODO: Check player levelupdata and get this right
@ -203,7 +206,7 @@ void PlayerManager::enterPlayer(CNSocket* sock, CNPacketData* data) {
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];
for (int i = 0; i < AINVEN_COUNT; i++) for (int i = 0; i < AINVEN_COUNT; i++)
response.PCLoadData2CL.aInven[i] = plr.Inven[i]; response.PCLoadData2CL.aInven[i] = plr.Inven[i];
// don't ask.. // don't ask..
@ -251,7 +254,7 @@ void PlayerManager::loadPlayer(CNSocket* sock, CNPacketData* data) {
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((void*)&response, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC, sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC)); sock->sendPacket((void*)&response, P_FE2CL_REP_PC_LOADING_COMPLETE_SUCC, sizeof(sP_FE2CL_REP_PC_LOADING_COMPLETE_SUCC));
} }
@ -518,7 +521,7 @@ void PlayerManager::gotoPlayer(CNSocket* sock, CNPacketData* data) {
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;
@ -539,7 +542,7 @@ void PlayerManager::setSpecialPlayer(CNSocket* sock, CNPacketData* data) {
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;
@ -553,7 +556,7 @@ void PlayerManager::heartbeatPlayer(CNSocket* sock, CNPacketData* data) {
void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) { void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_EXIT)) if (data->size != sizeof(sP_CL2FE_REQ_PC_EXIT))
return; return;
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;
INITSTRUCT(sP_FE2CL_REP_PC_EXIT_SUCC, response); INITSTRUCT(sP_FE2CL_REP_PC_EXIT_SUCC, response);
@ -563,9 +566,81 @@ void PlayerManager::exitGame(CNSocket* sock, CNPacketData* data) {
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC)); sock->sendPacket((void*)&response, P_FE2CL_REP_PC_EXIT_SUCC, sizeof(sP_FE2CL_REP_PC_EXIT_SUCC));
} }
void PlayerManager::revivePlayer(CNSocket* sock, CNPacketData* data) {
if (data->size != sizeof(sP_CL2FE_REQ_PC_REGEN))
return;
Player plr = PlayerManager::getPlayer(sock);
// players respawn at same spot they died at for now...
sP_CL2FE_REQ_PC_REGEN* reviveData = (sP_CL2FE_REQ_PC_REGEN*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_REGEN_SUCC, response);
response.bMoveLocation = reviveData->eIL;
response.PCRegenData.iMapNum = reviveData->iIndex;
response.PCRegenData.iHP = 1000 * plr.level;
response.PCRegenData.iX = plr.x;
response.PCRegenData.iY = plr.y;
response.PCRegenData.iZ = plr.z;
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_REGEN_SUCC, sizeof(sP_FE2CL_REP_PC_REGEN_SUCC));
}
void PlayerManager::enterPlayerVehicle(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_PC_VEHICLE_ON* vehicleData = (sP_CL2FE_REQ_PC_VEHICLE_ON*)data->buf;
INITSTRUCT(sP_FE2CL_PC_VEHICLE_ON_SUCC, response);
PlayerView plrv = PlayerManager::players[sock];
//send to other players
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, pkt);
pkt.EquipSlotItem.iType = 1;
pkt.iEquipSlotNum = 8;
for (CNSocket* otherSock : plrv.viewable) {
otherSock->sendPacket((void*)&pkt, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
}
plrv.plr.iPCState = 8;
updatePlayer(sock, plrv.plr);
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_ON_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_ON_SUCC));
}
void PlayerManager::exitPlayerVehicle(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_PC_VEHICLE_OFF* vehicleData = (sP_CL2FE_REQ_PC_VEHICLE_OFF*)data->buf;
INITSTRUCT(sP_FE2CL_PC_VEHICLE_OFF_SUCC, response);
PlayerView plrv = PlayerManager::players[sock];
//send to other players
INITSTRUCT(sP_FE2CL_PC_EQUIP_CHANGE, pkt);
pkt.EquipSlotItem.iType = 1;
pkt.iEquipSlotNum = 8;
for (CNSocket* otherSock : plrv.viewable) {
otherSock->sendPacket((void*)&pkt, P_FE2CL_PC_EQUIP_CHANGE, sizeof(sP_FE2CL_PC_EQUIP_CHANGE));
}
plrv.plr.iPCState = 0;
updatePlayer(sock, plrv.plr);
sock->sendPacket((void*)&response, P_FE2CL_PC_VEHICLE_OFF_SUCC, sizeof(sP_FE2CL_PC_VEHICLE_OFF_SUCC));
}
void PlayerManager::setSpecialSwitchPlayer(CNSocket* sock, CNPacketData* data) {
sP_CL2FE_REQ_PC_SPECIAL_STATE_SWITCH* specialData = (sP_CL2FE_REQ_PC_SPECIAL_STATE_SWITCH*)data->buf;
INITSTRUCT(sP_FE2CL_REP_PC_SPECIAL_STATE_SWITCH_SUCC, response);
response.iPC_ID = specialData->iPC_ID;
response.iReqSpecialStateFlag = specialData->iSpecialStateFlag;
sock->sendPacket((void*)&response, P_FE2CL_REP_PC_SPECIAL_STATE_SWITCH_SUCC, sizeof(sP_FE2CL_REP_PC_SPECIAL_STATE_SWITCH_SUCC));
}
#pragma region Helper methods
Player PlayerManager::getPlayer(CNSocket* key) {
return players[key].plr;
}
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;
} }
#pragma endregion

View File

@ -41,5 +41,11 @@ namespace PlayerManager {
void gotoPlayer(CNSocket* sock, CNPacketData* data); void gotoPlayer(CNSocket* sock, CNPacketData* data);
void setSpecialPlayer(CNSocket* sock, CNPacketData* data); void setSpecialPlayer(CNSocket* sock, CNPacketData* data);
void heartbeatPlayer(CNSocket* sock, CNPacketData* data); void heartbeatPlayer(CNSocket* sock, CNPacketData* data);
void revivePlayer(CNSocket* sock, CNPacketData* data);
void exitGame(CNSocket* sock, CNPacketData* data); void exitGame(CNSocket* sock, CNPacketData* data);
void setSpecialSwitchPlayer(CNSocket* sock, CNPacketData* data);
void enterPlayerVehicle(CNSocket* sock, CNPacketData* data);
void exitPlayerVehicle(CNSocket* sock, CNPacketData* data);
} }

View File

@ -3,6 +3,7 @@
#include "PlayerManager.hpp" #include "PlayerManager.hpp"
#include "ChatManager.hpp" #include "ChatManager.hpp"
#include "ItemManager.hpp" #include "ItemManager.hpp"
#include "MissionManager.hpp"
#include "NanoManager.hpp" #include "NanoManager.hpp"
#include "NPCManager.hpp" #include "NPCManager.hpp"
@ -11,7 +12,7 @@
#if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS) #if defined(__MINGW32__) && !defined(_GLIBCXX_HAS_GTHREADS)
#include "mingw/mingw.thread.h" #include "mingw/mingw.thread.h"
#else #else
#include <thread> #include <thread>
#endif #endif
#include <string> #include <string>
@ -22,9 +23,9 @@ void startShard(CNShardServer* server) {
int main() { int main() {
#ifdef _WIN32 #ifdef _WIN32
WSADATA wsaData; WSADATA wsaData;
if (WSAStartup(MAKEWORD(1,1), &wsaData) != 0) { if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) {
std::cerr << "OpenFusion: WSAStartup failed" << std::endl; std::cerr << "OpenFusion: WSAStartup failed" << std::endl;
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
#endif #endif
settings::init(); settings::init();
@ -33,6 +34,7 @@ int main() {
PlayerManager::init(); PlayerManager::init();
ChatManager::init(); ChatManager::init();
ItemManager::init(); ItemManager::init();
MissionManager::init();
NanoManager::init(); NanoManager::init();
NPCManager::init(); NPCManager::init();
@ -41,12 +43,12 @@ int main() {
CNShardServer shardServer(settings::SHARDPORT); CNShardServer shardServer(settings::SHARDPORT);
std::thread shardThread(startShard, (CNShardServer*)&shardServer); std::thread shardThread(startShard, (CNShardServer*)&shardServer);
loginServer.start(); loginServer.start();
shardServer.kill(); shardServer.kill();
shardThread.join(); shardThread.join();
#ifdef _WIN32 #ifdef _WIN32
WSACleanup(); WSACleanup();
#endif #endif