Skip to content

v0.12.0

Latest

Choose a tag to compare

@gschup gschup released this 09 Apr 18:37

Bug fixes

fix: spectator_handles() now returns only spectator handles; previously it incorrectly returned local + spectator handles due to a copy-paste bug (fixes #105)
fix: network_stats() for spectator handles no longer panics — it was looking up the address in player_reg.remotes instead of player_reg.spectators
fix: confirmed inputs are now flushed to spectators immediately within advance_frame(), reducing spectator latency by one frame; previously the packets were queued and only sent on the next poll_remote_clients() call
fix: spectator session no longer stalls at frame 0 when started before the host; sync request retries now use a dedicated timer instead of the shared last-send timer, which was being reset by ACKs and keepalives
fix: delta compression no longer panics when inputs serialize to variable sizes (e.g. enums with variants of different sizes); each encoded input is now length-prefixed

Breaking changes

breaking: the network wire format for input packets has changed; clients on different versions of ggrs will not be able to communicate
breaking: GgrsError::NotEnoughData is a new error variant returned by network_stats() when less than one second has elapsed since the connection was established; previously GgrsError::NotSynchronized was returned in both this case and the "not yet connected" case
breaking: SessionBuilder::start_synctest_session() now returns GgrsError::InvalidRequest if sparse saving is enabled, rather than silently ignoring the setting — SyncTestSession must save every frame to compare checksums across the check window
breaking: SessionBuilder::with_num_players() now returns Result<Self, GgrsError> and immediately rejects a value of 0; previously the error was deferred to session start
breaking: Config trait now requires a type InputPredictor: InputPredictorSelf::Input associated type; migrate existing impls by adding type InputPredictor = ggrs::PredictRepeatLast;, which preserves the previous behaviour of repeating the last known input

Improvements

feat: custom input prediction via the new InputPredictor trait; set type InputPredictor on your Config to control how missing remote inputs are predicted. GGRS ships with PredictRepeatLast (repeat last input, good for held-button state) and PredictDefault (always use Input::default(), good for one-shot events); implement the trait yourself for custom strategies (closes #69)
feat: Display implementations added for SessionState, InputStatus, PlayerType, and DesyncDetection
refactor: poll_remote_clients() collects endpoint events before processing, removing unnecessary pre-emptive clones of handles and addresses
docs: SessionBuilder methods now document valid value ranges and constraint relationships
docs: NetworkStats now explains the one-second warmup window and the idiomatic NotEnoughData handling pattern
docs: SyncTestSession struct now fully documents the save/advance/rollback/compare lifecycle, the panic-on-mismatch behaviour, and the all-players-local requirement
docs: NonBlockingSocket now includes a WASM/WebRTC implementation example using matchbox
docs: P2PSession::advance_frame() and poll_remote_clients() now document the spectator packet delivery timing
docs: SpectatorSession::advance_frame() now documents its dependency on the host having called poll_remote_clients for inputs to have arrived
docs: SpectatorSession::frames_behind_host() now documents that both current_frame and last_recv_frame start at NULL_FRAME
examples: handle_requests no longer takes an in_lockstep flag or uses unreachable!() — all request variants are handled unconditionally, relying on the library's guarantee that Save/Load are never sent in lockstep mode

Crate hygiene

chore: rust-version = "1.87" added to Cargo.toml, establishing the declared MSRV
chore: added comment to the getrandom optional dependency clarifying it exists to forward the js feature to rand on WASM targets

Code quality

clippy: resolved warnings across the codebase; added #[must_use] to SessionBuilder and its builder methods
refactor: internal constants consolidated and de-duplicated; GgrsError now derives Eq; minor readability improvements throughout
tests: expanded unit and integration test coverage across all session types and internal modules

Full Changelog: v0.11.1...v0.12.0