1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Use reference types in TitleSequencePlayer

This commit is contained in:
Ted John
2018-05-31 12:49:09 +01:00
parent 9d617958cf
commit 056b596124
5 changed files with 16 additions and 18 deletions

View File

@@ -453,7 +453,7 @@ namespace OpenRCT2
_gameState = std::make_unique<GameState>();
_gameState->InitAll(150);
_titleScreen = std::make_unique<TitleScreen>(_gameState.get());
_titleScreen = std::make_unique<TitleScreen>(*_gameState);
return true;
}

View File

@@ -41,7 +41,7 @@ using namespace OpenRCT2;
// TODO Remove when no longer required.
static TitleScreen * _singleton = nullptr;
TitleScreen::TitleScreen(GameState * gameState)
TitleScreen::TitleScreen(GameState& gameState)
: _gameState(gameState)
{
_singleton = this;
@@ -174,7 +174,7 @@ void TitleScreen::Update()
}
for (sint32 i = 0; i < numUpdates; i++)
{
_gameState->UpdateLogic();
_gameState.UpdateLogic();
}
update_palette_effects();
// update_rain_animation();
@@ -227,8 +227,8 @@ void TitleScreen::TitleInitialise()
{
if (_sequencePlayer == nullptr)
{
IScenarioRepository * scenarioRepository = GetScenarioRepository();
_sequencePlayer = CreateTitleSequencePlayer(scenarioRepository, _gameState);
auto scenarioRepository = GetScenarioRepository();
_sequencePlayer = CreateTitleSequencePlayer(*scenarioRepository, _gameState);
}
size_t seqId = title_get_config_sequence();
if (seqId == SIZE_MAX)

View File

@@ -29,7 +29,7 @@ namespace OpenRCT2
class TitleScreen final
{
public:
TitleScreen(GameState * gameState);
TitleScreen(GameState& gameState);
~TitleScreen();
ITitleSequencePlayer * GetSequencePlayer();
@@ -46,7 +46,7 @@ namespace OpenRCT2
void ChangePresetSequence(size_t preset);
private:
GameState * const _gameState;
GameState& _gameState;
ITitleSequencePlayer * _sequencePlayer = nullptr;
size_t _loadedTitleSequenceId = SIZE_MAX;

View File

@@ -50,8 +50,8 @@ class TitleSequencePlayer final : public ITitleSequencePlayer
private:
static constexpr const char * SFMM_FILENAME = "Six Flags Magic Mountain.SC6";
IScenarioRepository * const _scenarioRepository;
GameState * const _gameState;
IScenarioRepository& _scenarioRepository;
GameState& _gameState;
size_t _sequenceId = 0;
TitleSequence * _sequence = nullptr;
@@ -63,12 +63,10 @@ private:
CoordsXY _viewCentreLocation = { 0 };
public:
explicit TitleSequencePlayer(IScenarioRepository * scenarioRepository, GameState * gameState)
explicit TitleSequencePlayer(IScenarioRepository& scenarioRepository, GameState& gameState)
: _scenarioRepository(scenarioRepository),
_gameState(gameState)
{
Guard::ArgumentNotNull(scenarioRepository);
Guard::ArgumentNotNull(gameState);
}
~TitleSequencePlayer() override
@@ -216,7 +214,7 @@ public:
{
if (Update())
{
_gameState->UpdateLogic();
_gameState.UpdateLogic();
}
else
{
@@ -264,7 +262,7 @@ private:
break;
case TITLE_SCRIPT_LOADMM:
{
const scenario_index_entry * entry = _scenarioRepository->GetByFilename(SFMM_FILENAME);
const scenario_index_entry * entry = _scenarioRepository.GetByFilename(SFMM_FILENAME);
if (entry == nullptr)
{
Console::Error::WriteLine("%s not found.", SFMM_FILENAME);
@@ -332,10 +330,10 @@ private:
}
const utf8 * path = nullptr;
size_t numScenarios = _scenarioRepository->GetCount();
size_t numScenarios = _scenarioRepository.GetCount();
for (size_t i = 0; i < numScenarios; i++)
{
const scenario_index_entry * scenario = _scenarioRepository->GetByIndex(i);
const scenario_index_entry * scenario = _scenarioRepository.GetByIndex(i);
if (scenario && scenario->source_index == sourceDesc.index)
{
path = scenario->path;
@@ -591,7 +589,7 @@ private:
}
};
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository * scenarioRepository, GameState * gameState)
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository& scenarioRepository, GameState& gameState)
{
return new TitleSequencePlayer(scenarioRepository, gameState);
}

View File

@@ -38,7 +38,7 @@ interface ITitleSequencePlayer
virtual void Eject() abstract;
};
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository * scenarioRepository, OpenRCT2::GameState * gameState);
ITitleSequencePlayer * CreateTitleSequencePlayer(IScenarioRepository& scenarioRepository, OpenRCT2::GameState& gameState);
// When testing title sequences within a normal game
extern bool gPreviewingTitleSequenceInGame;