SuperTuxKart
dummy_rewinder.hpp
1 //
2 // SuperTuxKart - a fun racing game with go-kart
3 // Copyright (C) 2018 SuperTuxKart-Team
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 3
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 
19 #ifndef HEADER_DUMMY_REWINDER_HPP
20 #define HEADER_DUMMY_REWINDER_HPP
21 
22 #include "network/event_rewinder.hpp"
24 #include "network/rewinder.hpp"
25 
28 class DummyRewinder : public Rewinder, public EventRewinder
29 {
30 public:
31  // -------------------------------------------------------------------------
32  BareNetworkString* saveState(std::vector<std::string>* ru) { return NULL; }
33  // -------------------------------------------------------------------------
34  virtual void undoEvent(BareNetworkString* s) {}
35  // -------------------------------------------------------------------------
36  virtual void rewindToEvent(BareNetworkString* s) {}
37  // -------------------------------------------------------------------------
38  virtual void restoreState(BareNetworkString* s, int count)
39  { s->skip(count); }
40  // -------------------------------------------------------------------------
41  virtual void undoState(BareNetworkString *s) {}
42  // -------------------------------------------------------------------------
43  virtual void undo(BareNetworkString *s) {}
44  // -------------------------------------------------------------------------
45  virtual void rewind(BareNetworkString *s) {}
46  // -------------------------------------------------------------------------
47  virtual void saveTransform() {}
48  // -------------------------------------------------------------------------
49  virtual void computeError() {}
50 };
51 
52 #endif
53 
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
void skip(int n)
Skips the specified number of bytes when reading.
Definition: network_string.hpp:195
A dummy Rewinder and EventRewinder class for unit testing and handle undo destruction of projectiles.
Definition: dummy_rewinder.hpp:29
virtual void rewindToEvent(BareNetworkString *s)
Called when an event needs to be replayed.
Definition: dummy_rewinder.hpp:36
BareNetworkString * saveState(std::vector< std::string > *ru)
Provides a copy of the state of the object in one memory buffer.
Definition: dummy_rewinder.hpp:32
virtual void computeError()
Called when a rewind is finished, and is used to compute the error caused by the rewind (which is the...
Definition: dummy_rewinder.hpp:49
virtual void saveTransform()
Called before a rewind.
Definition: dummy_rewinder.hpp:47
virtual void rewind(BareNetworkString *s)
Called when an event needs to be replayed.
Definition: dummy_rewinder.hpp:45
virtual void undo(BareNetworkString *s)
Called when an event needs to be undone.
Definition: dummy_rewinder.hpp:43
virtual void undoState(BareNetworkString *s)
Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo).
Definition: dummy_rewinder.hpp:41
virtual void restoreState(BareNetworkString *s, int count)
Called when a state needs to be replayed.
Definition: dummy_rewinder.hpp:38
virtual void undoEvent(BareNetworkString *s)
Called when an event needs to be undone.
Definition: dummy_rewinder.hpp:34
A simple class that defines an interface to event rewinding: an undo() function when going back in ti...
Definition: event_rewinder.hpp:29
Definition: rewinder.hpp:44
Defines functions to easily manipulate 8-bit network destinated strings.