diff --git a/src/ballistica/scene_v1/support/client_session_replay.cc b/src/ballistica/scene_v1/support/client_session_replay.cc index b6b2cce6..0c70280e 100644 --- a/src/ballistica/scene_v1/support/client_session_replay.cc +++ b/src/ballistica/scene_v1/support/client_session_replay.cc @@ -134,8 +134,10 @@ void ClientSessionReplay::FetchMessages() { // If we have no messages left, read from the file until we get some. while (commands().empty()) { - { - // Before we read next message, let's save our current state. + // Before we read next message, let's save our current state + // if we didn't that for too long. + unsaved_messages_count_ += 1; + if (unsaved_messages_count_ > 50) { SessionStream out(nullptr, false); DumpFullState(&out); @@ -280,7 +282,10 @@ void ClientSessionReplay::OnReset(bool rewind) { } } -void ClientSessionReplay::SaveState() { states_.push_back(current_state_); } +void ClientSessionReplay::SaveState() { + unsaved_messages_count_ = 0; + states_.push_back(current_state_); +} void ClientSessionReplay::RestoreState(millisecs_t to_base_time) { ScreenMessage("was: " + std::to_string(base_time()) + "ms"); diff --git a/src/ballistica/scene_v1/support/client_session_replay.h b/src/ballistica/scene_v1/support/client_session_replay.h index 32adbeeb..5a7f07ae 100644 --- a/src/ballistica/scene_v1/support/client_session_replay.h +++ b/src/ballistica/scene_v1/support/client_session_replay.h @@ -49,6 +49,8 @@ class ClientSessionReplay : public ClientSession, std::vector states_; IntermediateState current_state_; + int unsaved_messages_count_{}; + uint32_t message_fetch_num_{}; bool have_sent_client_message_{}; std::vector connections_to_clients_;