From 33c45e4ae0f10a4b296e520d3691b47bc801ea73 Mon Sep 17 00:00:00 2001 From: Magnus Larsen Date: Sat, 10 Jul 2021 08:56:28 -0700 Subject: 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. --- src/control/Script.cpp | 24 +++++++++++------------- src/control/Script.h | 1 + src/control/Script6.cpp | 4 ++++ 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'src/control') diff --git a/src/control/Script.cpp b/src/control/Script.cpp index e06acdc3..09891765 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -1771,20 +1771,12 @@ int scriptToLoad = 0; 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: return CFileMgr::OpenFile("main.scm", "rb"); - case 1: return CFileMgr::OpenFile("main_freeroam.scm", "rb"); - case 2: return CFileMgr::OpenFile("main_d.scm", "rb"); + case 0: return CFileMgr::OpenFile("data\\main.scm", "rb"); + case 1: return CFileMgr::OpenFile("data\\main_freeroam.scm", "rb"); + case 2: return CFileMgr::OpenFile("data\\main_d.scm", "rb"); } - return CFileMgr::OpenFile("main.scm", "rb"); + return CFileMgr::OpenFile("data\\main.scm", "rb"); } #endif @@ -1800,10 +1792,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); diff --git a/src/control/Script.h b/src/control/Script.h index 5682024b..cefd6747 100644 --- a/src/control/Script.h +++ b/src/control/Script.h @@ -591,5 +591,6 @@ void RetryMission(int, int); #endif #ifdef USE_DEBUG_SCRIPT_LOADER +int open_script(); extern int scriptToLoad; #endif \ No newline at end of file diff --git a/src/control/Script6.cpp b/src/control/Script6.cpp index 31be6987..c9b2b070 100644 --- a/src/control/Script6.cpp +++ b/src/control/Script6.cpp @@ -305,7 +305,11 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command) CTimer::Suspend(); int offset = CTheScripts::MultiScriptArray[ScriptParams[0]]; CFileMgr::ChangeDir("\\"); +#ifdef USE_DEBUG_SCRIPT_LOADER + int handle = open_script(); +#else 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); -- cgit v1.2.3 From 12efd1209bedcd3ad7e572fc600c59846cd9f119 Mon Sep 17 00:00:00 2001 From: Magnus Larsen Date: Sat, 10 Jul 2021 10:18:32 -0700 Subject: Fix Cheat menu debug script loader --- src/control/Script.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/control') diff --git a/src/control/Script.cpp b/src/control/Script.cpp index 09891765..b07c0701 100644 --- a/src/control/Script.cpp +++ b/src/control/Script.cpp @@ -4390,7 +4390,11 @@ CTheScripts::SwitchToMission(int32 mission) CTimer::Suspend(); int offset = CTheScripts::MultiScriptArray[mission]; CFileMgr::ChangeDir("\\"); +#ifdef USE_DEBUG_SCRIPT_LOADER + int handle = open_script(); +#else 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); -- cgit v1.2.3 From a437d2bc2611166b9dbbe3072cea9f9307b98838 Mon Sep 17 00:00:00 2001 From: withmorten Date: Mon, 19 Jul 2021 23:39:19 +0200 Subject: fix garbage data written in garage save block --- src/control/Garages.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/control') diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 91971ae7..245e961d 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -2305,6 +2305,9 @@ void CGarages::Save(uint8 * buf, uint32 * size) *size = (6 * sizeof(uint32) + TOTAL_COLLECTCARS_GARAGES * sizeof(*CarTypesCollected) + sizeof(uint32) + 3 * NUM_GARAGE_STORED_CARS * sizeof(CStoredCar) + NUM_GARAGES * sizeof(CGarage)); #else * size = 5484; +#endif +#if !defined THIS_IS_STUPID && !defined FIX_GARAGE_SIZE && defined COMPATIBLE_SAVES + memset(buf + 5240, 0, *size - 5240); // garbage data is written otherwise #endif CloseHideOutGaragesBeforeSave(); WriteSaveBuf(buf, NumGarages); -- cgit v1.2.3 From f73dfa12e6c41d1dcd16a4f5a220cc91c346ba7c Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Fri, 23 Jul 2021 21:07:44 +0300 Subject: Make cars and peds to not despawn when you look away --- src/control/CarCtrl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/control') diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 35580053..37312b89 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -731,6 +731,7 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) } float distanceToPlayer = (pVehicle->GetPosition() - vecPlayerPos).Magnitude2D(); float threshold = 50.0f; +#ifndef EXTENDED_OFFSCREEN_DESPAWN_RANGE if (pVehicle->GetIsOnScreen() || TheCamera.Cams[TheCamera.ActiveCam].LookingLeft || TheCamera.Cams[TheCamera.ActiveCam].LookingRight || @@ -741,7 +742,9 @@ CCarCtrl::PossiblyRemoveVehicle(CVehicle* pVehicle) pVehicle->GetModelIndex() == MI_FIRETRUCK || pVehicle->bIsLawEnforcer || pVehicle->bIsCarParkVehicle - ){ + ) +#endif + { threshold = 130.0f * TheCamera.GenerationDistMultiplier; } if (pVehicle->bExtendedRange) -- cgit v1.2.3