diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2021-01-09 15:35:27 +0100 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2021-01-09 15:35:27 +0100 |
commit | 97c95b763961460244c8a0c4c1e6231277112038 (patch) | |
tree | 66d9b5128531c834798bf4390c1c0856b37daae6 /src/control/Script6.cpp | |
parent | fix (diff) | |
download | re3-97c95b763961460244c8a0c4c1e6231277112038.tar re3-97c95b763961460244c8a0c4c1e6231277112038.tar.gz re3-97c95b763961460244c8a0c4c1e6231277112038.tar.bz2 re3-97c95b763961460244c8a0c4c1e6231277112038.tar.lz re3-97c95b763961460244c8a0c4c1e6231277112038.tar.xz re3-97c95b763961460244c8a0c4c1e6231277112038.tar.zst re3-97c95b763961460244c8a0c4c1e6231277112038.zip |
Diffstat (limited to 'src/control/Script6.cpp')
-rw-r--r-- | src/control/Script6.cpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp index 76780941..8915a089 100644 --- a/src/control/Script6.cpp +++ b/src/control/Script6.cpp @@ -374,32 +374,30 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) { CollectParameters(&m_nIp, 1); - if (CTheScripts::NumberOfExclusiveMissionScripts > 0 && ScriptParams[0] <= UINT16_MAX - 2) - return 0; + if (CTheScripts::NumberOfExclusiveMissionScripts > 0) { + if (ScriptParams[0] < UINT16_MAX - 1) + return 0; + ScriptParams[0] = UINT16_MAX - ScriptParams[0]; + } #ifdef MISSION_REPLAY missionRetryScriptIndex = ScriptParams[0]; if (missionRetryScriptIndex == 19) CStats::LastMissionPassedName[0] = '\0'; #endif CTimer::Suspend(); - int offset = CTheScripts::MultiScriptArray[ScriptParams[0]]; -#ifdef USE_DEBUG_SCRIPT_LOADER - CFileMgr::ChangeDir("\\data\\"); - int handle = CFileMgr::OpenFile(scriptfile, "rb"); - CFileMgr::ChangeDir("\\"); -#else - CFileMgr::ChangeDir("\\"); - int handle = CFileMgr::OpenFile("data\\main.scm", "rb"); -#endif - 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); + int offset = CTheScripts::MultiScriptArray[ScriptParams[0]] + 8; + int size = CTheScripts::MultiScriptArray[ScriptParams[0] + 1] - CTheScripts::MultiScriptArray[ScriptParams[0]]; + if (size <= 0) + size = CTheScripts::LargestMissionScriptSize; + CFileMgr::Seek(gScriptsFile, offset, 0); + CFileMgr::Read(gScriptsFile, (const char*)&CTheScripts::ScriptSpace[CTheScripts::MainScriptSize], size); // TODO + CRunningScript* pMissionScript = CTheScripts::StartNewScript(CTheScripts::MainScriptSize); CTimer::Resume(); pMissionScript->m_bIsMissionScript = true; pMissionScript->m_bMissionFlag = true; CTheScripts::bAlreadyRunningAMissionScript = true; - CGameLogic::ClearShortCut(); + memset(&CTheScripts::ScriptSpace[CTheScripts::NumTrueGlobals * 4 + 8], 0, CTheScripts::MostGlobals * 4); + pMissionScript->Process(); return 0; } case COMMAND_SET_OBJECT_DRAW_LAST: |