This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 21829 for ps


Ignore:
Timestamp:
05/29/18 04:14:38 (7 years ago)
Author:
elexis
Message:

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

Location:
ps/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/system/readme.txt

    r21726 r21829  
    7979-unique-logs        adds unix timestamp and process id to the filename of mainlog.html, interestinglog.html
    8080                    and oos_dump.txt to prevent these files from becoming overwritten by another pyrogenesis process.
     81-hashtest-full=X    whether to enable computation of full hashes in replaymode (default true). Can be disabled to improve performance.
     82-hashtest-quick=X   whether to enable computation of quick hashes in replaymode (default false). Can be enabled for debugging purposes.
    8183
    8284Windows-specific:
  • ps/trunk/source/main.cpp

    r21818 r21829  
    555555                args.Has("serializationtest"),
    556556                args.Has("rejointest") ? args.Get("rejointest").ToInt() : -1,
    557                 args.Has("ooslog"));
     557                args.Has("ooslog"),
     558                !args.Has("hashtest-full") || args.Get("hashtest-full") == "true",
     559                args.Has("hashtest-quick") && args.Get("hashtest-quick") == "true");
    558560        }
    559561
  • ps/trunk/source/ps/Replay.cpp

    r21823 r21829  
    168168        LOGWARNING("%s\nThe mods of the replay are:\n%s\nThese mods are enabled:\n%s", warn, ModListToString(replayMods), ModListToString(enabledMods));
    169169}
    170 void CReplayPlayer::Replay(bool serializationtest, int rejointestturn, bool ooslog)
     170
     171void CReplayPlayer::Replay(const bool serializationtest, const int rejointestturn, const bool ooslog, const bool testHashFull, const bool testHashQuick)
    171172{
    172173    ENSURE(m_Stream);
     
    248249            std::string replayHash;
    249250            *m_Stream >> replayHash;
    250 
    251             bool quick = (type == "hash-quick");
    252 
    253             if (turn % 100 == 0)
    254             {
    255                 std::string hash;
    256                 bool ok = g_Game->GetSimulation2()->ComputeStateHash(hash, quick);
    257                 ENSURE(ok);
    258                 std::string hexHash = Hexify(hash);
    259                 if (hexHash == replayHash)
    260                     debug_printf("hash ok (%s)\n", hexHash.c_str());
    261                 else
    262                     debug_printf("HASH MISMATCH (%s != %s)\n", hexHash.c_str(), replayHash.c_str());
    263             }
     251            TestHash(type, replayHash, testHashFull, testHashQuick);
    264252        }
    265253        else if (type == "end")
     
    308296    SAFE_DELETE(g_ScriptStatsTable);
    309297}
     298
     299void CReplayPlayer::TestHash(const std::string& hashType, const std::string& replayHash, const bool testHashFull, const bool testHashQuick)
     300{
     301    bool quick = (hashType == "hash-quick");
     302    if ((quick && !testHashQuick) || (!quick && !testHashFull))
     303        return;
     304
     305    std::string hash;
     306    ENSURE(g_Game->GetSimulation2()->ComputeStateHash(hash, quick));
     307
     308    std::string hexHash = Hexify(hash);
     309
     310    if (hexHash == replayHash)
     311        debug_printf("%s ok (%s)\n", hashType.c_str(), hexHash.c_str());
     312    else
     313        debug_printf("%s MISMATCH (%s != %s)\n", hashType.c_str(), hexHash.c_str(), replayHash.c_str());
     314}
  • ps/trunk/source/ps/Replay.h

    r21603 r21829  
    1 /* Copyright (C) 2017 Wildfire Games.
     1/* Copyright (C) 2018 Wildfire Games.
    22 * This file is part of 0 A.D.
    33 *
     
    9999
    100100    void Load(const OsPath& path);
    101     void Replay(bool serializationtest, int rejointestturn, bool ooslog);
     101    void Replay(const bool serializationtest, const int rejointestturn, const bool ooslog, const bool testHashFull, const bool testHashQuick);
    102102
    103103private:
     
    105105    CStr ModListToString(const std::vector<std::vector<CStr>>& list) const;
    106106    void CheckReplayMods(const ScriptInterface& scriptInterface, JS::HandleValue attribs) const;
     107    void TestHash(const std::string& hashType, const std::string& replayHash, const bool testHashFull, const bool testHashQuick);
    107108};
    108109
Note: See TracChangeset for help on using the changeset viewer.