mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-22 18:31:59 -05:00
Fix replay snapshots comparing states with different ticks
This commit is contained in:
parent
20f959c833
commit
6034cef358
4 changed files with 18 additions and 20 deletions
|
@ -533,7 +533,8 @@ struct GameStateSnapshots final : public IGameStateSnapshots
|
|||
virtual GameStateCompareData_t Compare(const GameStateSnapshot_t& base, const GameStateSnapshot_t& cmp) const override final
|
||||
{
|
||||
GameStateCompareData_t res;
|
||||
res.tick = base.tick;
|
||||
res.tickLeft = base.tick;
|
||||
res.tickRight = cmp.tick;
|
||||
res.srand0Left = base.srand0;
|
||||
res.srand0Right = cmp.srand0;
|
||||
|
||||
|
@ -643,7 +644,13 @@ struct GameStateSnapshots final : public IGameStateSnapshots
|
|||
std::string outputBuffer;
|
||||
char tempBuffer[1024] = {};
|
||||
|
||||
snprintf(tempBuffer, sizeof(tempBuffer), "tick: %08X\n", cmpData.tick);
|
||||
if (cmpData.tickLeft != cmpData.tickRight)
|
||||
{
|
||||
outputBuffer += "WARNING: Comparing two snapshots with different ticks, this will very likely result in false "
|
||||
"positives\n";
|
||||
}
|
||||
|
||||
snprintf(tempBuffer, sizeof(tempBuffer), "tick left = %08X, tick right = %08X\n", cmpData.tickLeft, cmpData.tickRight);
|
||||
outputBuffer += tempBuffer;
|
||||
|
||||
snprintf(
|
||||
|
|
|
@ -48,7 +48,8 @@ struct GameStateSpriteChange_t
|
|||
|
||||
struct GameStateCompareData_t
|
||||
{
|
||||
uint32_t tick;
|
||||
uint32_t tickLeft;
|
||||
uint32_t tickRight;
|
||||
uint32_t srand0Left;
|
||||
uint32_t srand0Right;
|
||||
std::vector<GameStateSpriteChange_t> spriteChanges;
|
||||
|
|
|
@ -177,11 +177,7 @@ namespace OpenRCT2
|
|||
#ifndef DISABLE_NETWORK
|
||||
// If the network is disabled we will only get a dummy hash which will cause
|
||||
// false positives during replay.
|
||||
if (!CheckState())
|
||||
{
|
||||
StopPlayback();
|
||||
return;
|
||||
}
|
||||
CheckState();
|
||||
#endif
|
||||
ReplayCommands();
|
||||
|
||||
|
@ -454,11 +450,6 @@ namespace OpenRCT2
|
|||
|
||||
virtual bool IsPlaybackStateMismatching() const override
|
||||
{
|
||||
if (_mode != ReplayMode::NONE)
|
||||
{
|
||||
// This state is only valid after the playback.
|
||||
return false;
|
||||
}
|
||||
return _faultyChecksumIndex != -1;
|
||||
}
|
||||
|
||||
|
@ -794,16 +785,18 @@ namespace OpenRCT2
|
|||
}
|
||||
|
||||
#ifndef DISABLE_NETWORK
|
||||
bool CheckState()
|
||||
void CheckState()
|
||||
{
|
||||
uint32_t checksumIndex = _currentReplay->checksumIndex;
|
||||
|
||||
if (checksumIndex >= _currentReplay->checksums.size())
|
||||
return true;
|
||||
return;
|
||||
|
||||
const auto& savedChecksum = _currentReplay->checksums[checksumIndex];
|
||||
if (_currentReplay->checksums[checksumIndex].first == gCurrentTicks)
|
||||
{
|
||||
_currentReplay->checksumIndex++;
|
||||
|
||||
rct_sprite_checksum checksum = sprite_checksum();
|
||||
if (savedChecksum.second.raw != checksum.raw)
|
||||
{
|
||||
|
@ -815,8 +808,6 @@ namespace OpenRCT2
|
|||
replayTick, savedChecksum.second.ToString().c_str(), checksum.ToString().c_str());
|
||||
|
||||
_faultyChecksumIndex = checksumIndex;
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -825,10 +816,7 @@ namespace OpenRCT2
|
|||
"Good state at tick %u ; Saved: %s, Current: %s", gCurrentTicks,
|
||||
savedChecksum.second.ToString().c_str(), checksum.ToString().c_str());
|
||||
}
|
||||
_currentReplay->checksumIndex++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif // DISABLE_NETWORK
|
||||
|
||||
|
|
|
@ -98,6 +98,8 @@ TEST_P(ReplayTests, RunReplay)
|
|||
while (replayManager->IsReplaying())
|
||||
{
|
||||
gs->UpdateLogic();
|
||||
if (replayManager->IsPlaybackStateMismatching())
|
||||
break;
|
||||
}
|
||||
ASSERT_FALSE(replayManager->IsReplaying());
|
||||
ASSERT_FALSE(replayManager->IsPlaybackStateMismatching());
|
||||
|
|
Loading…
Reference in a new issue