Table of Contents

Class PredictedAbilityStateHistory

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Per-tick record of what the owning client predicted for its ability controller, so a reconcile can be compared against the client's state at the reconcile tick rather than against whatever the client holds now.

public sealed class PredictedAbilityStateHistory
Inheritance
PredictedAbilityStateHistory
Inherited Members

Remarks

FishNet only applies a reconcile once its tick is at least stateInterpolation + 1 ticks behind the client's local tick, and the client has already simulated every tick in between. The server's seed and ability ID in that reconcile therefore describe an older tick than the client's live currentSeed / currentAbilityID. Comparing the two directly declared a "mismatch" on every cast — the client had advanced its seed for a cast the server had not yet processed — which destroyed every owner-predicted projectile about one tick after it spawned and cleared the cast bar on every reconcile for the first RTT of every timed cast.

Recording the predicted state per tick and looking up the entry for the reconcile's own tick makes the comparison like-for-like: a real misprediction is one where the client's simulation of tick T produced a different seed than the server's simulation of tick T.

Fixed-size ring indexed by tick & (capacity - 1); each slot stores the tick it holds so a stale slot is never mistaken for the requested tick. Capacity must be a power of two and comfortably larger than the client's look-ahead (a few ticks) plus a full reconcile window; 128 ticks is over four seconds at 30 Hz.

Constructors

PredictedAbilityStateHistory(int)

Creates a history ring.

public PredictedAbilityStateHistory(int capacity = 128)

Parameters

capacity int

Number of ticks retained. Rounded up to a power of two, minimum 2.

Fields

DefaultCapacity

Default ring capacity, in ticks. Must be a power of two.

public const int DefaultCapacity = 128

Field Value

int

Properties

Capacity

Ring capacity in ticks.

public int Capacity { get; }

Property Value

int

Methods

Clear()

Forgets every recorded tick.

public void Clear()

Record(uint, int, long)

Records the state the client holds after simulating tick. Overwrites any earlier record for the same tick (replays re-simulate a tick and the later simulation is the one a subsequent reconcile should be compared with).

public void Record(uint tick, int seed, long abilityID)

Parameters

tick uint
seed int
abilityID long

TryGet(uint, out int, out long)

Returns the recorded state for tick, if it is still in the ring.

public bool TryGet(uint tick, out int seed, out long abilityID)

Parameters

tick uint
seed int
abilityID long

Returns

bool