MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / CheckSRAND

Method CheckSRAND

src/openrct2/network/NetworkBase.cpp:845–877  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

843 }
844
845 bool NetworkBase::CheckSRAND(uint32_t tick, uint32_t srand0)
846 {
847 // We have to wait for the map to be loaded first, ticks may match current loaded map.
848 if (!_clientMapLoaded)
849 return true;
850
851 auto itTickData = _serverTickData.find(tick);
852 if (itTickData == std::end(_serverTickData))
853 return true;
854
855 const ServerTickData storedTick = itTickData->second;
856 _serverTickData.erase(itTickData);
857
858 if (storedTick.srand0 != srand0)
859 {
860 LOG_INFO("Srand0 mismatch, client = %08X, server = %08X", srand0, storedTick.srand0);
861 return false;
862 }
863
864 if (!storedTick.spriteHash.empty())
865 {
866 EntitiesChecksum checksum = getGameState().entities.GetAllEntitiesChecksum();
867 std::string clientSpriteHash = checksum.ToString();
868 if (clientSpriteHash != storedTick.spriteHash)
869 {
870 LOG_INFO(
871 "Sprite hash mismatch, client = %s, server = %s", clientSpriteHash.c_str(), storedTick.spriteHash.c_str());
872 return false;
873 }
874 }
875
876 return true;
877 }
878
879 bool NetworkBase::IsDesynchronised() const noexcept
880 {

Callers

nothing calls this directly

Calls 4

findMethod · 0.80
emptyMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected