Warn when loading incompatible RCTC saves

This commit is contained in:
Michael Steenbeek 2017-10-30 16:11:45 +01:00
parent 9425ed1aee
commit 3d8ec4e393
6 changed files with 48 additions and 3 deletions

View File

@ -4466,6 +4466,7 @@ STR_6154 :It is not recommended to run OpenRCT2 with elevated permissions.
STR_6155 :Neither KDialog nor Zenity are installed. Please install one, or configure from the command line.
STR_6156 :Name is reserved
STR_6157 :Console
STR_6158 :Failed to load this file...{NEWLINE}Incompatible RCTC version: {COMMA16}
#############
# Scenarios #

View File

@ -22,13 +22,21 @@
#include "ParkImporter.h"
ParkLoadResult::ParkLoadResult(PARK_LOAD_ERROR error)
: Error(error)
: Error(error),
Flag(0)
{
}
ParkLoadResult::ParkLoadResult(PARK_LOAD_ERROR error, const std::vector<rct_object_entry> &missingObjects)
: Error(error),
MissingObjects(missingObjects)
MissingObjects(missingObjects),
Flag(0)
{
}
ParkLoadResult::ParkLoadResult(PARK_LOAD_ERROR error, const uint8 flag)
: Error(error),
Flag(flag)
{
}
@ -52,6 +60,11 @@ ParkLoadResult ParkLoadResult::CreateUnknown()
return ParkLoadResult(PARK_LOAD_ERROR::PARK_LOAD_ERROR_UNKNOWN);
}
ParkLoadResult ParkLoadResult::CreateUnsupportedRCTCflag(uint8 classic_flag)
{
return ParkLoadResult(PARK_LOAD_ERROR::PARK_LOAD_ERROR_UNSUPPORTED_RCTC_FLAG, classic_flag);
}
extern "C"
{
PARK_LOAD_ERROR ParkLoadResult_GetError(const ParkLoadResult * t)
@ -64,6 +77,11 @@ extern "C"
return t->MissingObjects.size();
}
uint8 ParkLoadResult_GetFlag(const ParkLoadResult * t)
{
return t->Flag;
}
const rct_object_entry * ParkLoadResult_GetMissingObjects(const ParkLoadResult * t)
{
return t->MissingObjects.data();

View File

@ -25,6 +25,7 @@ typedef enum PARK_LOAD_ERROR
PARK_LOAD_ERROR_OK,
PARK_LOAD_ERROR_MISSING_OBJECTS,
PARK_LOAD_ERROR_INVALID_EXTENSION,
PARK_LOAD_ERROR_UNSUPPORTED_RCTC_FLAG,
PARK_LOAD_ERROR_UNKNOWN = 255
} PARK_LOAD_ERROR;
@ -44,15 +45,18 @@ struct ParkLoadResult final
public:
const PARK_LOAD_ERROR Error;
const std::vector<rct_object_entry> MissingObjects;
const uint8 Flag;
static ParkLoadResult CreateOK();
static ParkLoadResult CreateInvalidExtension();
static ParkLoadResult CreateMissingObjects(const std::vector<rct_object_entry> &missingObjects);
static ParkLoadResult CreateUnknown();
static ParkLoadResult CreateUnsupportedRCTCflag(uint8 classic_flag);
private:
ParkLoadResult(PARK_LOAD_ERROR error);
ParkLoadResult(PARK_LOAD_ERROR error, const std::vector<rct_object_entry> &missingObjects);
ParkLoadResult(PARK_LOAD_ERROR error, const uint8 flag);
};
/**
@ -101,6 +105,7 @@ extern "C"
PARK_LOAD_ERROR ParkLoadResult_GetError(const ParkLoadResult * t);
size_t ParkLoadResult_GetMissingObjectsCount(const ParkLoadResult * t);
const rct_object_entry * ParkLoadResult_GetMissingObjects(const ParkLoadResult * t);
uint8 ParkLoadResult_GetFlag(const ParkLoadResult * t);
void ParkLoadResult_Delete(ParkLoadResult * t);
ParkLoadResult * ParkLoadResult_CreateInvalidExtension();
#ifdef __cplusplus

View File

@ -1151,7 +1151,21 @@ void handle_park_load_failure_with_title_opt(const ParkLoadResult * result, cons
window_object_load_error_open(strndup(path, strnlen(path, MAX_PATH)),
ParkLoadResult_GetMissingObjectsCount(result),
ParkLoadResult_GetMissingObjects(result));
} else if (ParkLoadResult_GetError(result) != PARK_LOAD_ERROR_OK) {
}
else if (ParkLoadResult_GetError(result) == PARK_LOAD_ERROR_UNSUPPORTED_RCTC_FLAG)
{
// This option is used when loading parks from the command line
// to ensure that the title sequence loads before the window
if (loadTitleFirst)
{
title_load();
}
set_format_arg(0, uint16, ParkLoadResult_GetFlag(result));
context_show_error(STR_FAILED_TO_LOAD_IMCOMPATIBLE_RCTC_FLAG, STR_NONE);
}
else if (ParkLoadResult_GetError(result) != PARK_LOAD_ERROR_OK) {
// If loading the SV6 or SV4 failed for a reason other than invalid objects
// the current park state will be corrupted so just go back to the title screen.
title_load();

View File

@ -3813,6 +3813,8 @@ enum {
STR_CONSOLE = 6157,
STR_FAILED_TO_LOAD_IMCOMPATIBLE_RCTC_FLAG = 6158,
// Have to include resource strings (from scenarios and objects) for the time being now that language is partially working
STR_COUNT = 32768
};

View File

@ -141,6 +141,11 @@ public:
}
}
if (_s6.header.classic_flag == 0xf)
{
return ParkLoadResult::CreateUnsupportedRCTCflag(_s6.header.classic_flag);
}
// Read packed objects
// TODO try to contain this more and not store objects until later
for (uint16 i = 0; i < _s6.header.num_packed_objects; i++)