diff options
Diffstat (limited to 'src/network/connection.cpp')
-rw-r--r-- | src/network/connection.cpp | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/network/connection.cpp b/src/network/connection.cpp index a4970954f..548b2e3a0 100644 --- a/src/network/connection.cpp +++ b/src/network/connection.cpp @@ -578,7 +578,7 @@ u16 Channel::getOutgoingSequenceNumber(bool& successful) // ugly cast but this one is required in order to tell compiler we // know about difference of two unsigned may be negative in general // but we already made sure it won't happen in this case - if (((u16)(next_outgoing_seqnum - lowest_unacked_seqnumber)) > window_size) { + if (((u16)(next_outgoing_seqnum - lowest_unacked_seqnumber)) > m_window_size) { successful = false; return 0; } @@ -588,7 +588,7 @@ u16 Channel::getOutgoingSequenceNumber(bool& successful) // know about difference of two unsigned may be negative in general // but we already made sure it won't happen in this case if ((next_outgoing_seqnum + (u16)(SEQNUM_MAX - lowest_unacked_seqnumber)) > - window_size) { + m_window_size) { successful = false; return 0; } @@ -666,7 +666,7 @@ void Channel::UpdateTimers(float dtime) //packet_too_late = current_packet_too_late; packets_successful = current_packet_successful; - if (current_bytes_transfered > (unsigned int) (window_size*512/2)) { + if (current_bytes_transfered > (unsigned int) (m_window_size*512/2)) { reasonable_amount_of_data_transmitted = true; } current_packet_loss = 0; @@ -681,37 +681,25 @@ void Channel::UpdateTimers(float dtime) if (packets_successful > 0) { successful_to_lost_ratio = packet_loss/packets_successful; } else if (packet_loss > 0) { - window_size = std::max( - (window_size - 10), - MIN_RELIABLE_WINDOW_SIZE); + setWindowSize(m_window_size - 10); done = true; } if (!done) { - if ((successful_to_lost_ratio < 0.01f) && - (window_size < MAX_RELIABLE_WINDOW_SIZE)) { + if (successful_to_lost_ratio < 0.01f) { /* don't even think about increasing if we didn't even * use major parts of our window */ if (reasonable_amount_of_data_transmitted) - window_size = std::min( - (window_size + 100), - MAX_RELIABLE_WINDOW_SIZE); - } else if ((successful_to_lost_ratio < 0.05f) && - (window_size < MAX_RELIABLE_WINDOW_SIZE)) { + setWindowSize(m_window_size + 100); + } else if (successful_to_lost_ratio < 0.05f) { /* don't even think about increasing if we didn't even * use major parts of our window */ if (reasonable_amount_of_data_transmitted) - window_size = std::min( - (window_size + 50), - MAX_RELIABLE_WINDOW_SIZE); + setWindowSize(m_window_size + 50); } else if (successful_to_lost_ratio > 0.15f) { - window_size = std::max( - (window_size - 100), - MIN_RELIABLE_WINDOW_SIZE); + setWindowSize(m_window_size - 100); } else if (successful_to_lost_ratio > 0.1f) { - window_size = std::max( - (window_size - 50), - MIN_RELIABLE_WINDOW_SIZE); + setWindowSize(m_window_size - 50); } } } |