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;
|
uint16 mapSize = _s4.map_size == 0 ? 128 : _s4.map_size;
|
||||||
|
|
||||||
// Do map initialisation, same kind of stuff done when loading scenario editor
|
// Do map initialisation, same kind of stuff done when loading scenario editor
|
||||||
audio_stop_all_music_and_sounds();
|
|
||||||
GetObjectManager()->UnloadAll();
|
GetObjectManager()->UnloadAll();
|
||||||
game_init_all(mapSize);
|
game_init_all(mapSize);
|
||||||
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
gS6Info.editor_step = EDITOR_STEP_OBJECT_SELECTION;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "../core/Math.hpp"
|
#include "../core/Math.hpp"
|
||||||
#include "../core/Path.hpp"
|
#include "../core/Path.hpp"
|
||||||
#include "../core/String.hpp"
|
#include "../core/String.hpp"
|
||||||
|
#include "../rct1/S4Importer.h"
|
||||||
#include "../scenario/ScenarioRepository.h"
|
#include "../scenario/ScenarioRepository.h"
|
||||||
#include "../scenario/ScenarioSources.h"
|
#include "../scenario/ScenarioSources.h"
|
||||||
#include "TitleSequence.h"
|
#include "TitleSequence.h"
|
||||||
|
@ -352,12 +353,40 @@ private:
|
||||||
bool LoadParkFromFile(const utf8 * path)
|
bool LoadParkFromFile(const utf8 * path)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
bool isScenario = String::Equals(Path::GetExtension(path), ".sc6", true);
|
const utf8 * extension = Path::GetExtension(path);
|
||||||
SDL_RWops * rw = SDL_RWFromFile(path, "rb");
|
if (String::Equals(extension, ".sc4", true) ||
|
||||||
if (rw != nullptr)
|
String::Equals(extension, ".sv4", true))
|
||||||
{
|
{
|
||||||
success = LoadParkFromRW(rw, isScenario);
|
try
|
||||||
SDL_RWclose(rw);
|
{
|
||||||
|
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;
|
return success;
|
||||||
}
|
}
|
||||||
|
@ -366,11 +395,15 @@ private:
|
||||||
{
|
{
|
||||||
bool successfulLoad = isScenario ? scenario_load_rw(rw) :
|
bool successfulLoad = isScenario ? scenario_load_rw(rw) :
|
||||||
game_load_sv6(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();
|
rct_window * w = window_get_main();
|
||||||
w->viewport_target_sprite = -1;
|
w->viewport_target_sprite = -1;
|
||||||
w->saved_view_x = gSavedViewX;
|
w->saved_view_x = gSavedViewX;
|
||||||
|
@ -410,7 +443,6 @@ private:
|
||||||
gfx_invalidate_screen();
|
gfx_invalidate_screen();
|
||||||
gScreenAge = 0;
|
gScreenAge = 0;
|
||||||
gGameSpeed = 1;
|
gGameSpeed = 1;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue