SuperTuxKart
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Rewinder Class Referenceabstract
Inheritance diagram for Rewinder:
Inheritance graph
[legend]

Public Member Functions

 Rewinder (const std::string &ui="")
 
virtual void saveTransform ()=0
 Called before a rewind. More...
 
virtual void computeError ()=0
 Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time). More...
 
virtual BareNetworkStringsaveState (std::vector< std::string > *ru)=0
 Provides a copy of the state of the object in one memory buffer. More...
 
virtual void undoEvent (BareNetworkString *buffer)=0
 Called when an event needs to be undone. More...
 
virtual void rewindToEvent (BareNetworkString *buffer)=0
 Called when an event needs to be replayed. More...
 
virtual void restoreState (BareNetworkString *buffer, int count)=0
 Called when a state needs to be replayed. More...
 
virtual void undoState (BareNetworkString *buffer)=0
 Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo). More...
 
virtual void reset ()
 Nothing to do here. More...
 
virtual std::function< void()> getLocalStateRestoreFunction ()
 
const std::string & getUniqueIdentity () const
 
bool rewinderAdd ()
 Add this object to the list of all rewindable objects in the rewind manager.
 
template<typename T >
std::shared_ptr< T > getShared ()
 

Protected Member Functions

void setUniqueIdentity (const std::string &uid)
 

Private Attributes

std::string m_unique_identity
 Currently it has 2 usages: More...
 

Member Function Documentation

◆ computeError()

virtual void Rewinder::computeError ( )
pure virtual

Called when a rewind is finished, and is used to compute the error caused by the rewind (which is then visually smoothed over time).

Implemented in PhysicalObject, Flyable, NetworkItemManager, CTFFlag, DummyRewinder, and KartRewinder.

◆ reset()

virtual void Rewinder::reset ( )
inlinevirtual

Nothing to do here.

Reimplemented in Flyable, PhysicalObject, NetworkItemManager, and KartRewinder.

◆ restoreState()

virtual void Rewinder::restoreState ( BareNetworkString buffer,
int  count 
)
pure virtual

Called when a state needs to be replayed.

This is called during rewind, i.e. when going forward in time again, and only for confirmed states.

Implemented in PhysicalObject, Flyable, RubberBall, CTFFlag, NetworkItemManager, Plunger, KartRewinder, and DummyRewinder.

◆ rewindToEvent()

virtual void Rewinder::rewindToEvent ( BareNetworkString buffer)
pure virtual

Called when an event needs to be replayed.

This is called during rewind, i.e. when going forward in time again.

Implemented in PhysicalObject, Flyable, CTFFlag, NetworkItemManager, KartRewinder, and DummyRewinder.

◆ saveState()

virtual BareNetworkString* Rewinder::saveState ( std::vector< std::string > *  ru)
pure virtual

Provides a copy of the state of the object in one memory buffer.

The memory is managed by the RewindManager.

Parameters
[out]ruThe unique identity of rewinder writing to.
Returns
The address of the memory buffer with the state.

Implemented in PhysicalObject, Flyable, RubberBall, CTFFlag, NetworkItemManager, Plunger, KartRewinder, and DummyRewinder.

◆ saveTransform()

virtual void Rewinder::saveTransform ( )
pure virtual

Called before a rewind.

Is used to save the previous position of an object before a rewind, so that the error due to a rewind can be computed.

Implemented in PhysicalObject, Flyable, NetworkItemManager, CTFFlag, DummyRewinder, and KartRewinder.

◆ undoEvent()

virtual void Rewinder::undoEvent ( BareNetworkString buffer)
pure virtual

Called when an event needs to be undone.

This is called while going backwards for rewinding - all stored events will get an 'undo' call.

Implemented in PhysicalObject, Flyable, NetworkItemManager, CTFFlag, KartRewinder, and DummyRewinder.

◆ undoState()

virtual void Rewinder::undoState ( BareNetworkString buffer)
pure virtual

Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo).

This is called while going backwards for rewinding - all stored events will get an 'undo' call.

Implemented in PhysicalObject, Flyable, CTFFlag, NetworkItemManager, KartRewinder, and DummyRewinder.

Member Data Documentation

◆ m_unique_identity

std::string Rewinder::m_unique_identity
private

Currently it has 2 usages:

  1. Create the required flyable if the firing event missed using this uid. (see RewindInfoState::restore)
  2. Determine the order of restoring state for each rewinder, this is used as a key in std::string, Rewinder map, which is less than. So uid of "0x01" (item manager) is restored before "0x02, x" (which kart id x) and 0x03 / 0x04 (the red / blue flag) is restored after karts, because the restoreState in CTFFlag read kart transformation.

The documentation for this class was generated from the following files: