From 1874f1081b5c5509d1271952e40eea6a33493498 Mon Sep 17 00:00:00 2001 From: kamilprzyb Date: Thu, 24 Sep 2020 22:32:09 +0200 Subject: [PATCH] warping to the past now sets PayZoneFlag and removes all active missions --- src/MissionManager.cpp | 12 ++++++++---- src/MissionManager.hpp | 1 + src/PlayerManager.cpp | 12 +++++++++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/MissionManager.cpp b/src/MissionManager.cpp index e70beb3..c77e775 100644 --- a/src/MissionManager.cpp +++ b/src/MissionManager.cpp @@ -157,13 +157,17 @@ void MissionManager::quitMission(CNSocket* sock, CNPacketData* data) { return; // malformed packet sP_CL2FE_REQ_PC_TASK_STOP* missionData = (sP_CL2FE_REQ_PC_TASK_STOP*)data->buf; + quitTask(sock, missionData->iTaskNum); +} + +void MissionManager::quitTask(CNSocket* sock, int32_t TaskNum) { INITSTRUCT(sP_FE2CL_REP_PC_TASK_STOP_SUCC, response); - Player *plr = PlayerManager::getPlayer(sock); + Player* plr = PlayerManager::getPlayer(sock); // update player int i; for (i = 0; i < ACTIVE_MISSION_COUNT; i++) { - if (plr->tasks[i] == missionData->iTaskNum) + if (plr->tasks[i] == TaskNum) { plr->tasks[i] = 0; for (int j = 0; j < 3; j++) { @@ -177,7 +181,7 @@ void MissionManager::quitMission(CNSocket* sock, CNPacketData* data) { // remove current mission plr->CurrentMissionID = 0; - TaskData& task = *Tasks[missionData->iTaskNum]; + TaskData& task = *Tasks[TaskNum]; // clean up quest items for (i = 0; i < 3; i++) { @@ -193,7 +197,7 @@ void MissionManager::quitMission(CNSocket* sock, CNPacketData* data) { memset(&plr->QInven[j], 0, sizeof(sItemBase)); } - response.iTaskNum = missionData->iTaskNum; + response.iTaskNum = TaskNum; sock->sendPacket((void*)&response, P_FE2CL_REP_PC_TASK_STOP_SUCC, sizeof(sP_FE2CL_REP_PC_TASK_STOP_SUCC)); } diff --git a/src/MissionManager.hpp b/src/MissionManager.hpp index 4ecf75c..991622d 100644 --- a/src/MissionManager.hpp +++ b/src/MissionManager.hpp @@ -56,4 +56,5 @@ namespace MissionManager { void mobKilled(CNSocket *sock, int mobid); void saveMission(Player* player, int missionId); + void quitTask(CNSocket* sock, int32_t TaskNum); } diff --git a/src/PlayerManager.cpp b/src/PlayerManager.cpp index 6ff9247..02395b9 100644 --- a/src/PlayerManager.cpp +++ b/src/PlayerManager.cpp @@ -815,7 +815,17 @@ void PlayerManager::changePlayerGuide(CNSocket *sock, CNPacketData *data) { resp.iFusionMatter = plr->fusionmatter; // no cost sock->sendPacket((void*)&resp, P_FE2CL_REP_PC_CHANGE_MENTOR_SUCC, sizeof(sP_FE2CL_REP_PC_CHANGE_MENTOR_SUCC)); - //save it on player + // if it's changed from computress + if (plr->mentor == 5) { + // we're warping to the past + plr->PCStyle2.iPayzoneFlag = 1; + // remove all active missions + for (int i = 0; i < ACTIVE_MISSION_COUNT; i++) { + if (plr->tasks[i] != 0) + MissionManager::quitTask(sock, plr->tasks[i]); + } + } + // save it on player plr->mentor = pkt->iMentor; }