Savegame format
From WarzoneWiki
The new proposed savegame format is a tagged file format that uses big-endian for storage, is easily extended without breaking compatibility backwards or forwards with other versions, checks the tag format against a definition file for consistency, and uses default values to save disk space.
The file contains only tags. The first tag should always contain the string "WZTAGFILE1", and this string will then appear at the fifth byte of any savegame file. Each tag begins with a byte that describes the tag number. This number must be in the range 1 to 254, and must be larger than the previous tag number, except as noted below. Each tag in this range also has a byte describing the tag's value representation. If this value representation is an array type, an unsigned 16-bit value follows to describe its length. Then follows the value payload.
If the tag has a value representation of type group, it contains a nested tag list in which tag numbers start counting from 1 again. After a group tag's value representation byte follows an unsigned 16-bit giving the number of separate instances of the tag list contained in this group. A nested group continues until a tag number of 255 is encountered. Groups may be defined recursively, and allow the number of tags in a file to reach any number, despite the limitation of 253 unique tag numbers in any given tag list.
Tag number zero is special, and denotes a separator in a list of tag list instances. Once a tag number value zero is encountered, that tag list is completed, and a new tag list of the same type shall begin.
Tag number 255 is also special, and denotes the end of a group.
Value representations:
- Unsigned 8 bits = 0
- Unsigned 16 bits = 1
- Unsigned 32 bits = 2
- Signed 8 bits = 3
- Signed 16 bits = 4
- Signed 32 bits = 5
- Floating point 16 bits = 6
- Unsigned 16 bits array = 7
- Floating point 16 bits array = 8
- Unsigned 8 bits array = 9 (also used for strings)
- Group = 10
Extensibility
You can always increase the length of an array later on. The code may easily be made to support casts between formats, so that you can change value representations without breaking compatibility, but this is by and large not yet done. Tags with default values can be retired without causing compatibility issues, while you may want to consider writing retired tags for a while if you want to keep compatibility with older versions of the software.


