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

Function EncodeTD6

src/openrct2/sawyer_coding/SawyerCoding.cpp:131–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129 }
130
131 size_t EncodeTD6(const uint8_t* src, uint8_t* dst, size_t length)
132 {
133 size_t output_length = EncodeChunkRLE(src, dst, length);
134
135 uint32_t checksum = 0;
136 for (size_t i = 0; i < output_length; i++)
137 {
138 uint8_t new_byte = ((checksum & 0xFF) + dst[i]) & 0xFF;
139 checksum = (checksum & 0xFFFFFF00) + new_byte;
140 checksum = Numerics::rol32(checksum, 3);
141 }
142 checksum -= 0x1D4C1;
143
144 *(reinterpret_cast<uint32_t*>(&dst[output_length])) = checksum;
145 output_length += 4;
146 return output_length;
147 }
148
149 /* Based off of rct2: 0x006770C1 */
150 int32_t ValidateTrackChecksum(const uint8_t* src, size_t length)

Callers

nothing calls this directly

Calls 1

EncodeChunkRLEFunction · 0.85

Tested by

no test coverage detected