Skip to content

Schemas #454

@elementbound

Description

@elementbound

✨ Description

Most of the netfox traffic is generated by RollbackSynchronizer in most games, particularly the property snapshots. Each snapshot contains full property paths, and property values are serialized by Godot's built-in solution.

The former is solved by #159, while this ticket aims to solve the rest.

Users would be able to register schemas, which describe how each property should be serialized, for example:

rollback_synchronizer.set_state_schema({
  ":health": Schemas.uint8(),
  ":position": Schemas.vec3f(),
  # etc...
})

This would enable serializing integers with the right size for what they store ( instead of having Godot transmit everything as a 8-byte value ), using custom methods for marshalling custom types, or quantization of data, among others.

Use case

This would enable most games to fine-tune their bandwidth usage.

Distribution

netfox core

Implementation

  • Serializers would be pairs of methods, one for serializing the value, and one for deserializing
  • A utility class should be provided, with factory methods for most common types, including but not limited to:
    • Integers: uint8, uint16, uint32, uint64, int8, int16, int32, int64
    • Floats: float, double
    • Strings
    • Collections: arrayOf(), dictionaryOf(), receiving the item type's serializer as param
    • Crucially, a fallback serializer that just uses Godot's var_to_bytes()

Notes

  • RollbackSynchronizer could recognize property types on startup or during configuration. This could be the subject of a follow-up ticket.
  • Include an example for custom serializers in the docs
  • Consider if quantization would make sense here
    • ❓ Can it be done in a way that diff-states also recognizes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions