Save game SV5 checksum calculation

Discuss, get help with, or post new modifications, graphics or related tools for Locomotion in this forum.

Moderator: Locomotion Moderators

Post Reply
2kan
Engineer
Engineer
Posts: 5
Joined: 27 Nov 2016 03:26

Save game SV5 checksum calculation

Post by 2kan »

Hi all,

I'm working on a save game editor for fun but I've run across an issue with calculating the checksum of the save game.

I've read that loco uses (more or less) the same save file encoding as RCT2's SV6 files and the RCT Tech Info Depot states that "The last four bytes of the file is a simple checksum - formed by starting with zero and adding each byte of the file to a 32 bit variable."

I'm able to successfully decode and re-encode the save data, however the checksum doesn't actually seem to be the sum of all bytes in the file. I know this because I have a normal save file that has a checksum of 8381400b (2206285835 in decimal) but when I calculate the sum of all the bytes from either the decoded or encoded file, I only end up with 188777170 and 157339111 in decimal -- more than 11 times less than what I expected.

Does anyone have any insight into how the save file checksum is generated? Am I missing something?

Thanks
User avatar
Greyfox
Route Supervisor
Route Supervisor
Posts: 417
Joined: 19 Jun 2009 14:47
Location: Victoria, Australia

Re: Save game SV5 checksum calculation

Post by Greyfox »

Hello 2kan, and welcome to the forums.

After using an online search tool, I came up with this: http://www.checksumcalculator.com/

I'm not sure if this will help you, but I hope it does. I cannot offer any further info.

Good luck

Cheers.
Windows 10 discussion here: http://www.tt-forums.net/viewtopic.php?f=2&t=72527
Looking for AMI trains, Chicago Locomotive Works, etc: You'll find your needs here: http://www.locomotiondepot.net/
Here's another: http://www.walter1940.de Lots of interesting stuff on this site, including tutorials.
__________________________
"Don't badger the Badger"....(Retired Moderator)
2kan
Engineer
Engineer
Posts: 5
Joined: 27 Nov 2016 03:26

Re: Save game SV5 checksum calculation

Post by 2kan »

Thanks Greyfox, but the checksum algorithm in loco wouldn't be something general like what the link provides. I'll try hashing it just in case though.

Given that Chris Sawyer was pretty much the only developer on the game, it'd be a fair bet to say that the checksum was something he thought of and implemented himself.
2kan
Engineer
Engineer
Posts: 5
Joined: 27 Nov 2016 03:26

Re: Save game SV5 checksum calculation

Post by 2kan »

Hashing the sum with MD5 or SHA1 didn't work, nor did hashing the contents.

Bummer.
2kan
Engineer
Engineer
Posts: 5
Joined: 27 Nov 2016 03:26

Re: Save game SV5 checksum calculation

Post by 2kan »

Okay it turns out that I was reading the checksum hash backwards. Instead of that ridiculously large value I posted earlier, it should be 188776835.

Summing the encoded data from each of the chunks (without the header) gives me 188776823 (difference of -12). Performing the same calculation on a different save file with checksum value of 184093318 gives me 184093801 (difference of 483).... so I'm getting closer. I just need to figure out what makes the difference. It can't be the header data as they're only five bytes long and wouldn't contribute to a difference of almost 500 since the second file was an earlier save of the save I'm using to test. Also because tried it with the header and I get much larger values from my checksum calculation.
2kan
Engineer
Engineer
Posts: 5
Joined: 27 Nov 2016 03:26

Re: Save game SV5 checksum calculation

Post by 2kan »

Never mind.

It is the sum of the bytes.

Reading the hex backwards caused me to over think this.

At least this is confirmation that loco uses the same checksum calculation as RCT2 SV6 files.

:|
Post Reply

Return to “Locomotion Graphics, Modifications & Tools”

Who is online

Users browsing this forum: No registered users and 24 guests