mirror of
https://github.com/gopher64/gopher64.git
synced 2026-07-11 01:25:20 +02:00
update recommendation formula (#1067)
* update recommendation formula * more
This commit is contained in:
+4
-3
@@ -488,11 +488,11 @@ fn update_ping(
|
||||
.duration_since(std::time::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_millis();
|
||||
let ping = (now - message.timestamp) / 2; // calculate one-way latency
|
||||
let ping = (now - message.timestamp) as f64 / 2.0; // calculate one-way latency
|
||||
pings.push(ping);
|
||||
if pings.len() > message.num_of_peers * 4 {
|
||||
// once we have enough samples, remove the highest 2 and return the next highest
|
||||
pings.sort();
|
||||
pings.sort_by(f64::total_cmp);
|
||||
pings.truncate(pings.len() - 2);
|
||||
let ping = *pings.last().unwrap();
|
||||
pings.clear();
|
||||
@@ -503,8 +503,9 @@ fn update_ping(
|
||||
} else {
|
||||
60.0
|
||||
};
|
||||
let latency_frames = (ping / (1000.0 / refresh_rate)).ceil() as i32;
|
||||
let recommendation =
|
||||
((ping as f64 / (1000.0 / refresh_rate)) as i32 + 1).min(8);
|
||||
(latency_frames + 1).min(8);
|
||||
|
||||
if handle.get_netplay_recommended_delay() == 0 {
|
||||
handle.set_netplay_input_delay(recommendation);
|
||||
|
||||
Reference in New Issue
Block a user