diff options
author | sapier <Sapier at GMX dot net> | 2014-05-02 00:18:25 +0200 |
---|---|---|
committer | sapier <Sapier at GMX dot net> | 2014-05-02 00:18:25 +0200 |
commit | 9370f5657a498c7fde00eddf4c8e78e8c3a42c7a (patch) | |
tree | 562996911e349e33ba813caa65dbd20eeeddbd02 /src | |
parent | 4b44d359f5d580369bdc5c69d7ad2cd978aef344 (diff) | |
download | minetest-9370f5657a498c7fde00eddf4c8e78e8c3a42c7a.tar.gz minetest-9370f5657a498c7fde00eddf4c8e78e8c3a42c7a.tar.bz2 minetest-9370f5657a498c7fde00eddf4c8e78e8c3a42c7a.zip |
Add hack to avoid 2s startup delay on local games
Diffstat (limited to 'src')
-rw-r--r-- | src/client.cpp | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/src/client.cpp b/src/client.cpp index a4fabfa61..50162b1e9 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -221,6 +221,11 @@ Client::Client( MtEventManager *event, bool ipv6 ): + m_packetcounter_timer(0.0), + m_connection_reinit_timer(0.1), + m_avg_rtt_timer(0.0), + m_playerpos_send_timer(0.0), + m_ignore_damage_timer(0.0), m_tsrc(tsrc), m_shsrc(shsrc), m_itemdef(itemdef), @@ -258,13 +263,6 @@ Client::Client( m_removed_sounds_check_timer(0), m_state(LC_Created) { - m_packetcounter_timer = 0.0; - //m_delete_unused_sectors_timer = 0.0; - m_connection_reinit_timer = 0.0; - m_avg_rtt_timer = 0.0; - m_playerpos_send_timer = 0.0; - m_ignore_damage_timer = 0.0; - /* Add local player */ @@ -332,11 +330,11 @@ void Client::connect(Address address) void Client::step(float dtime) { DSTACK(__FUNCTION_NAME); - + // Limit a bit if(dtime > 2.0) dtime = 2.0; - + if(m_ignore_damage_timer > dtime) m_ignore_damage_timer -= dtime; else @@ -360,7 +358,8 @@ void Client::step(float dtime) { counter = 20.0; - infostream<<"Client packetcounter (20s):"<<std::endl; + infostream << "Client packetcounter (" << m_packetcounter_timer + << "):"<<std::endl; m_packetcounter.print(infostream); m_packetcounter.clear(); } @@ -456,8 +455,13 @@ void Client::step(float dtime) } } #endif - - if(m_state == LC_Created) + // UGLY hack to fix 2 second startup delay caused by non existent + // server client startup synchronization in local server or singleplayer mode + static bool initial_step = true; + if (initial_step) { + initial_step = false; + } + else if(m_state == LC_Created) { float &counter = m_connection_reinit_timer; counter -= dtime; @@ -469,7 +473,6 @@ void Client::step(float dtime) Player *myplayer = m_env.getLocalPlayer(); assert(myplayer != NULL); - // Send TOSERVER_INIT // [0] u16 TOSERVER_INIT // [2] u8 SER_FMT_VER_HIGHEST_READ |