Yup, that's what happens when you're a downright unsociable git like myselfCol.Kell wrote:wow you certainly have a lot of free time quota
Anyhow, I've finally worked out the checksum algorithm! In the end I got sick of trying to guess it and disassembled the code instead As a result, I was also able to determine the following:
- The geometry name field IS 16 bytes long.
- The geometry name field doesn't have to be mangled (if the first character is a valid ASCII code, the sim doesn't un-mangle the name).
- The 16-bit field at offset 28 of the header are flags (but I still need to figure out what exactly they do).
- As best I can tell, the 16-bit field at offset 30 of the header is unused.
- The checksum field is 32-bits, stored at offset 4 of the header.
And the checksum algorithm looks something like this:
Code: Select all
checksum = 0; for each vertex record do add vertex x, y, z, texture_x and texture_y values to checksum (these are all treated as signed integers) foo = (checksum >= 0) ? 0 : -1 checksum = ((((checksum xor foo) - foo) and 0x000fffff) xor foo) - foo end for each polygon record do add polygon texture, index count and index values to checksum (these are all treated as unsigned integers - I'm considering the "texture" value to be the first two bytes of the polygon record) foo = (checksum >= 0) ? 0 : -1 checksum = ((((checksum xor foo) - foo) and 0x000fffff) xor foo) - foo end
I've knocked together a little command-line Java tool to calculate WTB file checksums, and correct them when they are in error. It can be found here (including source code). It requires Java 6 to run. From the command line type: "java -jar WtbChecksum.jar" and it will print out usage instructions (it's pretty self-explanatory).
It should now be possible to start creating/editing WTB files that will be accepted by the sim