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)
104 void erasePeerInGame(std::weak_ptr<STKPeer> peer)
An abstract interface for the actual karts.
Definition: abstract_kart.hpp:62
Describes a chain of 8-bit unsigned integers.
Definition: network_string.hpp:53
Definition: item_manager.hpp:47
Contains the state information of an item, i.e.
Definition: item.hpp:53
The network item manager is responsible for handling all network related item manager tasks - synchro...
Definition: network_item_manager.hpp:45
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
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
int m_confirmed_state_time
Time at which m_confirmed_state was taken.
Definition: network_item_manager.hpp:56
virtual void switchItems() OVERRIDE
Called when a switch is activated.
Definition: network_item_manager.cpp:117
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
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
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
virtual ~NetworkItemManager()
Destructor.
Definition: network_item_manager.cpp:67
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
void initServer()
If this is a server, initializing the peers in game.
Definition: network_item_manager.cpp:50
virtual void saveTransform() OVERRIDE
Called before a rewind.
Definition: network_item_manager.hpp:90
NetworkItemManager()
Creates a new instance of the item manager.
Definition: network_item_manager.cpp:39
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
Synchronised< std::vector< ItemEventInfo > > m_item_events
List of all items events.
Definition: network_item_manager.hpp:66
virtual void reset() OVERRIDE
Nothing to do here.
Definition: network_item_manager.cpp:76
virtual void rewindToEvent(BareNetworkString *bns) OVERRIDE
Called when an event needs to be replayed.
Definition: network_item_manager.hpp:88
int m_confirmed_switch_ticks
The switch ticks value at the lime of the last confirmed state.
Definition: network_item_manager.hpp:53
void saveCompleteState(BareNetworkString *buffer) const
Save all current items at current ticks in server for live join.
Definition: network_item_manager.cpp:522
std::mutex m_live_players_mutex
Allow remove or add peer live.
Definition: network_item_manager.hpp:59
virtual void undoEvent(BareNetworkString *) OVERRIDE
Called when an event needs to be undone.
Definition: network_item_manager.hpp:96
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 forwardTime(int ticks)
Progresses the time for all item by the given number of ticks.
Definition: network_item_manager.cpp:252
virtual void collectedItem(ItemState *item, AbstractKart *kart) OVERRIDE
Called when a kart collects an item.
Definition: network_item_manager.cpp:88
Definition: rewinder.hpp:44
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:76
A variable that is automatically synchronised using pthreads mutex.
Definition: synchronised.hpp:28
A wrapper around bullets btVector3 to include conventient conversion functions (e....
Definition: vec3.hpp:35