Skip to content

Commit 45efe56

Browse files
committed
Legacy-proxy: Use whole startup phase as overhead time.
1 parent e92fc2d commit 45efe56

File tree

2 files changed

+12
-31
lines changed

2 files changed

+12
-31
lines changed

game/legacy-proxy/src/client.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::{collections::BTreeMap, net::SocketAddr, time::Duration};
1+
use std::{collections::BTreeMap, net::SocketAddr};
22

33
use anyhow::anyhow;
44
use arrayvec::ArrayVec;
@@ -208,8 +208,6 @@ pub struct ClientData {
208208
pub latest_input: snap_obj::PlayerInput,
209209
pub latest_char_input: CharacterInput,
210210

211-
pub connect_time: Duration,
212-
213211
pub player_info: NetworkCharacterInfo,
214212

215213
pub latest_inputs: BTreeMap<i32, (CharacterInput, snap_obj::PlayerInput)>,
@@ -226,7 +224,6 @@ impl ProxyClient {
226224
pub fn new(
227225
player_info: NetworkCharacterInfo,
228226
socket: SocketClient,
229-
connect_time: Duration,
230227
id: u64,
231228
secondary_player: bool,
232229
) -> Self {
@@ -255,8 +252,6 @@ impl ProxyClient {
255252
inp
256253
},
257254

258-
connect_time,
259-
260255
player_info,
261256

262257
latest_inputs: Default::default(),

game/legacy-proxy/src/lib.rs

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,8 @@ struct Client {
347347
log: ConnectingLog,
348348

349349
last_snapshot: Snapshot,
350+
351+
start_time: Duration,
350352
}
351353

352354
impl Client {
@@ -356,6 +358,7 @@ impl Client {
356358
addr: SocketAddr,
357359
log: ConnectingLog,
358360
) -> anyhow::Result<LegacyProxy> {
361+
let proxy_start = time.now();
359362
let fs = io.fs.clone();
360363

361364
log.log("Preparing proxy socket");
@@ -675,6 +678,8 @@ impl Client {
675678
is_finished: is_finished_thread,
676679

677680
log,
681+
682+
start_time: proxy_start,
678683
};
679684

680685
app.run_loop().unwrap();
@@ -3528,13 +3533,7 @@ impl Client {
35283533

35293534
self.players.insert(
35303535
self.base.id_generator.next_id(),
3531-
ProxyClient::new(
3532-
Default::default(),
3533-
sock_loop,
3534-
self.time.now(),
3535-
0,
3536-
false,
3537-
),
3536+
ProxyClient::new(Default::default(), sock_loop, 0, false),
35383537
);
35393538
}
35403539
}
@@ -3564,13 +3563,7 @@ impl Client {
35643563

35653564
self.players.insert(
35663565
self.base.id_generator.next_id(),
3567-
ProxyClient::new(
3568-
Default::default(),
3569-
sock_loop,
3570-
self.time.now(),
3571-
0,
3572-
false,
3573-
),
3566+
ProxyClient::new(Default::default(), sock_loop, 0, false),
35743567
);
35753568
}
35763569
ClientToServerMessage::Ready(msg) => {
@@ -3619,13 +3612,7 @@ impl Client {
36193612
let player_id = self.base.id_generator.next_id();
36203613
self.players.insert(
36213614
player_id,
3622-
ProxyClient::new(
3623-
ev.player_info,
3624-
sock_loop,
3625-
self.time.now(),
3626-
ev.id,
3627-
true,
3628-
),
3615+
ProxyClient::new(ev.player_info, sock_loop, ev.id, true),
36293616
);
36303617
if let Some(con_id) = self.con_id {
36313618
self.server_network.send_unordered_to(
@@ -4531,10 +4518,9 @@ impl Client {
45314518
self.server_network.send_unordered_to(
45324519
&ServerToClientMessage::ServerInfo {
45334520
info: server_info,
4534-
overhead: self
4535-
.time
4536-
.now()
4537-
.saturating_sub(player.data.connect_time),
4521+
// the proxy is not really good at estimating the first ping
4522+
// so give it the whole startup time as overhead instead
4523+
overhead: self.time.now().saturating_sub(self.start_time),
45384524
},
45394525
&con_id,
45404526
);

0 commit comments

Comments
 (0)