Vehicle.dat Support?
Posted: 12 Jan 2005 21:43
I cannot be sure on the exact mapping of vehicles.dat, but I am nearly certain of how it is set up (someone using TTD to add some random letter to the end of each and every vehicle would help with determining exact mapping):
0x8C 0x11 0x03 0x00 - Magic Number (I believe. I do not see any variations on this in the variations of vehicles.dat)
Followed by a standard array of all vehicles in the game. I'm not exactly sure how many, but counting is rather easy. Starting with the Kirby Paul Tank, each vehicle in the game has an entry. If the entry is non-null (i.e. the character at the beginning of the entry is not 0x00), then the length of the name is 32 characters (regardless. Is this null-terminated? It's null-filled, but I don't know if the max text is 31-characters with a null, or 32 characters, with a 33'd character, a null, implied. A test by saving the max-length name in a TTD vehicles.dat would test this). If the entry is null, the length of the entry is 1, and the next character is the next entry.
From that information (and with a little more from people with a working TTD original to make vehicle.dat files for a little more information) it should be fairly easy to add a patch for vehicle.dat support.
Unicode support would of course require then testing the magic number and replacing it with one we find suitable (such as making that last character, 0x00 to 0x01?) to call for a vehicle.dat version update (to support unicode, variable-length names, keying to specific names to overlay (i.e. a sparse array format), and/or adding support for adding an unlimited number of vehicles (handy if we ever move beyond newgrf's limitations in the number of sprites(?))
0x8C 0x11 0x03 0x00 - Magic Number (I believe. I do not see any variations on this in the variations of vehicles.dat)
Followed by a standard array of all vehicles in the game. I'm not exactly sure how many, but counting is rather easy. Starting with the Kirby Paul Tank, each vehicle in the game has an entry. If the entry is non-null (i.e. the character at the beginning of the entry is not 0x00), then the length of the name is 32 characters (regardless. Is this null-terminated? It's null-filled, but I don't know if the max text is 31-characters with a null, or 32 characters, with a 33'd character, a null, implied. A test by saving the max-length name in a TTD vehicles.dat would test this). If the entry is null, the length of the entry is 1, and the next character is the next entry.
From that information (and with a little more from people with a working TTD original to make vehicle.dat files for a little more information) it should be fairly easy to add a patch for vehicle.dat support.
Unicode support would of course require then testing the magic number and replacing it with one we find suitable (such as making that last character, 0x00 to 0x01?) to call for a vehicle.dat version update (to support unicode, variable-length names, keying to specific names to overlay (i.e. a sparse array format), and/or adding support for adding an unlimited number of vehicles (handy if we ever move beyond newgrf's limitations in the number of sprites(?))