add mission switcher from miami

This commit is contained in:
withmorten 2020-11-16 00:41:03 +01:00
parent a6f5f4634c
commit abcda2ce29
4 changed files with 86 additions and 0 deletions

View File

@ -13337,3 +13337,44 @@ void RetryMission(int type, int unk)
} }
#endif #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

View File

@ -376,6 +376,11 @@ private:
#ifdef FIX_BUGS #ifdef FIX_BUGS
friend void RetryMission(int, int); friend void RetryMission(int, int);
#endif #endif
#ifdef MISSION_SWITCHER
public:
static void SwitchToMission(int32 mission);
#endif
}; };
@ -514,6 +519,8 @@ private:
return false; return false;
} }
} }
friend class CTheScripts;
}; };
#ifdef MISSION_REPLAY #ifdef MISSION_REPLAY

View File

@ -217,6 +217,11 @@ enum Config {
#define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible #define COMPATIBLE_SAVES // this allows changing structs while keeping saves compatible
#define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS #define LOAD_INI_SETTINGS // as the name suggests. fundamental for CUSTOM_FRONTEND_OPTIONS
// Just debug menu entries
#ifdef DEBUGMENU
#define MISSION_SWITCHER // from debug menu
#endif
// Rendering/display // Rendering/display
//#define EXTRA_MODEL_FLAGS // from mobile to optimize rendering //#define EXTRA_MODEL_FLAGS // from mobile to optimize rendering
//# define HARDCODED_MODEL_FLAGS // sets the flags enabled above from hardcoded model names. //# define HARDCODED_MODEL_FLAGS // sets the flags enabled above from hardcoded model names.

View File

@ -26,6 +26,7 @@
#include "Frontend.h" #include "Frontend.h"
#include "WaterLevel.h" #include "WaterLevel.h"
#include "main.h" #include "main.h"
#include "Script.h"
#include "postfx.h" #include "postfx.h"
#include "custompipes.h" #include "custompipes.h"
@ -373,6 +374,15 @@ ResetCamStatics(void)
TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true; TheCamera.Cams[TheCamera.ActiveCam].ResetStatics = true;
} }
#ifdef MISSION_SWITCHER
int8 nextMissionToSwitch = 0;
static void
SwitchToMission(void)
{
CTheScripts::SwitchToMission(nextMissionToSwitch);
}
#endif
static const char *carnames[] = { static const char *carnames[] = {
"landstal", "idaho", "stinger", "linerun", "peren", "sentinel", "patriot", "firetruk", "trash", "stretch", "manana", "infernus", "blista", "pony", "landstal", "idaho", "stinger", "linerun", "peren", "sentinel", "patriot", "firetruk", "trash", "stretch", "manana", "infernus", "blista", "pony",
"mule", "cheetah", "ambulan", "fbicar", "moonbeam", "esperant", "taxi", "kuruma", "bobcat", "mrwhoop", "bfinject", "corpse", "police", "enforcer", "mule", "cheetah", "ambulan", "fbicar", "moonbeam", "esperant", "taxi", "kuruma", "bobcat", "mrwhoop", "bfinject", "corpse", "police", "enforcer",
@ -581,6 +591,29 @@ DebugMenuPopulate(void)
#ifdef TIMEBARS #ifdef TIMEBARS
DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil); DebugMenuAddVarBool8("Debug", "Show Timebars", &gbShowTimebars, nil);
#endif #endif
#ifdef MISSION_SWITCHER
DebugMenuEntry *missionEntry;
static const char* missions[] = {
"Intro Movie", "Hospital Info Scene", "Police Station Info Scene",
"RC Diablo Destruction", "RC Mafia Massacre", "RC Rumpo Rampage", "RC Casino Calamity",
"Patriot Playground", "A Ride In The Park", "Gripped!", "Multistorey Mayhem",
"Paramedic", "Firefighter", "Vigilante", "Taxi Driver",
"The Crook", "The Thieves", "The Wife", "Her Lover",
"Give Me Liberty and Luigi's Girls", "Don't Spank My Bitch Up", "Drive Misty For Me", "Pump-Action Pimp", "The Fuzz Ball",
"Mike Lips Last Lunch", "Farewell 'Chunky' Lee Chong", "Van Heist", "Cipriani's Chauffeur", "Dead Skunk In The Trunk", "The Getaway",
"Taking Out The Laundry", "The Pick-Up", "Salvatore's Called A Meeting", "Triads And Tribulations", "Blow Fish", "Chaperone", "Cutting The Grass",
"Bomb Da Base: Act I", "Bomb Da Base: Act II", "Last Requests", "Turismo", "I Scream, You Scream", "Trial By Fire", "Big'N'Veiny", "Sayonara Salvatore",
"Under Surveillance", "Paparazzi Purge", "Payday For Ray", "Two-Faced Tanner", "Kanbu Bust-Out", "Grand Theft Auto", "Deal Steal", "Shima", "Smack Down",
"Silence The Sneak", "Arms Shortage", "Evidence Dash", "Gone Fishing", "Plaster Blaster", "Marked Man",
"Liberator", "Waka-Gashira Wipeout!", "A Drop In The Ocean", "Bling-Bling Scramble", "Uzi Rider", "Gangcar Round-Up", "Kingdom Come",
"Grand Theft Aero", "Escort Service", "Decoy", "Love's Disappearance", "Bait", "Espresso-2-Go!", "S.A.M.",
"Uzi Money", "Toyminator", "Rigged To Blow", "Bullion Run", "Rumble", "The Exchange"
};
missionEntry = DebugMenuAddVar("Debug", "Select mission", &nextMissionToSwitch, nil, 1, 0, 79, missions);
DebugMenuEntrySetWrap(missionEntry, true);
DebugMenuAddCmd("Debug", "Start selected mission ", SwitchToMission);
#endif
extern bool PrintDebugCode; extern bool PrintDebugCode;
extern int16 DebugCamMode; extern int16 DebugCamMode;