FRollbackSession
FRollbackSession — GGPO-style rollback for any number of players over any transport. Each frame the local input is filed inputDelay frames ahead and sent; inputs not yet heard from a peer are predicted (its last known input repeated); the frame is simulated at once. When a peer's real input for an already-simulated frame differs from what was predicted, the state saved before that frame is restored and every frame since resimulated with what is now known. Peers that fall more than maxPrediction frames behind stall the local simulation instead of predicting further.
- Module
- Game
- Header
#include "Rollback/RollbackSession.h"- Namespace
Mowo
Desync detection: once every player's input for a frame is confirmed, the state saved at that frame is final; every checksumInterval frames each peer sends that state's checksum, and a mismatch is reported (OnDesync) — the moment two machines stopped agreeing, not the moment it became visible.
Properties
| Type | Name | Description |
|---|---|---|
static constexpr uint32_t | kMaxPlayers | Default 8. |
std::function<void(int32_t frame, uint64_t local, uint64_t remote, uint32_t player)> | OnDesync |
Constructors
| Signature | Name | Description |
|---|---|---|
FRollbackSession(const FRollbackConfig& config, IRollbackGame& game, IRollbackTr… | FRollbackSession |
Public functions
| Returns | Name | Description |
|---|---|---|
bool | AdvanceFrame | Simulates one frame with this local input; false when stalled waiting for a peer (the input is kept and offered again next call). |
void | Poll | Reads everything the transport has: inputs, acknowledgements, checksums. |
void | SendInputs | Re-sends the unacknowledged local input without advancing. |
int32_t | GetFrame | |
int32_t | GetConfirmedFrame | Newest frame for which every player's input is known. |
const FRollbackStats& | GetStats | |
const FRollbackConfig& | GetConfig | |
uint64_t | GetSavedChecksum | The checksum of the saved state at a frame still in the ring, 0 if gone. |
FRollbackInput | GetInput | The input a player had (or was predicted to have) at a frame. |
Function details
FRollbackSession
FRollbackSession(const FRollbackConfig& config, IRollbackGame& game, IRollbackTransport& transport)AdvanceFrame
bool AdvanceFrame(const FRollbackInput& localInput)Simulates one frame with this local input; false when stalled waiting for a peer (the input is kept and offered again next call).
Poll
void Poll()Reads everything the transport has: inputs, acknowledgements, checksums. AdvanceFrame polls first; call it alone to keep a stalled peer talking.
SendInputs
void SendInputs()Re-sends the unacknowledged local input without advancing.
GetFrame
int32_t GetFrame() constGetConfirmedFrame
int32_t GetConfirmedFrame() constNewest frame for which every player's input is known.
GetStats
const FRollbackStats& GetStats() constGetConfig
const FRollbackConfig& GetConfig() constGetSavedChecksum
uint64_t GetSavedChecksum(int32_t frame) constThe checksum of the saved state at a frame still in the ring, 0 if gone.
GetInput
FRollbackInput GetInput(uint32_t player, int32_t frame) constThe input a player had (or was predicted to have) at a frame.