use full rtt instead of half rtt for determining simulation tick count
This commit is contained in:
parent
6442998795
commit
89a4b3b22f
@ -85,6 +85,8 @@ struct host_channel {
|
||||
u64 their_acked_seq;
|
||||
u64 our_acked_seq;
|
||||
u64 last_sent_seq;
|
||||
|
||||
i64 last_packet_received_ns;
|
||||
};
|
||||
|
||||
struct host_channel_node {
|
||||
@ -685,9 +687,12 @@ void host_update(struct host *host)
|
||||
u8 packet_flags = br_read_ubits(&br, 8);
|
||||
|
||||
u64 their_acked_seq = br_read_uv(&br);
|
||||
if (channel->valid) {
|
||||
channel->last_packet_received_ns = now_ns;
|
||||
if (their_acked_seq > channel->their_acked_seq) {
|
||||
channel->their_acked_seq = their_acked_seq;
|
||||
}
|
||||
}
|
||||
|
||||
b32 skip_packet = false;
|
||||
b32 is_reliable = packet_flags & HOST_PACKET_FLAG_RELIABLE;
|
||||
|
||||
@ -2115,8 +2115,9 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg)
|
||||
if (is_master) {
|
||||
desired_step_tick = local_client->last_tick + 1;
|
||||
} else {
|
||||
i64 half_rtt_ns = master_client->rtt_ns / 2;
|
||||
i64 num_predict_ticks = (half_rtt_ns + (step_dt_ns - 1)) / step_dt_ns; /* Half rtt in ticks */
|
||||
i64 rtt_ns = master_client->rtt_ns;
|
||||
f64 rtt_tick_ratio = (f64)(rtt_ns + (step_dt_ns - 1)) / (f64)step_dt_ns;
|
||||
i64 num_predict_ticks = math_round_to_int64(rtt_tick_ratio);
|
||||
num_predict_ticks += 2; /* Jitter buffer */
|
||||
desired_step_tick = master_client->last_tick + num_predict_ticks;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user