Skip to main content

Module replay

Module replay 

Source
Expand description

Replay system: input recording, deterministic playback, scrubbing, ghost.

§Architecture

  • InputRecorder — captures every input event with frame-accurate timestamps
  • ReplayFile — compact binary format: header + seed + input stream
  • ReplayPlayer — plays back a replay at configurable speed
  • ReplayScrubber — seeks to arbitrary points via state snapshots
  • GhostReplay — semi-transparent replay alongside live play
  • ReplayExporter — serialize replay to bytes / upload URL
  • ReplayVerifier — checksum validation against stored hash

§Determinism contract

The game must use only the provided RNG seed and recorded inputs. Any external randomness (system time, thread ID, etc.) breaks determinism.

§File format (little-endian binary)

Header (128 bytes):
  magic:      [u8; 4]   = b"PRFE"
  version:    u16
  flags:      u16
  seed:       u64
  frame_count: u32
  duration_ms: u32
  score:      i64
  checksum:   [u8; 32]  (SHA-256 of seed + input stream)
  metadata:   [u8; 64]  (null-padded JSON: class, floor, build)

Input stream:
  for each event:
    frame:    u32
    kind:     u8
    payload:  [u8; 8]

Re-exports§

pub use rollback::RollbackSession;
pub use rollback::PlayerInput;
pub use rollback::FrameInput;
pub use rollback::GameState;
pub use rollback::NetworkStats;

Modules§

rollback
Rollback networking support — deterministic state snapshots, input prediction, and reconciliation for peer-to-peer fighting/action games.

Structs§

GhostReplay
Plays a replay alongside live gameplay, representing a “ghost” opponent.
InputEvent
A single recorded input event.
InputRecorder
Records inputs during gameplay.
ReplayFile
A complete recorded replay.
ReplayMetadata
ReplayPlayer
Plays back a ReplayFile, emitting input events frame by frame.
ReplaySnapshot
ReplayVerifier
Validates a replay file’s integrity.

Enums§

InputKind
Compressed input event kind byte.
PlaybackState
VerifyResult