Reset all smooth network body of rewinders during firstly live join
This commit is contained in:
@@ -52,6 +52,7 @@
|
||||
#include "main_loop.hpp"
|
||||
#include "modes/overworld.hpp"
|
||||
#include "modes/profile_world.hpp"
|
||||
#include "network/protocols/client_lobby.hpp"
|
||||
#include "network/network_config.hpp"
|
||||
#include "network/rewind_manager.hpp"
|
||||
#include "physics/btKart.hpp"
|
||||
@@ -1010,6 +1011,14 @@ void World::scheduleTutorial()
|
||||
*/
|
||||
void World::updateGraphics(float dt)
|
||||
{
|
||||
if (auto cl = LobbyProtocol::get<ClientLobby>())
|
||||
{
|
||||
// Reset all smooth network body of rewinders so the rubber band effect
|
||||
// of moveable does not exist during firstly live join.
|
||||
if (cl->hasLiveJoiningRecently())
|
||||
RewindManager::get()->resetSmoothNetworkBody();
|
||||
}
|
||||
|
||||
PROFILER_PUSH_CPU_MARKER("World::update (weather)", 0x80, 0x7F, 0x00);
|
||||
if (UserConfigParams::m_particles_effects > 1 && Weather::getInstance())
|
||||
{
|
||||
|
||||
@@ -112,7 +112,6 @@ void ClientLobby::setup()
|
||||
{
|
||||
m_auto_back_to_lobby_time = std::numeric_limits<uint64_t>::max();
|
||||
m_start_live_game_time = std::numeric_limits<uint64_t>::max();
|
||||
m_live_join_ticks = -1;
|
||||
m_received_server_result = false;
|
||||
TracksScreen::getInstance()->resetVote();
|
||||
LobbyProtocol::setup();
|
||||
@@ -1001,12 +1000,12 @@ void ClientLobby::liveJoinAcknowledged(Event* event)
|
||||
m_start_live_game_time = data.getUInt64();
|
||||
powerup_manager->setRandomSeed(m_start_live_game_time);
|
||||
m_start_live_game_time = data.getUInt64();
|
||||
m_live_join_ticks = data.getUInt32();
|
||||
m_last_live_join_util_ticks = data.getUInt32();
|
||||
for (unsigned i = 0; i < w->getNumKarts(); i++)
|
||||
{
|
||||
AbstractKart* k = w->getKart(i);
|
||||
if (k->getController()->isLocalPlayerController())
|
||||
k->setLiveJoinKart(m_live_join_ticks);
|
||||
k->setLiveJoinKart(m_last_live_join_util_ticks);
|
||||
}
|
||||
|
||||
NetworkItemManager* nim =
|
||||
@@ -1027,7 +1026,7 @@ void ClientLobby::finishLiveJoin()
|
||||
StkTime::getRealTime());
|
||||
|
||||
w->setLiveJoinWorld(false);
|
||||
w->endLiveJoinWorld(m_live_join_ticks);
|
||||
w->endLiveJoinWorld(m_last_live_join_util_ticks);
|
||||
for (unsigned i = 0; i < w->getNumKarts(); i++)
|
||||
{
|
||||
AbstractKart* k = w->getKart(i);
|
||||
|
||||
@@ -83,8 +83,6 @@ private:
|
||||
|
||||
uint64_t m_start_live_game_time;
|
||||
|
||||
int m_live_join_ticks;
|
||||
|
||||
/** The state of the finite state machine. */
|
||||
std::atomic<ClientState> m_state;
|
||||
|
||||
|
||||
@@ -146,6 +146,7 @@ void LobbyProtocol::configRemoteKart(
|
||||
*/
|
||||
void LobbyProtocol::setup()
|
||||
{
|
||||
m_last_live_join_util_ticks = 0;
|
||||
resetVotingTime();
|
||||
m_peers_votes.clear();
|
||||
m_game_setup->reset();
|
||||
@@ -216,3 +217,14 @@ void LobbyProtocol::addLiveJoiningKart(int kart_id, const RemoteKartInfo& rki,
|
||||
if (!k->getController()->isLocalPlayerController())
|
||||
k->setOnScreenText(rki.getPlayerName().c_str());
|
||||
} // addLiveJoiningKart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool LobbyProtocol::hasLiveJoiningRecently() const
|
||||
{
|
||||
World* w = World::getWorld();
|
||||
if (!w)
|
||||
return false;
|
||||
return m_last_live_join_util_ticks != 0 &&
|
||||
w->getTicksSinceStart() - m_last_live_join_util_ticks > 0 &&
|
||||
w->getTicksSinceStart() - m_last_live_join_util_ticks < 120;
|
||||
} // hasLiveJoiningRecently
|
||||
|
||||
@@ -115,6 +115,10 @@ protected:
|
||||
* uint32_t max if not available. */
|
||||
std::atomic<uint32_t> m_estimated_progress;
|
||||
|
||||
// Save the last live join ticks, for physical objects to update current
|
||||
// transformation in server, and reset smooth network body in client
|
||||
int m_last_live_join_util_ticks;
|
||||
|
||||
/** Stores data about the online game to play. */
|
||||
GameSetup* m_game_setup;
|
||||
|
||||
@@ -205,6 +209,8 @@ public:
|
||||
m_estimated_remaining_time.store(std::numeric_limits<uint32_t>::max());
|
||||
m_estimated_progress.store(std::numeric_limits<uint32_t>::max());
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
bool hasLiveJoiningRecently() const;
|
||||
}; // class LobbyProtocol
|
||||
|
||||
#endif // LOBBY_PROTOCOL_HPP
|
||||
|
||||
@@ -250,7 +250,6 @@ void ServerLobby::setup()
|
||||
m_item_seed = 0;
|
||||
m_winner_peer_id = 0;
|
||||
m_client_starting_time = 0;
|
||||
m_last_live_join_util_ticks = 0;
|
||||
auto players = STKHost::get()->getPlayersForNewGame();
|
||||
if (m_game_setup->isGrandPrix() && !m_game_setup->isGrandPrixStarted())
|
||||
{
|
||||
@@ -3324,14 +3323,3 @@ void ServerLobby::handleKartInfo(Event* event)
|
||||
peer->sendPacket(ns, true/*reliable*/);
|
||||
delete ns;
|
||||
} // handleKartInfo
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
bool ServerLobby::hasLiveJoiningRecently() const
|
||||
{
|
||||
World* w = World::getWorld();
|
||||
if (!w)
|
||||
return false;
|
||||
return m_last_live_join_util_ticks != 0 &&
|
||||
w->getTicksSinceStart() - m_last_live_join_util_ticks > 0 &&
|
||||
w->getTicksSinceStart() - m_last_live_join_util_ticks < 120;
|
||||
} // hasLiveJoiningRecently
|
||||
|
||||
@@ -173,10 +173,6 @@ private:
|
||||
|
||||
uint64_t m_client_starting_time;
|
||||
|
||||
// Save the last live join ticks, for physical objects to update current
|
||||
// transformation
|
||||
int m_last_live_join_util_ticks;
|
||||
|
||||
// connection management
|
||||
void clientDisconnected(Event* event);
|
||||
void connectionRequested(Event* event);
|
||||
@@ -313,7 +309,6 @@ public:
|
||||
float getStartupBoostOrPenaltyForKart(uint32_t ping, unsigned kart_id);
|
||||
int getDifficulty() const { return m_difficulty.load(); }
|
||||
int getGameMode() const { return m_game_mode.load(); }
|
||||
bool hasLiveJoiningRecently() const;
|
||||
}; // class ServerLobby
|
||||
|
||||
#endif // SERVER_LOBBY_HPP
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "network/protocols/game_protocol.hpp"
|
||||
#include "network/rewinder.hpp"
|
||||
#include "network/rewind_info.hpp"
|
||||
#include "network/smooth_network_body.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "race/history.hpp"
|
||||
#include "utils/log.hpp"
|
||||
@@ -390,3 +391,20 @@ void RewindManager::mergeRewindInfoEventFunction()
|
||||
m_rewind_queue.insertRewindInfo(rief);
|
||||
m_pending_rief.clear();
|
||||
} // mergeRewindInfoEventFunction
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Reset all smooth network body of rewinders so the rubber band effect of
|
||||
* moveable does not exist during firstly live join.
|
||||
*/
|
||||
void RewindManager::resetSmoothNetworkBody()
|
||||
{
|
||||
for (auto& p : m_all_rewinder)
|
||||
{
|
||||
if (auto r = p.second.lock())
|
||||
{
|
||||
auto snb = std::dynamic_pointer_cast<SmoothNetworkBody>(r);
|
||||
if (snb)
|
||||
snb->reset();
|
||||
}
|
||||
}
|
||||
} // resetSmoothNetworkBody
|
||||
|
||||
@@ -208,6 +208,8 @@ public:
|
||||
int a = ticks - m_state_frequency + 1;
|
||||
return ticks != 0 && a >= 0 && a % m_state_frequency == 0;
|
||||
}
|
||||
// ------------------------------------------------------------------------
|
||||
void resetSmoothNetworkBody();
|
||||
}; // RewindManager
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
#include "io/xml_node.hpp"
|
||||
#include "physics/physics.hpp"
|
||||
#include "physics/triangle_mesh.hpp"
|
||||
#include "network/protocols/server_lobby.hpp"
|
||||
#include "network/protocols/lobby_protocol.hpp"
|
||||
#include "network/compress_network_body.hpp"
|
||||
#include "network/rewind_manager.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
@@ -806,7 +806,7 @@ BareNetworkString* PhysicalObject::saveState(std::vector<std::string>* ru)
|
||||
{
|
||||
bool has_live_join = false;
|
||||
|
||||
if (auto sl = LobbyProtocol::get<ServerLobby>())
|
||||
if (auto sl = LobbyProtocol::get<LobbyProtocol>())
|
||||
has_live_join = sl->hasLiveJoiningRecently();
|
||||
|
||||
btTransform cur_transform = m_body->getWorldTransform();
|
||||
|
||||
Reference in New Issue
Block a user