mirror of https://github.com/OpenRCT2/OpenRCT2.git
Replace load_from_sv6() and load_from_sc6()
This commit is contained in:
parent
d5f6a5b285
commit
830fedb6b8
|
@ -283,13 +283,9 @@ namespace Editor
|
|||
auto extensionS = Path::GetExtension(path);
|
||||
const char* extension = extensionS.c_str();
|
||||
auto loadedFromSave = false;
|
||||
if (_stricmp(extension, ".sc6") == 0)
|
||||
GetContext()->LoadParkFromFile(path);
|
||||
if (_stricmp(extension, ".sv6") == 0 || _stricmp(extension, ".sv7") == 0)
|
||||
{
|
||||
load_from_sc6(path);
|
||||
}
|
||||
else if (_stricmp(extension, ".sv6") == 0 || _stricmp(extension, ".sv7") == 0)
|
||||
{
|
||||
load_from_sv6(path);
|
||||
loadedFromSave = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,7 +158,6 @@ void reset_all_sprite_quadrant_placements();
|
|||
void update_palette_effects();
|
||||
|
||||
void game_load_or_quit_no_save_prompt();
|
||||
void load_from_sv6(const char* path);
|
||||
void game_load_init();
|
||||
void game_load_scripts();
|
||||
void game_unload_scripts();
|
||||
|
|
|
@ -2316,85 +2316,3 @@ std::unique_ptr<IParkImporter> ParkImporter::CreateS6(IObjectRepository& objectR
|
|||
{
|
||||
return std::make_unique<RCT2::S6Importer>(objectRepository);
|
||||
}
|
||||
|
||||
static void show_error(uint8_t errorType, StringId errorStringId)
|
||||
{
|
||||
if (errorType == ERROR_TYPE_GENERIC)
|
||||
{
|
||||
context_show_error(errorStringId, STR_NONE, {});
|
||||
}
|
||||
context_show_error(STR_UNABLE_TO_LOAD_FILE, errorStringId, {});
|
||||
}
|
||||
|
||||
void load_from_sv6(const char* path)
|
||||
{
|
||||
auto context = OpenRCT2::GetContext();
|
||||
auto s6Importer = std::make_unique<RCT2::S6Importer>(context->GetObjectRepository());
|
||||
try
|
||||
{
|
||||
auto& objectMgr = context->GetObjectManager();
|
||||
auto result = s6Importer->LoadSavedGame(path);
|
||||
objectMgr.LoadObjects(result.RequiredObjects);
|
||||
s6Importer->Import();
|
||||
game_fix_save_vars();
|
||||
MapAnimationAutoCreate();
|
||||
EntityTweener::Get().Reset();
|
||||
gScreenAge = 0;
|
||||
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
|
||||
}
|
||||
catch (const ObjectLoadException&)
|
||||
{
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
|
||||
}
|
||||
catch (const IOException& loadError)
|
||||
{
|
||||
log_error("Error loading: %s", loadError.what());
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_GAME_SAVE_FAILED);
|
||||
}
|
||||
catch (const UnsupportedRideTypeException&)
|
||||
{
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_UNSUPPORTED_RIDE_TYPES);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00676053
|
||||
* scenario (ebx)
|
||||
*/
|
||||
void load_from_sc6(const char* path)
|
||||
{
|
||||
auto context = OpenRCT2::GetContext();
|
||||
auto& objManager = context->GetObjectManager();
|
||||
auto s6Importer = std::make_unique<RCT2::S6Importer>(context->GetObjectRepository());
|
||||
try
|
||||
{
|
||||
auto result = s6Importer->LoadScenario(path);
|
||||
objManager.LoadObjects(result.RequiredObjects);
|
||||
s6Importer->Import();
|
||||
game_fix_save_vars();
|
||||
MapAnimationAutoCreate();
|
||||
EntityTweener::Get().Reset();
|
||||
return;
|
||||
}
|
||||
catch (const ObjectLoadException& loadError)
|
||||
{
|
||||
log_error("Error loading: %s", loadError.what());
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_GAME_SAVE_FAILED);
|
||||
}
|
||||
catch (const IOException& loadError)
|
||||
{
|
||||
log_error("Error loading: %s", loadError.what());
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_GAME_SAVE_FAILED);
|
||||
}
|
||||
catch (const std::exception&)
|
||||
{
|
||||
show_error(ERROR_TYPE_FILE_LOAD, STR_FILE_CONTAINS_INVALID_DATA);
|
||||
}
|
||||
gScreenAge = 0;
|
||||
gLastAutoSaveUpdate = AUTOSAVE_PAUSE;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,6 @@ extern uint32_t gLastAutoSaveUpdate;
|
|||
|
||||
extern std::string gScenarioFileName;
|
||||
|
||||
void load_from_sc6(const char* path);
|
||||
void scenario_begin();
|
||||
void scenario_reset();
|
||||
void scenario_update();
|
||||
|
|
|
@ -41,7 +41,7 @@ TEST(MultiLaunchTest, all)
|
|||
bool initialised = context->Initialise();
|
||||
ASSERT_TRUE(initialised);
|
||||
|
||||
load_from_sv6(path.c_str());
|
||||
GetContext()->LoadParkFromFile(path);
|
||||
game_load_init();
|
||||
|
||||
// Check ride count to check load was successful
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
ASSERT_TRUE(initialised);
|
||||
|
||||
std::string parkPath = TestData::GetParkPath("pathfinding-tests.sv6");
|
||||
load_from_sv6(parkPath.c_str());
|
||||
GetContext()->LoadParkFromFile(parkPath);
|
||||
game_load_init();
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ TEST_F(RideRatings, all)
|
|||
bool initialised = context->Initialise();
|
||||
ASSERT_TRUE(initialised);
|
||||
|
||||
load_from_sv6(path.c_str());
|
||||
GetContext()->LoadParkFromFile(path);
|
||||
|
||||
// Check ride count to check load was successful
|
||||
ASSERT_EQ(ride_get_count(), 134);
|
||||
|
|
|
@ -32,7 +32,7 @@ protected:
|
|||
bool initialised = _context->Initialise();
|
||||
ASSERT_TRUE(initialised);
|
||||
|
||||
load_from_sv6(parkPath.c_str());
|
||||
GetContext()->LoadParkFromFile(parkPath);
|
||||
game_load_init();
|
||||
|
||||
// Changed in some tests. Store to restore its value
|
||||
|
|
|
@ -33,7 +33,7 @@ protected:
|
|||
bool initialised = _context->Initialise();
|
||||
ASSERT_TRUE(initialised);
|
||||
|
||||
load_from_sv6(parkPath.c_str());
|
||||
GetContext()->LoadParkFromFile(parkPath);
|
||||
game_load_init();
|
||||
|
||||
// Changed in some tests. Store to restore its value
|
||||
|
|
Loading…
Reference in New Issue