Module veloren_server::terrain_persistence::version
source · Expand description
§Adding a new chunk format version
Chunk formats are designed to be backwards-compatible when loading, but are not required to be backwards-compatible when saving (i.e: we must always be able to load old formats, but we’re not required to save old formats because newer formats might contain richer information that is incompatible with an older format).
The steps for doing this are as follows:
-
Create a new ‘raw format’ type that implements
Serialize
andDeserialize
]. Make sure to add a version field. If in doubt, copy the last raw format and increment the version number wherever it appears. Don’t forget to increment the version number in theserde(deserialize_with = ...}
attribute! Conventionally, these types are namedV{N}
where{N}
is the number succeeding the previous raw format type. -
Add an implementation of
From<{YourRawFormat}>
forChunk
. As before, see previous versions if in doubt. -
Change the type of
version::Current
to your new raw format type. -
Add an entry for your raw format at the top of the array in [
version::loaders
]. -
Remove the
Serialize
implementation from the previous raw format type: we don’t need it any longer!
Structs§
- Version 1 of the raw chunk format.
- Version 2 of the raw chunk format.
- Version 3 of the raw chunk format.
Functions§
Type Aliases§
- The newest supported raw format type. This should be changed every time a new raw format is added.