diff options
author | erorcun <erayorcunus@gmail.com> | 2020-11-17 23:45:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-17 23:45:12 +0100 |
commit | b58a54527ef9c34559f3640c1e0056b8dcc4601b (patch) | |
tree | c6f109ef5d5dfc8720d0df518eb74ee718a5caa4 /src/control | |
parent | fix flag (diff) | |
parent | add mission switcher from miami (diff) | |
download | re3-b58a54527ef9c34559f3640c1e0056b8dcc4601b.tar re3-b58a54527ef9c34559f3640c1e0056b8dcc4601b.tar.gz re3-b58a54527ef9c34559f3640c1e0056b8dcc4601b.tar.bz2 re3-b58a54527ef9c34559f3640c1e0056b8dcc4601b.tar.lz re3-b58a54527ef9c34559f3640c1e0056b8dcc4601b.tar.xz re3-b58a54527ef9c34559f3640c1e0056b8dcc4601b.tar.zst re3-b58a54527ef9c34559f3640c1e0056b8dcc4601b.zip |
Diffstat (limited to 'src/control')
-rw-r--r-- | src/control/Script.cpp | 41 | ||||
-rw-r--r-- | src/control/Script.h | 7 |
2 files changed, 48 insertions, 0 deletions
diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 86595bbd..646bc3f7 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -13337,3 +13337,44 @@ void RetryMission(int type, int unk) } #endif + +#ifdef MISSION_SWITCHER +void +CTheScripts::SwitchToMission(int32 mission) +{ + for (CRunningScript* pScript = CTheScripts::pActiveScripts; pScript != nil; pScript = pScript->GetNext()) { + if (!pScript->m_bIsMissionScript || !pScript->m_bDeatharrestEnabled) { + continue; + } + while (pScript->m_nStackPointer > 0) + --pScript->m_nStackPointer; + + pScript->m_nIp = pScript->m_anStack[pScript->m_nStackPointer]; + *(int32*)&CTheScripts::ScriptSpace[CTheScripts::OnAMissionFlag] = 0; + pScript->m_nWakeTime = 0; + pScript->m_bDeatharrestExecuted = true; + + while (!pScript->ProcessOneCommand()); + + CMessages::ClearMessages(); + } + +#ifdef MISSION_REPLAY + missionRetryScriptIndex = mission; + if (missionRetryScriptIndex == 19) + CStats::LastMissionPassedName[0] = '\0'; +#endif + CTimer::Suspend(); + int offset = CTheScripts::MultiScriptArray[mission]; + CFileMgr::ChangeDir("\\"); + int handle = CFileMgr::OpenFile("data\\main.scm", "rb"); + CFileMgr::Seek(handle, offset, 0); + CFileMgr::Read(handle, (const char*)&CTheScripts::ScriptSpace[SIZE_MAIN_SCRIPT], SIZE_MISSION_SCRIPT); + CFileMgr::CloseFile(handle); + CRunningScript* pMissionScript = CTheScripts::StartNewScript(SIZE_MAIN_SCRIPT); + CTimer::Resume(); + pMissionScript->m_bIsMissionScript = true; + pMissionScript->m_bMissionFlag = true; + CTheScripts::bAlreadyRunningAMissionScript = true; +} +#endif diff --git a/src/control/Script.h b/src/control/Script.h index e0ed314e..c9e92129 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -376,6 +376,11 @@ private: #ifdef FIX_BUGS friend void RetryMission(int, int); #endif + +#ifdef MISSION_SWITCHER +public: + static void SwitchToMission(int32 mission); +#endif }; @@ -514,6 +519,8 @@ private: return false; } } + + friend class CTheScripts; }; #ifdef MISSION_REPLAY |