Advanced chunk'ing
Posted: Wed Jan 25, 2017 10:41 am
I'm about to add this to the Exult Studio documentation along with initgame.dat hints and tips but who knows how long that will take.
So, for those that struggled with the chunks and messed them up etc...
The U7 world is made up of preformed chunks saved in the u7chunks file. The order of the chunk files used in the map, is saved in the u7map file. In Exult Studio when you change the order of the chunks, by adding or deleting a chunk, Exult Studio will automatically save the new order in the u7map file.
But what if you really messed up existing chunks by accident and you want to reset the chunks?
Unfortunately we do not have an option in Exult Studio for doing that. You will have to hex edit the u7chunks file.
NOTE: PLEASE MAKE BACKUPS OF YOUR u7chunks AND u7map BEFORE PROCEEDING WITH HEX EDITING
Our u7chunks file has two different formats.
The stock chunk format:
If you use #255).
In the second byte, the top hex digit is entirely for the frame; the bottom hex digit is half for frame (the top half) and half for shape (the bottom half).
You divide the second byte by 4 to get the frame number, or get the remainder of division by 4 for shape.
For example frame #11 of shape #1016 (0x03F8), which would make the first byte be 0xF8 and the second 0x2F (hex of 4 x 11 + 3).
(The original u7chunks format is similar, the second byte needs you to add 128 to the summ, though. So the above example would be first byte 0xF8, second byte 0xAF (hex of 4 x 11 + 3 + 128))
The extended chunk format:
If you use more than 1024 shapes u7chunks will have a ten bytes long header (0xff, 0xff, 0xff, 0xff, 'exlt', 0, 0 (FFFFFFFF65786C740000)) and each chunk will take up 768 bytes. Each shape using two bytes for the shape number and 1 byte for the frame number.
For example frame #11 (0x0B) of shape #1016 (0x03F8), which would make the first byte be 0xF8, the second 0x03 and the third 0x0B.
You can then save an unchanged map with Exult Studio and compare the resulting pristine u7chunks file with your edited one to find little problems.
To get a pristine map, make a backup of your u7chunks and u7map files and delete (or rename to something else (u7chunksnew u7mapnew) them from your mod or patch folder, start a game with with your mod or patch, enter map edit mode, in Exult Studio select U7CHUNKS, select the first chunk and move it once down and then up again. Then hit "Save map" (file -> save ... -> map).
NOTE: DO NOT DELETE A WHOLE CHUNK via hex editing from the u7chunk file - This would mess up your map very badly as the order of the chunks in u7map will then no longer match the actual order of the chunks.
So, for those that struggled with the chunks and messed them up etc...
The U7 world is made up of preformed chunks saved in the u7chunks file. The order of the chunk files used in the map, is saved in the u7map file. In Exult Studio when you change the order of the chunks, by adding or deleting a chunk, Exult Studio will automatically save the new order in the u7map file.
But what if you really messed up existing chunks by accident and you want to reset the chunks?
Unfortunately we do not have an option in Exult Studio for doing that. You will have to hex edit the u7chunks file.
NOTE: PLEASE MAKE BACKUPS OF YOUR u7chunks AND u7map BEFORE PROCEEDING WITH HEX EDITING
Our u7chunks file has two different formats.
The stock chunk format:
If you use #255).
In the second byte, the top hex digit is entirely for the frame; the bottom hex digit is half for frame (the top half) and half for shape (the bottom half).
You divide the second byte by 4 to get the frame number, or get the remainder of division by 4 for shape.
For example frame #11 of shape #1016 (0x03F8), which would make the first byte be 0xF8 and the second 0x2F (hex of 4 x 11 + 3).
(The original u7chunks format is similar, the second byte needs you to add 128 to the summ, though. So the above example would be first byte 0xF8, second byte 0xAF (hex of 4 x 11 + 3 + 128))
The extended chunk format:
If you use more than 1024 shapes u7chunks will have a ten bytes long header (0xff, 0xff, 0xff, 0xff, 'exlt', 0, 0 (FFFFFFFF65786C740000)) and each chunk will take up 768 bytes. Each shape using two bytes for the shape number and 1 byte for the frame number.
For example frame #11 (0x0B) of shape #1016 (0x03F8), which would make the first byte be 0xF8, the second 0x03 and the third 0x0B.
You can then save an unchanged map with Exult Studio and compare the resulting pristine u7chunks file with your edited one to find little problems.
To get a pristine map, make a backup of your u7chunks and u7map files and delete (or rename to something else (u7chunksnew u7mapnew) them from your mod or patch folder, start a game with with your mod or patch, enter map edit mode, in Exult Studio select U7CHUNKS, select the first chunk and move it once down and then up again. Then hit "Save map" (file -> save ... -> map).
NOTE: DO NOT DELETE A WHOLE CHUNK via hex editing from the u7chunk file - This would mess up your map very badly as the order of the chunks in u7map will then no longer match the actual order of the chunks.