Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Fri Nov 17, 2017 7:36 pm

All times are UTC




Post new topic  Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Sun Nov 27, 2016 3:38 am 
Offline
Engineer
Engineer

Joined: Sun Nov 27, 2016 3:26 am
Posts: 5
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


Top
   
PostPosted: Sun Nov 27, 2016 10:20 pm 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Fri Jun 19, 2009 2:47 pm
Posts: 358
Location: Victoria, Australia
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/
__________________________
"Don't badger the Badger"....(Retired Moderator)


Top
   
PostPosted: Mon Nov 28, 2016 6:59 am 
Offline
Engineer
Engineer

Joined: Sun Nov 27, 2016 3:26 am
Posts: 5
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.


Top
   
PostPosted: Tue Nov 29, 2016 7:10 am 
Offline
Engineer
Engineer

Joined: Sun Nov 27, 2016 3:26 am
Posts: 5
Hashing the sum with MD5 or SHA1 didn't work, nor did hashing the contents.

Bummer.


Top
   
PostPosted: Tue Nov 29, 2016 8:32 am 
Offline
Engineer
Engineer

Joined: Sun Nov 27, 2016 3:26 am
Posts: 5
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.


Top
   
PostPosted: Tue Nov 29, 2016 8:40 am 
Offline
Engineer
Engineer

Joined: Sun Nov 27, 2016 3:26 am
Posts: 5
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.

:|


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2017 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2017.
Hosted by Zernebok Hosting.