MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / bitWiseLogDivergence

Function bitWiseLogDivergence

src/OpenLoco/src/GameSaveCompare.cpp:49–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48 template<typename T1, typename T2>
49 long bitWiseLogDivergence(const std::string type, const T1& lhs, const T2& rhs, bool displayAllDivergences, long divergentBytesTotal)
50 {
51 static_assert(sizeof(T1) == sizeof(T2));
52
53 std::span<const std::byte> bytesSpanLhs = getBytesSpan(lhs);
54 std::span<const std::byte> bytesSpanRhs = getBytesSpan(rhs);
55
56 size_t size = bytesSpanLhs.size();
57
58 for (size_t offset = 0; offset < size; offset++)
59 {
60 if (bytesSpanLhs[offset] != bytesSpanRhs[offset])
61 {
62 if (divergentBytesTotal == 0)
63 {
64 Logging::info("DIVERGENCE");
65 Logging::info("TYPE: {}", type);
66 }
67 if (displayAllDivergences || divergentBytesTotal == 0)
68 {
69 Logging::info(" OFFSET: {}", offset);
70 Logging::info(" LHS: {:#x}", bytesSpanLhs[offset]);
71 Logging::info(" RHS: {:#x}", bytesSpanRhs[offset]);
72 }
73 divergentBytesTotal++;
74 }
75 }
76 return divergentBytesTotal;
77 }
78
79 template<typename T1, typename T2>
80 bool isLoggedDivergence(const std::string type, const T1& lhs, const T2& rhs, bool displayAllDivergences)

Callers 4

isLoggedDivergenceFunction · 0.85
logDivergenceFunction · 0.85
logDivergentEntityOffsetFunction · 0.85
compareElementsFunction · 0.85

Calls 3

getBytesSpanFunction · 0.85
infoFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected