Crate twsnap

Crate twsnap 

Source
Expand description

§Snapshot reprentation

Goals:

  • Can be used to render

  • Can be produced by game implementation

  • Can be serialized into DDNet demo

  • Can be deserialized from DDNet demo

  • Can be used as input from game implementation

  • valid utf-8

  • no allocations

  • usability first

Goals, if it doesn’t affect the representation, otherwise another snapshot is necessary

  • Can be deserialized from Teehistorian

Non-goals:

  • repr(C) to serialize
  • Implement functions on snap objects like trajectory.
  • no_std
  • Serialization can be played by old DDNet clients or Teeworlds Client
  • resemblance of [i32; k] strings by Teeworlds
  • writing non-DDNet snapshots (other mods)

Architecture:

  • Using fixed to represent uniform scales for all distance related variables: 1 per tile
  • vek for points
  • arrayvec for stack strings/arrays
  • rust enum for protocol enums
  • bitflags
  • bools
  • One snapshot per team

Modules§

compat
enums
events
flags
items
All the items that are in a server snapshot
time
Timing for ddnet

Structs§

Iter
IterMut
OrderedMap
Collection type with the two primary goals:
SkinColor
Similar to HSLA, however, the l value is abnormal. The base float value of l will always be 0.5 on any color conversion. l_upper determines the final l value from 0.5 to 1.
Snap
SnapId
Key type for OrderedMap. Internally it is an u32, and the lower 16 bits are for the legacy id.
Values
ValuesMut

Enums§

Events

Functions§

vec2_from_bits
Converts the coordinates to i32 by simple cast and interpret as fixed type

Type Aliases§

AnglePrecision
Position
PositionPrecision
Velocity
VelocityPrecision