mirror of
https://github.com/OpenFusionProject/OpenFusion.git
synced 2024-11-05 06:50:04 +00:00
55 lines
2.3 KiB
C++
55 lines
2.3 KiB
C++
|
#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));
|
||
|
}
|