diff --git a/src/title/TitleSequence.cpp b/src/title/TitleSequence.cpp index 1a1f21b2fc..861e73f6f7 100644 --- a/src/title/TitleSequence.cpp +++ b/src/title/TitleSequence.cpp @@ -295,6 +295,25 @@ extern "C" } seq->NumSaves--; + // Update load commands + for (size_t i = 0; i < seq->NumCommands; i++) + { + TitleCommand * command = &seq->Commands[i]; + if (command->Type == TITLE_SCRIPT_LOAD) + { + if (command->SaveIndex == index) + { + // Park no longer exists, so reset load command to invalid + command->SaveIndex = SAVE_INDEX_INVALID; + } + else if (command->SaveIndex > index) + { + // Park index will have shifted by -1 + command->SaveIndex--; + } + } + } + return true; } } @@ -352,7 +371,7 @@ static std::vector LegacyScriptRead(utf8 * script, size_t scriptLe if (_stricmp(token, "LOAD") == 0) { command.Type = TITLE_SCRIPT_LOAD; - command.SaveIndex = UINT8_MAX; + command.SaveIndex = SAVE_INDEX_INVALID; for (size_t i = 0; i < saves.size(); i++) { if (String::Equals(part1, saves[i], true)) diff --git a/src/title/TitleSequence.h b/src/title/TitleSequence.h index e92387906b..77c195f0a0 100644 --- a/src/title/TitleSequence.h +++ b/src/title/TitleSequence.h @@ -77,7 +77,10 @@ enum TITLE_SCRIPT }; #ifdef __cplusplus -constexpr const utf8 * TITLE_SEQUENCE_EXTENSION = ".parkseq"; + constexpr const utf8 * TITLE_SEQUENCE_EXTENSION = ".parkseq"; + constexpr uint8 SAVE_INDEX_INVALID = UINT8_MAX; +#else + #define SAVE_INDEX_INVALID UINT8_MAX #endif #ifdef __cplusplus diff --git a/src/windows/title_editor.c b/src/windows/title_editor.c index 4ea4a74a40..7bd944d444 100644 --- a/src/windows/title_editor.c +++ b/src/windows/title_editor.c @@ -870,7 +870,7 @@ static void window_title_editor_scrollpaint_commands(rct_window *w, rct_drawpixe switch (command->Type) { case TITLE_SCRIPT_LOAD: commandName = STR_TITLE_EDITOR_COMMAND_LOAD_FILE; - if (command->SaveIndex == 0xFF) { + if (command->SaveIndex == SAVE_INDEX_INVALID) { commandName = STR_TITLE_EDITOR_COMMAND_LOAD_NO_SAVE; error = true; }