19#ifndef HEADER_REWIND_QUEUE_HPP
20#define HEADER_REWIND_QUEUE_HPP
22#include "utils/synchronised.hpp"
40 typedef std::list<RewindInfo*> AllRewindInfo;
42 AllRewindInfo m_all_rewind_info;
68 bool confirmed,
int ticks);
75 m_network_events.
lock();
76 m_network_events.
getData().push_back(ri);
98 assert(
m_current != m_all_rewind_info.end());
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
A simple class that defines an interface to event rewinding: an undo() function when going back in ti...
Definition: event_rewinder.hpp:29
Used to store rewind information for a given time for all rewind instances.
Definition: rewind_info.hpp:45
Definition: rewind_queue.hpp:37
void insertRewindInfo(RewindInfo *ri)
Inserts a RewindInfo object in the list of all events at the correct time.
Definition: rewind_queue.cpp:95
void addLocalState(BareNetworkString *buffer, bool confirmed, int ticks)
Adds a state from the local simulation to the last created TimeStepInfo container with the current wo...
Definition: rewind_queue.cpp:142
static void unitTesting()
Unit tests for RewindQueue.
Definition: rewind_queue.cpp:417
void addLocalEvent(EventRewinder *event_rewinder, BareNetworkString *buffer, bool confirmed, int ticks)
Adds an event to the rewind data.
Definition: rewind_queue.cpp:122
void reset()
Frees all saved state information and all destroyable rewinder.
Definition: rewind_queue.cpp:64
std::vector< RewindInfo * > AllNetworkRewindInfo
The list of all events received from the network.
Definition: rewind_queue.hpp:49
void mergeNetworkData(int world_ticks, bool *needs_rewind, int *rewind_ticks)
Merges thread-safe all data received from the network up to and including the current time (tick) wit...
Definition: rewind_queue.cpp:201
RewindQueue()
The RewindQueue stores one TimeStepInfo for each time step done.
Definition: rewind_queue.cpp:46
int getLatestConfirmedState() const
Returns the time of the latest confirmed state.
Definition: rewind_queue.hpp:89
void cleanupOldRewindInfo(int ticks)
Deletes all states and event before the given time.
Definition: rewind_queue.cpp:328
RewindInfo * getCurrent()
Returns the current RewindInfo.
Definition: rewind_queue.hpp:106
int undoUntil(int undo_ticks)
Rewinds the rewind queue and undos all events/states stored.
Definition: rewind_queue.cpp:366
AllRewindInfo::iterator m_current
Iterator to the curren time step info to be handled.
Definition: rewind_queue.hpp:53
void addNetworkState(BareNetworkString *buffer, int ticks)
Adds a state to the list of network rewind data.
Definition: rewind_queue.cpp:181
bool hasMoreRewindInfo() const
Returns true if there is at least one more RewindInfo available.
Definition: rewind_queue.cpp:354
void addNetworkEvent(EventRewinder *event_rewinder, BareNetworkString *buffer, int ticks)
Adds an event to the list of network rewind data.
Definition: rewind_queue.cpp:162
void next()
Sets the current element to be the next one and returns the next RewindInfo element.
Definition: rewind_queue.hpp:96
int m_latest_confirmed_state_time
Time at which the latest confirmed state is at.
Definition: rewind_queue.hpp:56
void replayAllEvents(int ticks)
Replays all events (not states) that happened at the specified time.
Definition: rewind_queue.cpp:397
~RewindQueue()
Frees all saved state information.
Definition: rewind_queue.cpp:55
A variable that is automatically synchronised using pthreads mutex.
Definition: synchronised.hpp:28
TYPE & getData()
Returns a reference to the original data file.
Definition: synchronised.hpp:82
void lock() const
Locks the mutex.
Definition: synchronised.hpp:95
void unlock() const
Unlocks the mutex.
Definition: synchronised.hpp:99