Test all full hashes in non-visual replaymode by default and keep skipping quick-hash by default.

The previous code only tested quick hashes every 100 turns and could not
be used to confirm replay hashes matching.
The option can become used for visual replays too.

Differential Revision: https://code.wildfiregames.com/D1538
Refs #5162
Reviewed By: temple
This was SVN commit r21829.
This commit is contained in:
elexis
2018-05-29 02:14:38 +00:00
parent 572b72fa7f
commit 333766ef1b
4 changed files with 28 additions and 18 deletions
+20 -15
View File
@@ -167,7 +167,8 @@ void CReplayPlayer::CheckReplayMods(const ScriptInterface& scriptInterface, JS::
if (!warn.empty())
LOGWARNING("%s\nThe mods of the replay are:\n%s\nThese mods are enabled:\n%s", warn, ModListToString(replayMods), ModListToString(enabledMods));
}
void CReplayPlayer::Replay(bool serializationtest, int rejointestturn, bool ooslog)
void CReplayPlayer::Replay(const bool serializationtest, const int rejointestturn, const bool ooslog, const bool testHashFull, const bool testHashQuick)
{
ENSURE(m_Stream);
@@ -247,20 +248,7 @@ void CReplayPlayer::Replay(bool serializationtest, int rejointestturn, bool oosl
{
std::string replayHash;
*m_Stream >> replayHash;
bool quick = (type == "hash-quick");
if (turn % 100 == 0)
{
std::string hash;
bool ok = g_Game->GetSimulation2()->ComputeStateHash(hash, quick);
ENSURE(ok);
std::string hexHash = Hexify(hash);
if (hexHash == replayHash)
debug_printf("hash ok (%s)\n", hexHash.c_str());
else
debug_printf("HASH MISMATCH (%s != %s)\n", hexHash.c_str(), replayHash.c_str());
}
TestHash(type, replayHash, testHashFull, testHashQuick);
}
else if (type == "end")
{
@@ -307,3 +295,20 @@ void CReplayPlayer::Replay(bool serializationtest, int rejointestturn, bool oosl
delete &g_ProfileViewer;
SAFE_DELETE(g_ScriptStatsTable);
}
void CReplayPlayer::TestHash(const std::string& hashType, const std::string& replayHash, const bool testHashFull, const bool testHashQuick)
{
bool quick = (hashType == "hash-quick");
if ((quick && !testHashQuick) || (!quick && !testHashFull))
return;
std::string hash;
ENSURE(g_Game->GetSimulation2()->ComputeStateHash(hash, quick));
std::string hexHash = Hexify(hash);
if (hexHash == replayHash)
debug_printf("%s ok (%s)\n", hashType.c_str(), hexHash.c_str());
else
debug_printf("%s MISMATCH (%s != %s)\n", hashType.c_str(), hexHash.c_str(), replayHash.c_str());
}