Fix LOAD commands after removing a park from sequence

This commit is contained in:
Ted John 2016-12-06 16:04:47 +00:00
parent 2c0786eb24
commit e74cb7ac2a
3 changed files with 25 additions and 3 deletions

View File

@ -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<TitleCommand> 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))

View File

@ -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

View File

@ -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;
}