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
|
||||
* of each race. */
|
||||
NetworkItemManager::NetworkItemManager()
|
||||
: Rewinder(/*can be deleted*/false),
|
||||
: Rewinder("nim", /*can be deleted*/false),
|
||||
ItemManager()
|
||||
{
|
||||
m_last_confirmed_item_ticks.clear();
|
||||
|
@ -33,11 +33,13 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
KartRewinder::KartRewinder(const std::string& ident,unsigned int world_kart_id,
|
||||
int position, const btTransform& init_transform,
|
||||
KartRewinder::KartRewinder(const std::string& ident,
|
||||
unsigned int world_kart_id, int position,
|
||||
const btTransform& init_transform,
|
||||
PerPlayerDifficulty difficulty,
|
||||
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,
|
||||
ri)
|
||||
{
|
||||
|
@ -214,11 +214,8 @@ void RewindManager::update(int ticks_not_used)
|
||||
|
||||
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)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Save state
|
||||
if (NetworkConfig::get()->isClient())
|
||||
|
@ -417,7 +417,7 @@ void RewindQueue::unitTesting()
|
||||
virtual void rewind(BareNetworkString *s) {}
|
||||
virtual void saveTransform() {}
|
||||
virtual void computeError() {}
|
||||
DummyRewinder() : Rewinder(true) {}
|
||||
DummyRewinder() : Rewinder("", true) {}
|
||||
};
|
||||
DummyRewinder *dummy_rewinder = new DummyRewinder();
|
||||
|
||||
|
@ -23,7 +23,8 @@
|
||||
/** Constructor. It will add this object to the list of all rewindable
|
||||
* 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;
|
||||
if (auto_add)
|
||||
|
@ -19,6 +19,7 @@
|
||||
#ifndef HEADER_REWINDER_HPP
|
||||
#define HEADER_REWINDER_HPP
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
class BareNetworkString;
|
||||
@ -28,6 +29,8 @@ class Rewinder
|
||||
protected:
|
||||
void add();
|
||||
private:
|
||||
const std::string m_unique_identity;
|
||||
|
||||
/** 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
|
||||
* inheritance (e.g. KartRewinder, which is a Rewinder and Kart), then
|
||||
@ -36,7 +39,8 @@ private:
|
||||
bool m_can_be_destroyed;
|
||||
|
||||
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();
|
||||
|
||||
/** Called before a rewind. Is used to save the previous position of an
|
||||
@ -86,7 +90,9 @@ public:
|
||||
bool canBeDestroyed() const { return m_can_be_destroyed; }
|
||||
// -------------------------------------------------------------------------
|
||||
virtual std::function<void()> getLocalStateRestoreFunction()
|
||||
{ return nullptr; }
|
||||
{ return nullptr; }
|
||||
// -------------------------------------------------------------------------
|
||||
const std::string& getUniqueIdentity() const { return m_unique_identity; }
|
||||
}; // Rewinder
|
||||
#endif
|
||||
|
||||
|
@ -135,7 +135,10 @@ PhysicalObject* PhysicalObject::fromXML(bool is_dynamic,
|
||||
PhysicalObject::PhysicalObject(bool is_dynamic,
|
||||
const PhysicalObject::Settings& settings,
|
||||
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_body = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user