Repository navigation
Conversation
…ma-driven codec Savegames, continue and campaign progress files, high scores, the network config, replay headers and network resyncs are now written as KFXS files: a checked header, then chunks with a CRC and optional zlib. Each file carries a schema of the structs and fields it holds, and loading matches fields by name, so adding, removing or widening a field no longer breaks old saves. Changes of meaning are handled by migrations, and the config a level changed is stored as an overlay on the config files rather than as a copy of it.
|
@Loobinex please see https://github.com/cerwym/keeperfx/blob/7110e498729781d757c0a8d0f18cd777e87cf207/docs/lua_saves_for_mappers.md for guidance regarding lua best practices that should occur. I've made a best effort to preserve old maps working. But this is effectively also the security fix for loading arbritrary byte code from saves as lua was stored there |
|
I would suggest expanding the magic header from 4 to 8 bytes, with a \0 and invalid utf8 in the upper portion. This guarantees the OS understands it as a binary file, and also guarantees we can distinguish this from the legacy formats. (bytes 4-8 in the old code are guaranteed printable; and in legacy dk saves had \0 in byte 3 i believe.) |
| -------------------------------------------------------------------------------- | ||
| Describes every struct and field of the records in the file. | ||
| The writer lists the structs reachable from the roots of the file. | ||
| Structs are sorted by name (strcmp). No two structs share a name. |
There was a problem hiding this comment.
perhaps sort topographically, i.e. no struct has another struct in it unless that struct is defined earlier. Makes parsers easier to write if struct length can be decided without backtracking.
OTOH, if you don't expect parsers to validate, maybe offer no promises about struct order at all, not even strcmp.
Adds in the new KFXS save format, including checks in CI that prove / warn if a save has deliberately been broken.
Realistically this should be hard because this is no longer a mem-dump, we now use fields and save them in a structured manner.
This should result in saves that never break.
Save CI checks may be squashed at a later date