Skip to content

Sein Lockstep

C++ type · FSeinLockstep

#include "SeinLockstep.h"

The turn exchange, without the transport. Every process keeps one.

A turn is the commands that run at one turn boundary. Turns 1 to the input delay D are empty everywhere. Commands a process issues while the world waits for turn N go into its batch for turn N + D. When the world takes turn N the process seals every batch through N + D, so a batch is never late by design and a stall means a missing peer, not a slow one.

The server assembles each turn from its own batch (its host player, the match administrator, AI slots) and one batch per authoring slot, in that order with slots ascending, and completes turns in order. A slot authors from the turn it joined or rejoined; a dropped slot authors nothing, so the match never waits on it.

C++ members (18)
  • void Reset(int32 InInputDelay, bool bInServer);
  • void ResumeAfter(int32 Turn, int32 FirstAuthoredTurn); After a state restore at the end of Turn: the world takes Turn + 1 next, and this process seals from FirstAuthoredTurn on, again where it sealed before the state (the server ignores a second batch for a turn).
  • int32 GetNextTurn() const;
  • int32 GetInputDelay() const;
  • int32 GetLastSealedTurn() const;
  • void AddLocal(const FSeinCommand& Command); A local command for the next batch this process seals.
  • bool Take(int32 Turn, TArray<FSeinCommand>& OutCommands); The world asks for turn Turn. False to stall; true with the turn’s commands.
  • void Seal(TFunctionRef<void(int32 Turn, TArray<FSeinCommand>&& Batch)> Send); After taking turn N, seal every batch through N + D. Pending local commands go into the last one; skipped turns get empty batches so no peer waits on them.
  • void AddTurn(int32 Turn, TArray<FSeinCommand>&& Commands); An assembled turn from the server. A turn already held or taken is ignored.
  • bool HasTurn(int32 Turn) const;
  • int32 GetNewestTurn() const; The newest assembled turn this process holds or took.
  • void SetAuthor(uint8 Slot, int32 FromTurn); A slot authors its batches from FromTurn on.
  • void RemoveAuthor(uint8 Slot); A dropped slot: the server no longer waits for it.
  • bool IsAuthor(uint8 Slot) const;
  • bool AddBatch(uint8 Author, int32 Turn, TArray<FSeinCommand>&& Batch); A batch for a turn not yet complete. False, with nothing kept, for a turn already complete, too far ahead, before the slot authors, or a second batch.
  • void CompleteTurns(TFunctionRef<void(int32 Turn, const TArray<FSeinCommand>& Commands)> Completed); Complete every turn whose batches are all in, in order. Each completed turn is passed on and also kept for Take.
  • int32 GetLastCompletedTurn() const;
  • TArray<uint8> GetMissingAuthors() const; Authors the next turn still waits for.