19#ifndef HEADER_REWIND_INFO_HPP
20#define HEADER_REWIND_INFO_HPP
22#include "network/event_rewinder.hpp"
24#include "utils/cpp2011.hpp"
25#include "utils/leak_check.hpp"
26#include "utils/ptr_vector.hpp"
82 virtual bool isEvent()
const {
return false; }
85 virtual bool isState()
const {
return false; }
95 std::vector<std::string> m_rewinder_using;
105 std::vector<std::string>& rewinder_using,
106 std::vector<uint8_t>& buffer);
184 const std::function<void()> m_undo_function, m_replay_function,
188 std::function<
void()> undo_function = [](){},
189 std::function<void()> replay_function = [](){},
190 std::function<void()> destroy_function = [](){})
192 m_undo_function(undo_function), m_replay_function(replay_function),
193 m_destroy_function(destroy_function) {}
202 virtual void undo() { m_undo_function(); }
204 virtual void replay() { m_replay_function(); }
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
void reset()
Allows one to read a buffer from the beginning again.
Definition: network_string.hpp:147
A simple class that defines an interface to event rewinding: an undo() function when going back in ti...
Definition: event_rewinder.hpp:29
virtual void undo(BareNetworkString *buffer)=0
Called when an event needs to be undone.
virtual void rewind(BareNetworkString *buffer)=0
Called when an event needs to be replayed.
Definition: rewind_info.hpp:182
virtual void undo()
Called when going back in time to undo any rewind information.
Definition: rewind_info.hpp:202
virtual void replay()
This is called while going forwards in time again to reach current time.
Definition: rewind_info.hpp:204
virtual bool isEvent() const
If this RewindInfo is an event.
Definition: rewind_info.hpp:200
void restore()
An event is never 'restored', it is only rewound.
Definition: rewind_info.hpp:198
Definition: rewind_info.hpp:136
EventRewinder * m_event_rewinder
Pointer to the event rewinder responsible for this event.
Definition: rewind_info.hpp:139
virtual bool isEvent() const
If this RewindInfo is an event.
Definition: rewind_info.hpp:155
virtual void replay()
This is called while going forwards in time again to reach current time.
Definition: rewind_info.hpp:168
void restore()
An event is never 'restored', it is only rewound.
Definition: rewind_info.hpp:153
BareNetworkString * m_buffer
Buffer with the event data.
Definition: rewind_info.hpp:142
BareNetworkString * getBuffer()
Returns the buffer with the event information in it.
Definition: rewind_info.hpp:176
virtual void undo()
Called when going back in time to undo any rewind information.
Definition: rewind_info.hpp:159
A class that stores a game state and can rewind it.
Definition: rewind_info.hpp:93
virtual void replay()
Called when rewinding from a past state to 'now'.
Definition: rewind_info.hpp:128
BareNetworkString * getBuffer() const
Returns a pointer to the state buffer.
Definition: rewind_info.hpp:115
virtual void undo()
Called when going back in time to undo any rewind information.
Definition: rewind_info.hpp:121
virtual bool isState() const
If this RewindInfo is an event.
Definition: rewind_info.hpp:117
BareNetworkString * m_buffer
Pointer to the buffer which stores all states.
Definition: rewind_info.hpp:100
virtual void restore()
Rewinds to this state.
Definition: rewind_info.cpp:77
Used to store rewind information for a given time for all rewind instances.
Definition: rewind_info.hpp:45
virtual bool isEvent() const
If this RewindInfo is an event.
Definition: rewind_info.hpp:82
void setTicks(int ticks)
Adjusts the time of this RewindInfo.
Definition: rewind_info.cpp:42
virtual void replay()=0
This is called while going forwards in time again to reach current time.
int m_ticks
Time when this RewindInfo was taken.
Definition: rewind_info.hpp:50
virtual void undo()=0
Called when going back in time to undo any rewind information.
bool isConfirmed() const
Returns if this RewindInfo is confirmed.
Definition: rewind_info.hpp:79
virtual bool isState() const
If this RewindInfo is an event.
Definition: rewind_info.hpp:85
int getTicks() const
Returns the time at which this RewindInfo was saved.
Definition: rewind_info.hpp:73
void setConfirmed(bool b)
Sets if this RewindInfo is confirmed or not.
Definition: rewind_info.hpp:76
virtual void restore()=0
This is called to restore a state before replaying the events.
bool m_is_confirmed
A confirmed event is one that was sent from the server.
Definition: rewind_info.hpp:55
Defines functions to easily manipulate 8-bit network destinated strings.