19 #ifndef HEADER_NETWORK_ITEM_MANAGER_HPP 20 #define HEADER_NETWORK_ITEM_MANAGER_HPP 22 #include "items/item_event_info.hpp" 23 #include "items/item_manager.hpp" 24 #include "network/rewinder.hpp" 25 #include "utils/cpp2011.hpp" 26 #include "utils/synchronised.hpp" 62 std::map<std::weak_ptr<STKPeer>, int32_t,
71 static bool m_network_item_debugging;
75 virtual void reset() OVERRIDE;
82 const
Vec3 *server_xyz = NULL,
83 const
Vec3 *server_normal = NULL) OVERRIDE;
98 void addLiveJoinPeer(std::weak_ptr<STKPeer> peer)
100 std::lock_guard<std::mutex> lock(m_live_players_mutex);
101 m_last_confirmed_item_ticks[peer] = 0;
104 void erasePeerInGame(std::weak_ptr<STKPeer> peer)
106 std::lock_guard<std::mutex> lock(m_live_players_mutex);
107 m_last_confirmed_item_ticks.erase(peer);
virtual Item * dropNewItem(ItemState::ItemType type, const AbstractKart *kart, const Vec3 *server_xyz=NULL, const Vec3 *server_normal=NULL) OVERRIDE
Called when a new item is created, e.g.
Definition: network_item_manager.cpp:140
void initServer()
If this is a server, initializing the peers in game.
Definition: network_item_manager.cpp:50
virtual ~NetworkItemManager()
Destructor.
Definition: network_item_manager.cpp:67
A wrapper around bullets btVector3 to include conventient conversion functions (e.g.
Definition: vec3.hpp:34
void restoreCompleteState(const BareNetworkString &buffer)
Restore all current items at current ticks in client for live join or at the start of a race...
Definition: network_item_manager.cpp:543
Definition: rewinder.hpp:43
A variable that is automatically synchronised using pthreads mutex.
Definition: synchronised.hpp:27
virtual void restoreState(BareNetworkString *buffer, int count) OVERRIDE
Restores the state of the items to the current world time.
Definition: network_item_manager.cpp:278
void saveCompleteState(BareNetworkString *buffer) const
Save all current items at current ticks in server for live join.
Definition: network_item_manager.cpp:522
virtual void reset() OVERRIDE
Nothing to do here.
Definition: network_item_manager.cpp:76
NetworkItemManager()
Creates a new instance of the item manager.
Definition: network_item_manager.cpp:39
virtual void setItemConfirmationTime(std::weak_ptr< STKPeer > peer, int ticks) OVERRIDE
Called by the GameProtocol when a confirmation for an item event is received by the server...
Definition: network_item_manager.cpp:171
int m_confirmed_state_time
Time at which m_confirmed_state was taken.
Definition: network_item_manager.hpp:56
virtual void collectedItem(ItemState *item, AbstractKart *kart) OVERRIDE
Called when a kart collects an item.
Definition: network_item_manager.cpp:88
virtual void undoEvent(BareNetworkString *) OVERRIDE
Called when an event needs to be undone.
Definition: network_item_manager.hpp:96
virtual void saveTransform() OVERRIDE
Called before a rewind.
Definition: network_item_manager.hpp:90
std::map< std::weak_ptr< STKPeer >, int32_t, std::owner_less< std::weak_ptr< STKPeer > > > m_last_confirmed_item_ticks
Stores on the server the latest confirmed tick from each client.
Definition: network_item_manager.hpp:63
Synchronised< std::vector< ItemEventInfo > > m_item_events
List of all items events.
Definition: network_item_manager.hpp:66
virtual void rewindToEvent(BareNetworkString *bns) OVERRIDE
Called when an event needs to be replayed.
Definition: network_item_manager.hpp:88
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:52
Definition: item_manager.hpp:46
std::mutex m_live_players_mutex
Allow remove or add peer live.
Definition: network_item_manager.hpp:59
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:75
virtual void undoState(BareNetworkString *buffer) OVERRIDE
Undo the effects of the given state, but do not rewind to that state (which is done by rewindTo)...
Definition: network_item_manager.hpp:94
virtual BareNetworkString * saveState(std::vector< std::string > *ru) OVERRIDE
Saves the state of all items.
Definition: network_item_manager.cpp:222
std::vector< ItemState * > m_confirmed_state
A client stores a 'confirmed' item event state, which is based on the server data.
Definition: network_item_manager.hpp:50
void forwardTime(int ticks)
Progresses the time for all item by the given number of ticks.
Definition: network_item_manager.cpp:252
Contains the state information of an item, i.e.
Definition: item.hpp:52
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:61
int m_confirmed_switch_ticks
The switch ticks value at the lime of the last confirmed state.
Definition: network_item_manager.hpp:53
virtual void computeError() OVERRIDE
Called when a rewind is finished, and is used to compute the error caused by the rewind (which is the...
Definition: network_item_manager.hpp:92
The network item manager is responsible for handling all network related item manager tasks - synchro...
Definition: network_item_manager.hpp:44
virtual void switchItems() OVERRIDE
Called when a switch is activated.
Definition: network_item_manager.cpp:117