mirror of
https://github.com/jcreek/CosmicClash.git
synced 2026-09-14 10:32:05 +00:00
feat(multiplayer): Phase 4 tasks 4.1/4.2 - local prediction history ring
Adds LocalPredictionHistory, a client-owned seq-tagged ring recording predicted ship state per input sequence, plus wiring in NetworkedMatch to record predictions on send and compare them against authoritative snapshots on arrival. Ships stay frozen/interpolated until 4.3 lands actual correction logic; this round only builds the comparison machinery and its data. Includes fixes from two review rounds: resync_required now self-clears once acknowledgements catch back up (mirrors InputJitterBuffer's stalled flag), NetBodyState gained a copy() method to stop diagnostic accessors aliasing ring-owned state, and corrected comments that had described the local ship as being force-simulated pre-4.3 when it is still driven by interpolated transform writes.
This commit is contained in:
@@ -21,3 +21,27 @@ var turbo := false
|
||||
var thrust_z := 0.0 # -1..1; re-quantised to a 3-bit bin on the wire
|
||||
var stalled := false
|
||||
var avel_range := 4.0 # NetCodec.SHIP_AVEL_RANGE; set to BALL_AVEL_RANGE for the ball
|
||||
|
||||
# Self-referential preload, not get_script().new() — this file deliberately
|
||||
# has no class_name (same cache-timing reason as test_case.gd and other
|
||||
# path-`extends`d files in this project), and get_script().new() throws
|
||||
# "Nonexistent function 'new' in base 'GDScript'" from within the script's
|
||||
# own body in this Godot version.
|
||||
const _NetBodyState = preload("res://scripts/net_body_state.gd")
|
||||
|
||||
|
||||
# Same contract as ShipAction.copy() (see its own comment): a distinct
|
||||
# instance with equal fields, for callers that hold onto a state past the
|
||||
# tick/comparison it was returned in.
|
||||
func copy() -> RefCounted:
|
||||
var c := _NetBodyState.new()
|
||||
c.position = position
|
||||
c.rotation = rotation
|
||||
c.linear_velocity = linear_velocity
|
||||
c.angular_velocity = angular_velocity
|
||||
c.frozen = frozen
|
||||
c.turbo = turbo
|
||||
c.thrust_z = thrust_z
|
||||
c.stalled = stalled
|
||||
c.avel_range = avel_range
|
||||
return c
|
||||
|
||||
Reference in New Issue
Block a user