diff options
author | withmorten <morten.with@gmail.com> | 2020-11-16 00:41:03 +0100 |
---|---|---|
committer | withmorten <morten.with@gmail.com> | 2020-11-16 00:41:03 +0100 |
commit | abcda2ce29877cdd60fad383ec098b174fbcc11f (patch) | |
tree | f889b2c528ce9dc5a0623662c71236d0b5c61154 /src/control/Script.cpp | |
parent | Make collision code placement more like original (+ small fixes) (diff) | |
download | re3-abcda2ce29877cdd60fad383ec098b174fbcc11f.tar re3-abcda2ce29877cdd60fad383ec098b174fbcc11f.tar.gz re3-abcda2ce29877cdd60fad383ec098b174fbcc11f.tar.bz2 re3-abcda2ce29877cdd60fad383ec098b174fbcc11f.tar.lz re3-abcda2ce29877cdd60fad383ec098b174fbcc11f.tar.xz re3-abcda2ce29877cdd60fad383ec098b174fbcc11f.tar.zst re3-abcda2ce29877cdd60fad383ec098b174fbcc11f.zip |
Diffstat (limited to 'src/control/Script.cpp')
-rw-r--r-- | src/control/Script.cpp | 41 |
1 files changed, 41 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 |