Remove local state saving at t = 0
A proper same frequency local state saving for client will come later
This commit is contained in:
parent
b537df54fc
commit
908735b1b1
@ -62,6 +62,10 @@ NetworkItemManager::NetworkItemManager()
|
||||
*/
|
||||
NetworkItemManager::~NetworkItemManager()
|
||||
{
|
||||
for (ItemState* is : m_confirmed_state)
|
||||
{
|
||||
delete is;
|
||||
}
|
||||
} // ~NetworkItemManager
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -71,9 +75,9 @@ void NetworkItemManager::reset()
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Copies the initial state at the start of a race as confirmed state.
|
||||
/** Initialize state at the start of a race.
|
||||
*/
|
||||
void NetworkItemManager::saveInitialState()
|
||||
void NetworkItemManager::initClientConfirmState()
|
||||
{
|
||||
m_confirmed_state_time = 0;
|
||||
|
||||
@ -83,7 +87,7 @@ void NetworkItemManager::saveInitialState()
|
||||
ItemState *is = new ItemState(*i);
|
||||
m_confirmed_state.push_back(is);
|
||||
}
|
||||
} // saveInitialState
|
||||
} // initClientConfirmState
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Called when a kart collects an item. In network games only the server
|
||||
@ -195,12 +199,6 @@ void NetworkItemManager::setItemConfirmationTime(std::weak_ptr<STKPeer> peer,
|
||||
*/
|
||||
BareNetworkString* NetworkItemManager::saveState()
|
||||
{
|
||||
if(NetworkConfig::get()->isClient())
|
||||
{
|
||||
saveInitialState();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// On the server:
|
||||
// ==============
|
||||
m_item_events.lock();
|
||||
|
@ -68,7 +68,7 @@ public:
|
||||
|
||||
void setSwitchItems(const std::vector<int> &switch_items);
|
||||
void sendItemUpdate();
|
||||
void saveInitialState();
|
||||
void initClientConfirmState();
|
||||
|
||||
virtual void reset() OVERRIDE;
|
||||
virtual void setItemConfirmationTime(std::weak_ptr<STKPeer> peer,
|
||||
|
@ -324,15 +324,6 @@ void WorldStatus::updateTime(int ticks)
|
||||
{
|
||||
// set phase is over, go to the next one
|
||||
m_phase = GO_PHASE;
|
||||
// Save one initial state on a client, in case that an event
|
||||
// is received from a client (trieggering a rollback) before
|
||||
// a state from the server has been received.
|
||||
if (NetworkConfig::get()->isNetworking() &&
|
||||
NetworkConfig::get()->isClient() )
|
||||
{
|
||||
RewindManager::get()->saveLocalState();
|
||||
// FIXME TODO: save state in rewind queue!
|
||||
}
|
||||
if (m_play_ready_set_go_sounds)
|
||||
{
|
||||
m_start_sound->play();
|
||||
|
@ -182,30 +182,6 @@ void RewindManager::saveState(bool local_save)
|
||||
PROFILER_POP_CPU_MARKER();
|
||||
} // saveState
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Saves a state on the client. Used to save an initial state at t=0 for each
|
||||
* client in case that we receive an event from another client (which will
|
||||
* trigger a rewind) before a state from the server.
|
||||
*/
|
||||
void RewindManager::saveLocalState()
|
||||
{
|
||||
auto gp = GameProtocol::lock();
|
||||
if (!gp)
|
||||
return;
|
||||
|
||||
int ticks = World::getWorld()->getTimeTicks();
|
||||
|
||||
saveState(/*local_state*/true);
|
||||
NetworkString *state = gp->getState();
|
||||
|
||||
// Copy the data to a new string, making the buffer in
|
||||
// GameProtocol availble for again.
|
||||
BareNetworkString *bns =
|
||||
new BareNetworkString(state->getCurrentData(),
|
||||
state->size() );
|
||||
m_rewind_queue.addLocalState(bns, /*confirmed*/true, ticks);
|
||||
} // saveLocalState
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Restores a given state by calling rewindToState for each available rewinder
|
||||
* with its correct data.
|
||||
|
@ -147,7 +147,6 @@ public:
|
||||
BareNetworkString *buffer, int ticks);
|
||||
void addNetworkState(BareNetworkString *buffer, int ticks);
|
||||
void saveState(bool local_save);
|
||||
void saveLocalState();
|
||||
void restoreState(BareNetworkString *buffer);
|
||||
// ------------------------------------------------------------------------
|
||||
/** Adds a Rewinder to the list of all rewinders.
|
||||
|
@ -2050,9 +2050,15 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
|
||||
}
|
||||
} // for i<root->getNumNodes()
|
||||
}
|
||||
|
||||
delete root;
|
||||
|
||||
if (NetworkConfig::get()->isNetworking() &&
|
||||
NetworkConfig::get()->isClient())
|
||||
{
|
||||
static_cast<NetworkItemManager*>(NetworkItemManager::get())
|
||||
->initClientConfirmState();
|
||||
}
|
||||
|
||||
if (UserConfigParams::m_track_debug && Graph::get() && !m_is_cutscene)
|
||||
Graph::get()->createDebugMesh();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user