mirror of https://github.com/OpenRCT2/OpenRCT2.git
Allow SC4s to be loaded by title seq player
This commit is contained in:
parent
daaf6c69a3
commit
612e268e5f
|
@ -227,7 +227,6 @@ private:
|
|||
uint16 mapSize = _s4.map_size == 0 ? 128 : _s4.map_size;
|
||||
|
||||
// Do map initialisation, same kind of stuff done when loading scenario editor
|
||||
audio_stop_all_music_and_sounds();
|
||||
GetObjectManager()->UnloadAll();
|
||||
game_init_all(mapSize);
|
||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "../core/Math.hpp"
|
||||
#include "../core/Path.hpp"
|
||||
#include "../core/String.hpp"
|
||||
#include "../rct1/S4Importer.h"
|
||||
#include "../scenario/ScenarioRepository.h"
|
||||
#include "../scenario/ScenarioSources.h"
|
||||
#include "TitleSequence.h"
|
||||
|
@ -352,12 +353,40 @@ private:
|
|||
bool LoadParkFromFile(const utf8 * path)
|
||||
{
|
||||
bool success = false;
|
||||
bool isScenario = String::Equals(Path::GetExtension(path), ".sc6", true);
|
||||
SDL_RWops * rw = SDL_RWFromFile(path, "rb");
|
||||
if (rw != nullptr)
|
||||
const utf8 * extension = Path::GetExtension(path);
|
||||
if (String::Equals(extension, ".sc4", true) ||
|
||||
String::Equals(extension, ".sv4", true))
|
||||
{
|
||||
success = LoadParkFromRW(rw, isScenario);
|
||||
SDL_RWclose(rw);
|
||||
try
|
||||
{
|
||||
bool isScenario = String::Equals(extension, ".sc4", true);
|
||||
IS4Importer * s4Importer = CreateS4Importer();
|
||||
if (isScenario)
|
||||
{
|
||||
s4Importer->LoadScenario(path);
|
||||
s4Importer->Import();
|
||||
}
|
||||
else
|
||||
{
|
||||
s4Importer->LoadSavedGame(path);
|
||||
s4Importer->Import();
|
||||
}
|
||||
PrepareParkForPlayback(isScenario);
|
||||
success = true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isScenario = String::Equals(extension, ".sc6", true);
|
||||
SDL_RWops * rw = SDL_RWFromFile(path, "rb");
|
||||
if (rw != nullptr)
|
||||
{
|
||||
success = LoadParkFromRW(rw, isScenario);
|
||||
SDL_RWclose(rw);
|
||||
}
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
@ -366,11 +395,15 @@ private:
|
|||
{
|
||||
bool successfulLoad = isScenario ? scenario_load_rw(rw) :
|
||||
game_load_sv6(rw);
|
||||
if (!successfulLoad)
|
||||
if (successfulLoad)
|
||||
{
|
||||
return false;
|
||||
PrepareParkForPlayback(isScenario);
|
||||
}
|
||||
return successfulLoad;
|
||||
}
|
||||
|
||||
void PrepareParkForPlayback(bool isScenario)
|
||||
{
|
||||
rct_window * w = window_get_main();
|
||||
w->viewport_target_sprite = -1;
|
||||
w->saved_view_x = gSavedViewX;
|
||||
|
@ -410,7 +443,6 @@ private:
|
|||
gfx_invalidate_screen();
|
||||
gScreenAge = 0;
|
||||
gGameSpeed = 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue