Add a unique identity to each rewinder
This commit is contained in:
parent
99659e8021
commit
ab528e2840
@ -39,7 +39,7 @@ void NetworkItemManager::create()
|
|||||||
/** Creates a new instance of the item manager. This is done at startup
|
/** Creates a new instance of the item manager. This is done at startup
|
||||||
* of each race. */
|
* of each race. */
|
||||||
NetworkItemManager::NetworkItemManager()
|
NetworkItemManager::NetworkItemManager()
|
||||||
: Rewinder(/*can be deleted*/false),
|
: Rewinder("nim", /*can be deleted*/false),
|
||||||
ItemManager()
|
ItemManager()
|
||||||
{
|
{
|
||||||
m_last_confirmed_item_ticks.clear();
|
m_last_confirmed_item_ticks.clear();
|
||||||
|
@ -33,11 +33,13 @@
|
|||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
KartRewinder::KartRewinder(const std::string& ident,unsigned int world_kart_id,
|
KartRewinder::KartRewinder(const std::string& ident,
|
||||||
int position, const btTransform& init_transform,
|
unsigned int world_kart_id, int position,
|
||||||
|
const btTransform& init_transform,
|
||||||
PerPlayerDifficulty difficulty,
|
PerPlayerDifficulty difficulty,
|
||||||
std::shared_ptr<RenderInfo> ri)
|
std::shared_ptr<RenderInfo> ri)
|
||||||
: Rewinder(/*can_be_destroyed*/ false)
|
: Rewinder(ident + StringUtils::toString(world_kart_id),
|
||||||
|
/*can_be_destroyed*/ false)
|
||||||
, Kart(ident, world_kart_id, position, init_transform, difficulty,
|
, Kart(ident, world_kart_id, position, init_transform, difficulty,
|
||||||
ri)
|
ri)
|
||||||
{
|
{
|
||||||
|
@ -214,11 +214,8 @@ void RewindManager::update(int ticks_not_used)
|
|||||||
|
|
||||||
m_not_rewound_ticks.store(ticks, std::memory_order_relaxed);
|
m_not_rewound_ticks.store(ticks, std::memory_order_relaxed);
|
||||||
|
|
||||||
// Clients don't save state, so they just exit.
|
|
||||||
if (ticks - m_last_saved_state < m_state_frequency)
|
if (ticks - m_last_saved_state < m_state_frequency)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// Save state
|
// Save state
|
||||||
if (NetworkConfig::get()->isClient())
|
if (NetworkConfig::get()->isClient())
|
||||||
|
@ -417,7 +417,7 @@ void RewindQueue::unitTesting()
|
|||||||
virtual void rewind(BareNetworkString *s) {}
|
virtual void rewind(BareNetworkString *s) {}
|
||||||
virtual void saveTransform() {}
|
virtual void saveTransform() {}
|
||||||
virtual void computeError() {}
|
virtual void computeError() {}
|
||||||
DummyRewinder() : Rewinder(true) {}
|
DummyRewinder() : Rewinder("", true) {}
|
||||||
};
|
};
|
||||||
DummyRewinder *dummy_rewinder = new DummyRewinder();
|
DummyRewinder *dummy_rewinder = new DummyRewinder();
|
||||||
|
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
/** Constructor. It will add this object to the list of all rewindable
|
/** Constructor. It will add this object to the list of all rewindable
|
||||||
* objects in the rewind manager.
|
* objects in the rewind manager.
|
||||||
*/
|
*/
|
||||||
Rewinder::Rewinder(bool can_be_destroyed, bool auto_add)
|
Rewinder::Rewinder(const std::string& ui, bool can_be_destroyed, bool auto_add)
|
||||||
|
: m_unique_identity(ui)
|
||||||
{
|
{
|
||||||
m_can_be_destroyed = can_be_destroyed;
|
m_can_be_destroyed = can_be_destroyed;
|
||||||
if (auto_add)
|
if (auto_add)
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
#ifndef HEADER_REWINDER_HPP
|
#ifndef HEADER_REWINDER_HPP
|
||||||
#define HEADER_REWINDER_HPP
|
#define HEADER_REWINDER_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
class BareNetworkString;
|
class BareNetworkString;
|
||||||
@ -28,6 +29,8 @@ class Rewinder
|
|||||||
protected:
|
protected:
|
||||||
void add();
|
void add();
|
||||||
private:
|
private:
|
||||||
|
const std::string m_unique_identity;
|
||||||
|
|
||||||
/** True if this object can be destroyed, i.e. if this object is a 'stand
|
/** True if this object can be destroyed, i.e. if this object is a 'stand
|
||||||
* alone' (i.e. not used in inheritance). If the object is used in
|
* alone' (i.e. not used in inheritance). If the object is used in
|
||||||
* inheritance (e.g. KartRewinder, which is a Rewinder and Kart), then
|
* inheritance (e.g. KartRewinder, which is a Rewinder and Kart), then
|
||||||
@ -36,7 +39,8 @@ private:
|
|||||||
bool m_can_be_destroyed;
|
bool m_can_be_destroyed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Rewinder(bool can_be_destroyed, bool auto_add = true);
|
Rewinder(const std::string& ui, bool can_be_destroyed,
|
||||||
|
bool auto_add = true);
|
||||||
virtual ~Rewinder();
|
virtual ~Rewinder();
|
||||||
|
|
||||||
/** Called before a rewind. Is used to save the previous position of an
|
/** Called before a rewind. Is used to save the previous position of an
|
||||||
@ -87,6 +91,8 @@ public:
|
|||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
virtual std::function<void()> getLocalStateRestoreFunction()
|
virtual std::function<void()> getLocalStateRestoreFunction()
|
||||||
{ return nullptr; }
|
{ return nullptr; }
|
||||||
|
// -------------------------------------------------------------------------
|
||||||
|
const std::string& getUniqueIdentity() const { return m_unique_identity; }
|
||||||
}; // Rewinder
|
}; // Rewinder
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -135,7 +135,10 @@ PhysicalObject* PhysicalObject::fromXML(bool is_dynamic,
|
|||||||
PhysicalObject::PhysicalObject(bool is_dynamic,
|
PhysicalObject::PhysicalObject(bool is_dynamic,
|
||||||
const PhysicalObject::Settings& settings,
|
const PhysicalObject::Settings& settings,
|
||||||
TrackObject* object)
|
TrackObject* object)
|
||||||
: Rewinder(false/*can_be_destroyed*/, false/*auto_add*/)
|
: Rewinder(settings.m_id +
|
||||||
|
(object->getParentLibrary() ?
|
||||||
|
object->getParentLibrary()->getID() : "") ,
|
||||||
|
false/*can_be_destroyed*/, false/*auto_add*/)
|
||||||
{
|
{
|
||||||
m_shape = NULL;
|
m_shape = NULL;
|
||||||
m_body = NULL;
|
m_body = NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user