From 78f6e3e8e36800d016ca7694c40320349acddca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= Date: Thu, 14 Jan 2021 15:48:12 +0200 Subject: [PATCH] Fix replays not failing when last tick is the cause (#13834) * Fix replays never failing * Change replay dependency meta * Stop replay when state mismatches --- CMakeLists.txt | 4 ++-- openrct2.proj | 4 ++-- src/openrct2/ReplayManager.cpp | 17 +++++++++++++---- test/tests/ReplayTests.cpp | 3 ++- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 59593cb79d..f6e21fb8ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_SHA1 "151424d24b1d49a167932b58319bedaa6ec368e9") -set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.25/replays.zip") -set(REPLAYS_SHA1 "DA3E595E4D0231934F1DCFC3B540097CE2ED1B17") +set(REPLAYS_URL "https://github.com/OpenRCT2/replays/releases/download/v0.0.27/replays.zip") +set(REPLAYS_SHA1 "CC0BE0C9B9829062B67E1CFE14E36BEA1182882D") option(FORCE32 "Force 32-bit build. It will add `-m32` to compiler flags.") option(WITH_TESTS "Build tests") diff --git a/openrct2.proj b/openrct2.proj index 83e25c0753..56e9ff602d 100644 --- a/openrct2.proj +++ b/openrct2.proj @@ -48,8 +48,8 @@ 304d13a126c15bf2c86ff13b81a2f2cc1856ac8d https://github.com/OpenRCT2/objects/releases/download/v1.0.20/objects.zip 151424d24b1d49a167932b58319bedaa6ec368e9 - https://github.com/OpenRCT2/replays/releases/download/v0.0.25/replays.zip - DA3E595E4D0231934F1DCFC3B540097CE2ED1B17 + https://github.com/OpenRCT2/replays/releases/download/v0.0.27/replays.zip + CC0BE0C9B9829062B67E1CFE14E36BEA1182882D diff --git a/src/openrct2/ReplayManager.cpp b/src/openrct2/ReplayManager.cpp index f4730ae25d..986e325567 100644 --- a/src/openrct2/ReplayManager.cpp +++ b/src/openrct2/ReplayManager.cpp @@ -177,7 +177,11 @@ namespace OpenRCT2 #ifndef DISABLE_NETWORK // If the network is disabled we will only get a dummy hash which will cause // false positives during replay. - CheckState(); + if (!CheckState()) + { + StopPlayback(); + return; + } #endif ReplayCommands(); @@ -450,8 +454,9 @@ namespace OpenRCT2 virtual bool IsPlaybackStateMismatching() const override { - if (_mode != ReplayMode::PLAYING) + if (_mode != ReplayMode::NONE) { + // This state is only valid after the playback. return false; } return _faultyChecksumIndex != -1; @@ -789,12 +794,12 @@ namespace OpenRCT2 } #ifndef DISABLE_NETWORK - void CheckState() + bool CheckState() { uint32_t checksumIndex = _currentReplay->checksumIndex; if (checksumIndex >= _currentReplay->checksums.size()) - return; + return true; const auto& savedChecksum = _currentReplay->checksums[checksumIndex]; if (_currentReplay->checksums[checksumIndex].first == gCurrentTicks) @@ -810,6 +815,8 @@ namespace OpenRCT2 replayTick, savedChecksum.second.ToString().c_str(), checksum.ToString().c_str()); _faultyChecksumIndex = checksumIndex; + + return false; } else { @@ -820,6 +827,8 @@ namespace OpenRCT2 } _currentReplay->checksumIndex++; } + + return true; } #endif // DISABLE_NETWORK diff --git a/test/tests/ReplayTests.cpp b/test/tests/ReplayTests.cpp index 81d6026719..de5941cc1e 100644 --- a/test/tests/ReplayTests.cpp +++ b/test/tests/ReplayTests.cpp @@ -98,8 +98,9 @@ TEST_P(ReplayTests, RunReplay) while (replayManager->IsReplaying()) { gs->UpdateLogic(); - ASSERT_TRUE(replayManager->IsPlaybackStateMismatching() == false); } + ASSERT_FALSE(replayManager->IsReplaying()); + ASSERT_FALSE(replayManager->IsPlaybackStateMismatching()); #endif }