1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Remove legacy client handling code.

This commit is contained in:
Lars Hofhansl 2018-07-14 11:38:52 -07:00
parent b38c121856
commit ca8ec46843
3 changed files with 57 additions and 127 deletions

View file

@ -600,7 +600,7 @@ void Channel::UpdateBytesSent(unsigned int bytes, unsigned int packets)
{
MutexAutoLock internal(m_internal_mutex);
current_bytes_transfered += bytes;
current_packet_successfull += packets;
current_packet_successful += packets;
}
void Channel::UpdateBytesReceived(unsigned int bytes) {
@ -627,17 +627,16 @@ void Channel::UpdatePacketTooLateCounter()
current_packet_too_late++;
}
void Channel::UpdateTimers(float dtime,bool legacy_peer)
void Channel::UpdateTimers(float dtime)
{
bpm_counter += dtime;
packet_loss_counter += dtime;
if (packet_loss_counter > 1.0)
{
packet_loss_counter -= 1.0;
if (packet_loss_counter > 1.0f) {
packet_loss_counter -= 1.0f;
unsigned int packet_loss = 11; /* use a neutral value for initialization */
unsigned int packets_successfull = 0;
unsigned int packets_successful = 0;
//unsigned int packet_too_late = 0;
bool reasonable_amount_of_data_transmitted = false;
@ -646,94 +645,78 @@ void Channel::UpdateTimers(float dtime,bool legacy_peer)
MutexAutoLock internal(m_internal_mutex);
packet_loss = current_packet_loss;
//packet_too_late = current_packet_too_late;
packets_successfull = current_packet_successfull;
packets_successful = current_packet_successful;
if (current_bytes_transfered > (unsigned int) (window_size*512/2))
{
if (current_bytes_transfered > (unsigned int) (window_size*512/2)) {
reasonable_amount_of_data_transmitted = true;
}
current_packet_loss = 0;
current_packet_too_late = 0;
current_packet_successfull = 0;
current_packet_successful = 0;
}
/* dynamic window size is only available for non legacy peers */
if (!legacy_peer) {
float successfull_to_lost_ratio = 0.0;
bool done = false;
/* dynamic window size */
float successful_to_lost_ratio = 0.0f;
bool done = false;
if (packets_successfull > 0) {
successfull_to_lost_ratio = packet_loss/packets_successfull;
}
else if (packet_loss > 0)
{
window_size = MYMAX(
(window_size - 10),
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);
done = true;
}
if (!done) {
if ((successful_to_lost_ratio < 0.01f) &&
(window_size < MAX_RELIABLE_WINDOW_SIZE)) {
/* 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)) {
/* 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);
} else if (successful_to_lost_ratio > 0.15f) {
window_size = std::max(
(window_size - 100),
MIN_RELIABLE_WINDOW_SIZE);
} else if (successful_to_lost_ratio > 0.1f) {
window_size = std::max(
(window_size - 50),
MIN_RELIABLE_WINDOW_SIZE);
done = true;
}
if (!done)
{
if ((successfull_to_lost_ratio < 0.01) &&
(window_size < MAX_RELIABLE_WINDOW_SIZE))
{
/* 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 = MYMIN(
(window_size + 100),
MAX_RELIABLE_WINDOW_SIZE);
}
else if ((successfull_to_lost_ratio < 0.05) &&
(window_size < MAX_RELIABLE_WINDOW_SIZE))
{
/* 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 = MYMIN(
(window_size + 50),
MAX_RELIABLE_WINDOW_SIZE);
}
else if (successfull_to_lost_ratio > 0.15)
{
window_size = MYMAX(
(window_size - 100),
MIN_RELIABLE_WINDOW_SIZE);
}
else if (successfull_to_lost_ratio > 0.1)
{
window_size = MYMAX(
(window_size - 50),
MIN_RELIABLE_WINDOW_SIZE);
}
}
}
}
if (bpm_counter > 10.0)
{
if (bpm_counter > 10.0f) {
{
MutexAutoLock internal(m_internal_mutex);
cur_kbps =
(((float) current_bytes_transfered)/bpm_counter)/1024.0;
(((float) current_bytes_transfered)/bpm_counter)/1024.0f;
current_bytes_transfered = 0;
cur_kbps_lost =
(((float) current_bytes_lost)/bpm_counter)/1024.0;
(((float) current_bytes_lost)/bpm_counter)/1024.0f;
current_bytes_lost = 0;
cur_incoming_kbps =
(((float) current_bytes_received)/bpm_counter)/1024.0;
(((float) current_bytes_received)/bpm_counter)/1024.0f;
current_bytes_received = 0;
bpm_counter = 0;
bpm_counter = 0.0f;
}
if (cur_kbps > max_kbps)
{
if (cur_kbps > max_kbps) {
max_kbps = cur_kbps;
}
if (cur_kbps_lost > max_kbps_lost)
{
if (cur_kbps_lost > max_kbps_lost) {
max_kbps_lost = cur_kbps_lost;
}
@ -903,6 +886,8 @@ void Peer::Drop()
UDPPeer::UDPPeer(u16 a_id, Address a_address, Connection* connection) :
Peer(a_address,a_id,connection)
{
for (Channel &channel : channels)
channel.setWindowSize(g_settings->getU16("max_packets_per_iteration"));
}
bool UDPPeer::getAddress(MTProtocols type,Address& toset)
@ -916,15 +901,6 @@ bool UDPPeer::getAddress(MTProtocols type,Address& toset)
return false;
}
void UDPPeer::setNonLegacyPeer()
{
m_legacy_peer = false;
for(unsigned int i=0; i< CHANNEL_COUNT; i++)
{
channels[i].setWindowSize(g_settings->getU16("max_packets_per_iteration"));
}
}
void UDPPeer::reportRTT(float rtt)
{
assert(rtt >= 0.0f);