mirror of https://github.com/GTAmodding/re3.git
Fix debug script loader crashing missions
* open_script is now exposed in Script.h, perhaps it should be namespaced as a static method on CTheScripts? I'm unsure what is preferred. * I've moved the joypad code out of open_script to prevent buttons held down at mission load time from changing the scriptToLoad. * It appears that the debug script loader was mostly already fixed on miami branch.
This commit is contained in:
parent
c8cb1ed013
commit
7007cbbb27
|
@ -2206,24 +2206,15 @@ void CRunningScript::Init()
|
|||
|
||||
#ifdef USE_DEBUG_SCRIPT_LOADER
|
||||
int scriptToLoad = 0;
|
||||
const char *scriptfile = "main.scm";
|
||||
|
||||
int open_script()
|
||||
{
|
||||
// glfwGetKey doesn't work because of CGame::Initialise is blocking
|
||||
CPad::UpdatePads();
|
||||
if (CPad::GetPad(0)->GetChar('G'))
|
||||
scriptToLoad = 0;
|
||||
if (CPad::GetPad(0)->GetChar('R'))
|
||||
scriptToLoad = 1;
|
||||
if (CPad::GetPad(0)->GetChar('D'))
|
||||
scriptToLoad = 2;
|
||||
switch (scriptToLoad) {
|
||||
case 0: scriptfile = "main.scm"; break;
|
||||
case 1: scriptfile = "freeroam_miami.scm"; break;
|
||||
case 2: scriptfile = "main_d.scm"; break;
|
||||
case 0: return CFileMgr::OpenFile("data\\main.scm", "rb");
|
||||
case 1: return CFileMgr::OpenFile("data\\freeroam_miami.scm", "rb");
|
||||
case 2: return CFileMgr::OpenFile("data\\main_d.scm", "rb");
|
||||
}
|
||||
return CFileMgr::OpenFile(scriptfile, "rb");
|
||||
return CFileMgr::OpenFile("data\\main.scm", "rb");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -2239,10 +2230,16 @@ void CTheScripts::Init()
|
|||
MissionCleanUp.Init();
|
||||
UpsideDownCars.Init();
|
||||
StuckCars.Init();
|
||||
CFileMgr::SetDir("data");
|
||||
#ifdef USE_DEBUG_SCRIPT_LOADER
|
||||
// glfwGetKey doesn't work because of CGame::Initialise is blocking
|
||||
CPad::UpdatePads();
|
||||
if(CPad::GetPad(0)->GetChar('G')) scriptToLoad = 0;
|
||||
if(CPad::GetPad(0)->GetChar('R')) scriptToLoad = 1;
|
||||
if(CPad::GetPad(0)->GetChar('D')) scriptToLoad = 2;
|
||||
|
||||
int mainf = open_script();
|
||||
#else
|
||||
CFileMgr::SetDir("data");
|
||||
int mainf = CFileMgr::OpenFile("main.scm", "rb");
|
||||
#endif
|
||||
CFileMgr::Read(mainf, (char*)ScriptSpace, SIZE_MAIN_SCRIPT);
|
||||
|
@ -4839,12 +4836,10 @@ CTheScripts::SwitchToMission(int32 mission)
|
|||
#endif
|
||||
CTimer::Suspend();
|
||||
int offset = CTheScripts::MultiScriptArray[mission];
|
||||
CFileMgr::ChangeDir("\\");
|
||||
#ifdef USE_DEBUG_SCRIPT_LOADER
|
||||
CFileMgr::ChangeDir("\\data\\");
|
||||
int handle = CFileMgr::OpenFile(scriptfile, "rb");
|
||||
CFileMgr::ChangeDir("\\");
|
||||
int handle = open_script();
|
||||
#else
|
||||
CFileMgr::ChangeDir("\\");
|
||||
int handle = CFileMgr::OpenFile("data\\main.scm", "rb");
|
||||
#endif
|
||||
CFileMgr::Seek(handle, offset, 0);
|
||||
|
|
|
@ -597,5 +597,6 @@ void RetryMission(int, int);
|
|||
#endif
|
||||
|
||||
#ifdef USE_DEBUG_SCRIPT_LOADER
|
||||
int open_script();
|
||||
extern int scriptToLoad;
|
||||
#endif
|
||||
|
|
|
@ -383,12 +383,10 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
|
|||
#endif
|
||||
CTimer::Suspend();
|
||||
int offset = CTheScripts::MultiScriptArray[ScriptParams[0]];
|
||||
CFileMgr::ChangeDir("\\");
|
||||
#ifdef USE_DEBUG_SCRIPT_LOADER
|
||||
CFileMgr::ChangeDir("\\data\\");
|
||||
int handle = CFileMgr::OpenFile(scriptfile, "rb");
|
||||
CFileMgr::ChangeDir("\\");
|
||||
int handle = open_script();
|
||||
#else
|
||||
CFileMgr::ChangeDir("\\");
|
||||
int handle = CFileMgr::OpenFile("data\\main.scm", "rb");
|
||||
#endif
|
||||
CFileMgr::Seek(handle, offset, 0);
|
||||
|
|
Loading…
Reference in New Issue