mirror of https://github.com/OpenRCT2/OpenRCT2.git
Fix #4902: Title Sequences hang when no waits are in, or loading single save
This commit is contained in:
parent
c2d2a515b4
commit
463ec2025a
|
@ -14,6 +14,7 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
|
#include "../core/Console.hpp"
|
||||||
#include "../network/network.h"
|
#include "../network/network.h"
|
||||||
#include "../OpenRCT2.h"
|
#include "../OpenRCT2.h"
|
||||||
#include "TitleScreen.h"
|
#include "TitleScreen.h"
|
||||||
|
@ -44,12 +45,11 @@ extern "C"
|
||||||
}
|
}
|
||||||
|
|
||||||
static sint32 _sequenceAttemptId;
|
static sint32 _sequenceAttemptId;
|
||||||
static sint32 _loadedTitleSequenceId = -1;
|
static uint16 _loadedTitleSequenceId = UINT16_MAX;
|
||||||
static ITitleSequencePlayer * _sequencePlayer = nullptr;
|
static ITitleSequencePlayer * _sequencePlayer = nullptr;
|
||||||
|
|
||||||
static void TitleInitialise();
|
static void TitleInitialise();
|
||||||
static void TryLoadSequence();
|
static void TryLoadSequence();
|
||||||
static void TryNextSequence();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -78,24 +78,30 @@ static void TryLoadSequence()
|
||||||
{
|
{
|
||||||
if (_loadedTitleSequenceId != gTitleCurrentSequence)
|
if (_loadedTitleSequenceId != gTitleCurrentSequence)
|
||||||
{
|
{
|
||||||
if (_sequencePlayer->Begin(gTitleCurrentSequence))
|
uint16 numSequences = (uint16)TitleSequenceManager::GetCount();
|
||||||
|
if (numSequences > 0)
|
||||||
{
|
{
|
||||||
_loadedTitleSequenceId = gTitleCurrentSequence;
|
uint16 targetSequence = gTitleCurrentSequence;
|
||||||
gfx_invalidate_screen();
|
do
|
||||||
|
{
|
||||||
|
if (_sequencePlayer->Begin(targetSequence) && _sequencePlayer->Update())
|
||||||
|
{
|
||||||
|
_loadedTitleSequenceId = targetSequence;
|
||||||
|
gTitleCurrentSequence = targetSequence;
|
||||||
|
gfx_invalidate_screen();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
targetSequence = (targetSequence + 1) % numSequences;
|
||||||
|
}
|
||||||
|
while (targetSequence != gTitleCurrentSequence);
|
||||||
}
|
}
|
||||||
|
Console::Error::WriteLine("Unable to play any title sequences.");
|
||||||
|
_sequencePlayer->Eject();
|
||||||
|
gTitleCurrentSequence = UINT16_MAX;
|
||||||
|
_loadedTitleSequenceId = UINT16_MAX;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TryNextSequence()
|
|
||||||
{
|
|
||||||
gTitleCurrentSequence = _sequenceAttemptId++;
|
|
||||||
if (_sequenceAttemptId >= (sint32)TitleSequenceManager::GetCount())
|
|
||||||
{
|
|
||||||
_sequenceAttemptId = 0;
|
|
||||||
}
|
|
||||||
TryLoadSequence();
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -176,10 +182,6 @@ extern "C"
|
||||||
if (game_is_not_paused())
|
if (game_is_not_paused())
|
||||||
{
|
{
|
||||||
TryLoadSequence();
|
TryLoadSequence();
|
||||||
if (_sequencePlayer != nullptr && !_sequencePlayer->Update())
|
|
||||||
{
|
|
||||||
TryNextSequence();
|
|
||||||
}
|
|
||||||
|
|
||||||
sint32 numUpdates = 1;
|
sint32 numUpdates = 1;
|
||||||
if (gGameSpeed > 1) {
|
if (gGameSpeed > 1) {
|
||||||
|
|
|
@ -58,6 +58,8 @@ extern "C"
|
||||||
std::vector<utf8 *> saves;
|
std::vector<utf8 *> saves;
|
||||||
bool isZip;
|
bool isZip;
|
||||||
|
|
||||||
|
log_verbose("Loading title sequence: %s", path);
|
||||||
|
|
||||||
const utf8 * ext = Path::GetExtension(path);
|
const utf8 * ext = Path::GetExtension(path);
|
||||||
if (String::Equals(ext, TITLE_SEQUENCE_EXTENSION))
|
if (String::Equals(ext, TITLE_SEQUENCE_EXTENSION))
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,14 +50,20 @@ private:
|
||||||
public:
|
public:
|
||||||
~TitleSequencePlayer() override
|
~TitleSequencePlayer() override
|
||||||
{
|
{
|
||||||
FreeTitleSequence(_sequence);
|
Eject();
|
||||||
}
|
}
|
||||||
|
|
||||||
sint32 GetCurrentPosition() const override
|
sint32 GetCurrentPosition() const override
|
||||||
{
|
{
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Eject() override
|
||||||
|
{
|
||||||
|
FreeTitleSequence(_sequence);
|
||||||
|
_sequence = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
bool Begin(uint32 titleSequenceId) override
|
bool Begin(uint32 titleSequenceId) override
|
||||||
{
|
{
|
||||||
size_t numSequences = TitleSequenceManager::GetCount();
|
size_t numSequences = TitleSequenceManager::GetCount();
|
||||||
|
@ -73,7 +79,7 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FreeTitleSequence(_sequence);
|
Eject();
|
||||||
_sequence = sequence;
|
_sequence = sequence;
|
||||||
_sequenceId = titleSequenceId;
|
_sequenceId = titleSequenceId;
|
||||||
|
|
||||||
|
@ -124,13 +130,19 @@ public:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
IncrementPosition();
|
IncrementPosition();
|
||||||
|
if (_position == entryPosition)
|
||||||
|
{
|
||||||
|
Console::Error::WriteLine("Infinite loop detected in title sequence.");
|
||||||
|
Console::Error::WriteLine(" A wait command may be missing.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SkipToNextLoadCommand();
|
SkipToNextLoadCommand();
|
||||||
if (_position == entryPosition)
|
if (_position == entryPosition)
|
||||||
{
|
{
|
||||||
// Unable to load any of the parks
|
Console::Error::WriteLine("Unable to load any parks within title sequence.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,7 +155,6 @@ public:
|
||||||
{
|
{
|
||||||
_position = 0;
|
_position = 0;
|
||||||
_waitCounter = 0;
|
_waitCounter = 0;
|
||||||
Update();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Seek(sint32 targetPosition) override
|
void Seek(sint32 targetPosition) override
|
||||||
|
|
|
@ -30,6 +30,7 @@ interface ITitleSequencePlayer
|
||||||
virtual void Reset() abstract;
|
virtual void Reset() abstract;
|
||||||
virtual bool Update() abstract;
|
virtual bool Update() abstract;
|
||||||
virtual void Seek(sint32 position) abstract;
|
virtual void Seek(sint32 position) abstract;
|
||||||
|
virtual void Eject() abstract;
|
||||||
};
|
};
|
||||||
|
|
||||||
ITitleSequencePlayer * CreateTitleSequencePlayer();
|
ITitleSequencePlayer * CreateTitleSequencePlayer();
|
||||||
|
|
Loading…
Reference in New Issue