mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 10:03:45 +01:00
Fix rtt >= 0.0f assertion and free_move crash
This commit is contained in:
parent
6b72d8d090
commit
1d1cf000c0
@ -1167,7 +1167,7 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *chan
|
||||
|
||||
// a overflow is quite unlikely but as it'd result in major
|
||||
// rtt miscalculation we handle it here
|
||||
float rtt;
|
||||
float rtt = 0.0f;
|
||||
if (current_time > p.absolute_send_time) {
|
||||
rtt = (current_time - p.absolute_send_time) / 1000.0f;
|
||||
} else if (p.totaltime > 0) {
|
||||
@ -1176,7 +1176,8 @@ SharedBuffer<u8> ConnectionReceiveThread::handlePacketType_Control(Channel *chan
|
||||
|
||||
// Let peer calculate stuff according to it
|
||||
// (avg_rtt and resend_timeout)
|
||||
dynamic_cast<UDPPeer *>(peer)->reportRTT(rtt);
|
||||
if (rtt != 0.0f)
|
||||
dynamic_cast<UDPPeer *>(peer)->reportRTT(rtt);
|
||||
}
|
||||
// put bytes for max bandwidth calculation
|
||||
channel->UpdateBytesSent(p.data.getSize(), 1);
|
||||
|
@ -76,22 +76,18 @@ Player::Player(const char *name, IItemDefManager *idef):
|
||||
hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT;
|
||||
|
||||
m_player_settings.readGlobalSettings();
|
||||
g_settings->registerChangedCallback("free_move", &Player::settingsChangedCallback,
|
||||
&m_player_settings);
|
||||
g_settings->registerChangedCallback("fast_move", &Player::settingsChangedCallback,
|
||||
&m_player_settings);
|
||||
g_settings->registerChangedCallback("continuous_forward",
|
||||
// Register player setting callbacks
|
||||
for (const std::string &name : m_player_settings.setting_names)
|
||||
g_settings->registerChangedCallback(name,
|
||||
&Player::settingsChangedCallback, &m_player_settings);
|
||||
g_settings->registerChangedCallback("always_fly_fast",
|
||||
&Player::settingsChangedCallback, &m_player_settings);
|
||||
g_settings->registerChangedCallback("aux1_descends",
|
||||
&Player::settingsChangedCallback, &m_player_settings);
|
||||
g_settings->registerChangedCallback(
|
||||
"noclip", &Player::settingsChangedCallback, &m_player_settings);
|
||||
}
|
||||
|
||||
Player::~Player()
|
||||
{
|
||||
// m_player_settings becomes invalid, remove callbacks
|
||||
for (const std::string &name : m_player_settings.setting_names)
|
||||
g_settings->deregisterChangedCallback(name,
|
||||
&Player::settingsChangedCallback, &m_player_settings);
|
||||
clearHud();
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,10 @@ struct PlayerSettings
|
||||
bool aux1_descends = false;
|
||||
bool noclip = false;
|
||||
|
||||
const std::string setting_names[6] = {
|
||||
"free_move", "fast_move", "continuous_forward", "always_fly_fast",
|
||||
"aux1_descends", "noclip"
|
||||
};
|
||||
void readGlobalSettings();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user