1
0
mirror of https://github.com/minetest/minetest.git synced 2025-07-07 02:10:22 +02:00

Various code improvements

* Camera: Fix division by 0 after view bobbing
* Remove ignored constness
* Connection: Improve window size range limits
This commit is contained in:
SmallJoker
2021-09-27 17:45:44 +02:00
committed by GitHub
parent 918fbe3ec1
commit d51d0f3a5a
11 changed files with 40 additions and 47 deletions

View File

@ -420,34 +420,38 @@ public:
void UpdateTimers(float dtime);
const float getCurrentDownloadRateKB()
float getCurrentDownloadRateKB()
{ MutexAutoLock lock(m_internal_mutex); return cur_kbps; };
const float getMaxDownloadRateKB()
float getMaxDownloadRateKB()
{ MutexAutoLock lock(m_internal_mutex); return max_kbps; };
const float getCurrentLossRateKB()
float getCurrentLossRateKB()
{ MutexAutoLock lock(m_internal_mutex); return cur_kbps_lost; };
const float getMaxLossRateKB()
float getMaxLossRateKB()
{ MutexAutoLock lock(m_internal_mutex); return max_kbps_lost; };
const float getCurrentIncomingRateKB()
float getCurrentIncomingRateKB()
{ MutexAutoLock lock(m_internal_mutex); return cur_incoming_kbps; };
const float getMaxIncomingRateKB()
float getMaxIncomingRateKB()
{ MutexAutoLock lock(m_internal_mutex); return max_incoming_kbps; };
const float getAvgDownloadRateKB()
float getAvgDownloadRateKB()
{ MutexAutoLock lock(m_internal_mutex); return avg_kbps; };
const float getAvgLossRateKB()
float getAvgLossRateKB()
{ MutexAutoLock lock(m_internal_mutex); return avg_kbps_lost; };
const float getAvgIncomingRateKB()
float getAvgIncomingRateKB()
{ MutexAutoLock lock(m_internal_mutex); return avg_incoming_kbps; };
const unsigned int getWindowSize() const { return window_size; };
u16 getWindowSize() const { return m_window_size; };
void setWindowSize(long size)
{
m_window_size = (u16)rangelim(size, MIN_RELIABLE_WINDOW_SIZE, MAX_RELIABLE_WINDOW_SIZE);
}
void setWindowSize(unsigned int size) { window_size = size; };
private:
std::mutex m_internal_mutex;
int window_size = MIN_RELIABLE_WINDOW_SIZE;
u16 m_window_size = MIN_RELIABLE_WINDOW_SIZE;
u16 next_incoming_seqnum = SEQNUM_INITIAL;
@ -765,7 +769,7 @@ public:
Address GetPeerAddress(session_t peer_id);
float getPeerStat(session_t peer_id, rtt_stat_type type);
float getLocalStat(rate_stat_type type);
const u32 GetProtocolID() const { return m_protocol_id; };
u32 GetProtocolID() const { return m_protocol_id; };
const std::string getDesc();
void DisconnectPeer(session_t peer_id);