Class l2df.manager.sync

Last updated 2021-05-28 15:24:22

Synchronization manager.

Info:

Functions

Manager:init(kwargs) Configure SyncManager.
Manager:reset([zero=0]) Reset manager and drop all snapshots.
Manager:updateAdvantage(timestamp) Updates local simulation advantage value (difference in time between simulations).
Manager:sync(frame) Synchronize frame-counters between simulations.
Manager.persist([callback[, ...]]) Register callback functions for persisting state or call all of them.
Manager:stage(f, ...) Persist a function and its arguments to restore state during rollback.
Manager:commit(dt) Commit all staged functions and advance state.
Manager:rollback(frame) Rollback in history and execute persisted functions.

Fields

Manager.frame Internal frame counter.
Manager.time Time passed since start of the synchronization context.
Manager.size Size of the rollback window.
Manager.desync Value identifying that there was found a desync.


Functions

Methods
Manager:init(kwargs)
Configure SyncManager.

Parameters:

  • kwargs table Keyword arguments.
    • size number Maximum count of taken snapshots used for rollback. (default 10)
    • zero number Initial SyncManager.time. (default 0)

Returns:

    l2df.manager.sync
Manager:reset([zero=0])
Reset manager and drop all snapshots.

Parameters:

Manager:updateAdvantage(timestamp)
Updates local simulation advantage value (difference in time between simulations).

Parameters:

  • timestamp number Time of another simulation.
Manager:sync(frame)
Synchronize frame-counters between simulations.

Parameters:

  • frame number Target frame for rollback.

Returns:

  1. number delta-time
  2. number throttle
Manager.persist([callback[, ...]])
Register callback functions for persisting state or call all of them. All of that functions would be called with next SyncManager:persist(...) call. Usually you want to call it before start of each frame simulation.

Parameters:

  • callback function State persisting function. (optional)
  • ... Arguments passed to all stored callbacks. (optional)
Manager:stage(f, ...)
Persist a function and its arguments to restore state during rollback.

Parameters:

  • f function Restore-function which whould be used later to restore the initial state.
  • ... Arguments passed to restore-function during rollback.

Returns:

    l2df.manager.sync
Manager:commit(dt)
Commit all staged functions and advance state.

Parameters:

  • dt number Delta-time since last game tick.

Returns:

    l2df.manager.sync
Manager:rollback(frame)
Rollback in history and execute persisted functions.

Parameters:

  • frame number Target frame for rollback.

Returns:

    number Rollback size.

Fields

Manager.frame number
Internal frame counter. Advances on each SyncManager:commit() call.
Manager.time number
Time passed since start of the synchronization context.
Manager.size number
Size of the rollback window. It is the maximum count of taken snapshots.
Manager.desync boolean
Value identifying that there was found a desync.