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:

  1. Create a new ‘raw format’ type that implements Serialize and Deserialize]. 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 the serde(deserialize_with = ...} attribute! Conventionally, these types are named V{N} where {N} is the number succeeding the previous raw format type.

  2. Add an implementation of From<{YourRawFormat}> for Chunk. As before, see previous versions if in doubt.

  3. Change the type of version::Current to your new raw format type.

  4. Add an entry for your raw format at the top of the array in [version::loaders].

  5. 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.