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
|
||||
|
||||
#include "../core/Console.hpp"
|
||||
#include "../network/network.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "TitleScreen.h"
|
||||
|
@ -44,12 +45,11 @@ extern "C"
|
|||
}
|
||||
|
||||
static sint32 _sequenceAttemptId;
|
||||
static sint32 _loadedTitleSequenceId = -1;
|
||||
static uint16 _loadedTitleSequenceId = UINT16_MAX;
|
||||
static ITitleSequencePlayer * _sequencePlayer = nullptr;
|
||||
|
||||
static void TitleInitialise();
|
||||
static void TryLoadSequence();
|
||||
static void TryNextSequence();
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -78,22 +78,28 @@ static void TryLoadSequence()
|
|||
{
|
||||
if (_loadedTitleSequenceId != gTitleCurrentSequence)
|
||||
{
|
||||
if (_sequencePlayer->Begin(gTitleCurrentSequence))
|
||||
uint16 numSequences = (uint16)TitleSequenceManager::GetCount();
|
||||
if (numSequences > 0)
|
||||
{
|
||||
_loadedTitleSequenceId = gTitleCurrentSequence;
|
||||
uint16 targetSequence = gTitleCurrentSequence;
|
||||
do
|
||||
{
|
||||
if (_sequencePlayer->Begin(targetSequence) && _sequencePlayer->Update())
|
||||
{
|
||||
_loadedTitleSequenceId = targetSequence;
|
||||
gTitleCurrentSequence = targetSequence;
|
||||
gfx_invalidate_screen();
|
||||
return;
|
||||
}
|
||||
targetSequence = (targetSequence + 1) % numSequences;
|
||||
}
|
||||
while (targetSequence != gTitleCurrentSequence);
|
||||
}
|
||||
|
||||
static void TryNextSequence()
|
||||
{
|
||||
gTitleCurrentSequence = _sequenceAttemptId++;
|
||||
if (_sequenceAttemptId >= (sint32)TitleSequenceManager::GetCount())
|
||||
{
|
||||
_sequenceAttemptId = 0;
|
||||
Console::Error::WriteLine("Unable to play any title sequences.");
|
||||
_sequencePlayer->Eject();
|
||||
gTitleCurrentSequence = UINT16_MAX;
|
||||
_loadedTitleSequenceId = UINT16_MAX;
|
||||
}
|
||||
TryLoadSequence();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
|
@ -176,10 +182,6 @@ extern "C"
|
|||
if (game_is_not_paused())
|
||||
{
|
||||
TryLoadSequence();
|
||||
if (_sequencePlayer != nullptr && !_sequencePlayer->Update())
|
||||
{
|
||||
TryNextSequence();
|
||||
}
|
||||
|
||||
sint32 numUpdates = 1;
|
||||
if (gGameSpeed > 1) {
|
||||
|
|
|
@ -58,6 +58,8 @@ extern "C"
|
|||
std::vector<utf8 *> saves;
|
||||
bool isZip;
|
||||
|
||||
log_verbose("Loading title sequence: %s", path);
|
||||
|
||||
const utf8 * ext = Path::GetExtension(path);
|
||||
if (String::Equals(ext, TITLE_SEQUENCE_EXTENSION))
|
||||
{
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
public:
|
||||
~TitleSequencePlayer() override
|
||||
{
|
||||
FreeTitleSequence(_sequence);
|
||||
Eject();
|
||||
}
|
||||
|
||||
sint32 GetCurrentPosition() const override
|
||||
|
@ -58,6 +58,12 @@ public:
|
|||
return _position;
|
||||
}
|
||||
|
||||
void Eject() override
|
||||
{
|
||||
FreeTitleSequence(_sequence);
|
||||
_sequence = nullptr;
|
||||
}
|
||||
|
||||
bool Begin(uint32 titleSequenceId) override
|
||||
{
|
||||
size_t numSequences = TitleSequenceManager::GetCount();
|
||||
|
@ -73,7 +79,7 @@ public:
|
|||
return false;
|
||||
}
|
||||
|
||||
FreeTitleSequence(_sequence);
|
||||
Eject();
|
||||
_sequence = sequence;
|
||||
_sequenceId = titleSequenceId;
|
||||
|
||||
|
@ -124,13 +130,19 @@ public:
|
|||
break;
|
||||
}
|
||||
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
|
||||
{
|
||||
SkipToNextLoadCommand();
|
||||
if (_position == entryPosition)
|
||||
{
|
||||
// Unable to load any of the parks
|
||||
Console::Error::WriteLine("Unable to load any parks within title sequence.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +155,6 @@ public:
|
|||
{
|
||||
_position = 0;
|
||||
_waitCounter = 0;
|
||||
Update();
|
||||
}
|
||||
|
||||
void Seek(sint32 targetPosition) override
|
||||
|
|
|
@ -30,6 +30,7 @@ interface ITitleSequencePlayer
|
|||
virtual void Reset() abstract;
|
||||
virtual bool Update() abstract;
|
||||
virtual void Seek(sint32 position) abstract;
|
||||
virtual void Eject() abstract;
|
||||
};
|
||||
|
||||
ITitleSequencePlayer * CreateTitleSequencePlayer();
|
||||
|
|
Loading…
Reference in New Issue