1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Fix replays not failing when last tick is the cause (#13834)

* Fix replays never failing

* Change replay dependency meta

* Stop replay when state mismatches
This commit is contained in:
ζeh Matt
2021-01-14 15:48:12 +02:00
committed by GitHub
parent f1ea718ded
commit 78f6e3e8e3
4 changed files with 19 additions and 9 deletions

View File

@@ -44,8 +44,8 @@ set(TITLE_SEQUENCE_SHA1 "304d13a126c15bf2c86ff13b81a2f2cc1856ac8d")
set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.20/objects.zip") set(OBJECTS_URL "https://github.com/OpenRCT2/objects/releases/download/v1.0.20/objects.zip")
set(OBJECTS_SHA1 "151424d24b1d49a167932b58319bedaa6ec368e9") set(OBJECTS_SHA1 "151424d24b1d49a167932b58319bedaa6ec368e9")
set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.25/replays.zip") set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.27/replays.zip")
set(REPLAYS_SHA1 "DA3E595E4D0231934F1DCFC3B540097CE2ED1B17") set(REPLAYS_SHA1 "CC0BE0C9B9829062B67E1CFE14E36BEA1182882D")
option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.")
option(WITH_TESTS "Build tests") option(WITH_TESTS "Build tests")

View File

@@ -48,8 +48,8 @@
<TitleSequencesSha1>304d13a126c15bf2c86ff13b81a2f2cc1856ac8d</TitleSequencesSha1> <TitleSequencesSha1>304d13a126c15bf2c86ff13b81a2f2cc1856ac8d</TitleSequencesSha1>
<ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.0.20/objects.zip</ObjectsUrl> <ObjectsUrl>https://github.com/OpenRCT2/objects/releases/download/v1.0.20/objects.zip</ObjectsUrl>
<ObjectsSha1>151424d24b1d49a167932b58319bedaa6ec368e9</ObjectsSha1> <ObjectsSha1>151424d24b1d49a167932b58319bedaa6ec368e9</ObjectsSha1>
<ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.25/replays.zip</ReplaysUrl> <ReplaysUrl>https://github.com/OpenRCT2/replays/releases/download/v0.0.27/replays.zip</ReplaysUrl>
<ReplaysSha1>DA3E595E4D0231934F1DCFC3B540097CE2ED1B17</ReplaysSha1> <ReplaysSha1>CC0BE0C9B9829062B67E1CFE14E36BEA1182882D</ReplaysSha1>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -177,7 +177,11 @@ namespace OpenRCT2
#ifndef DISABLE_NETWORK #ifndef DISABLE_NETWORK
// If the network is disabled we will only get a dummy hash which will cause // If the network is disabled we will only get a dummy hash which will cause
// false positives during replay. // false positives during replay.
CheckState(); if (!CheckState())
{
StopPlayback();
return;
}
#endif #endif
ReplayCommands(); ReplayCommands();
@@ -450,8 +454,9 @@ namespace OpenRCT2
virtual bool IsPlaybackStateMismatching() const override virtual bool IsPlaybackStateMismatching() const override
{ {
if (_mode != ReplayMode::PLAYING) if (_mode != ReplayMode::NONE)
{ {
// This state is only valid after the playback.
return false; return false;
} }
return _faultyChecksumIndex != -1; return _faultyChecksumIndex != -1;
@@ -789,12 +794,12 @@ namespace OpenRCT2
} }
#ifndef DISABLE_NETWORK #ifndef DISABLE_NETWORK
void CheckState() bool CheckState()
{ {
uint32_t checksumIndex = _currentReplay->checksumIndex; uint32_t checksumIndex = _currentReplay->checksumIndex;
if (checksumIndex >= _currentReplay->checksums.size()) if (checksumIndex >= _currentReplay->checksums.size())
return; return true;
const auto& savedChecksum = _currentReplay->checksums[checksumIndex]; const auto& savedChecksum = _currentReplay->checksums[checksumIndex];
if (_currentReplay->checksums[checksumIndex].first == gCurrentTicks) if (_currentReplay->checksums[checksumIndex].first == gCurrentTicks)
@@ -810,6 +815,8 @@ namespace OpenRCT2
replayTick, savedChecksum.second.ToString().c_str(), checksum.ToString().c_str()); replayTick, savedChecksum.second.ToString().c_str(), checksum.ToString().c_str());
_faultyChecksumIndex = checksumIndex; _faultyChecksumIndex = checksumIndex;
return false;
} }
else else
{ {
@@ -820,6 +827,8 @@ namespace OpenRCT2
} }
_currentReplay->checksumIndex++; _currentReplay->checksumIndex++;
} }
return true;
} }
#endif // DISABLE_NETWORK #endif // DISABLE_NETWORK

View File

@@ -98,8 +98,9 @@ TEST_P(ReplayTests, RunReplay)
while (replayManager->IsReplaying()) while (replayManager->IsReplaying())
{ {
gs->UpdateLogic(); gs->UpdateLogic();
ASSERT_TRUE(replayManager->IsPlaybackStateMismatching() == false);
} }
ASSERT_FALSE(replayManager->IsReplaying());
ASSERT_FALSE(replayManager->IsPlaybackStateMismatching());
#endif #endif
} }