Skip to content

Make framerate / TPS configurable #14

@ErnWong

Description

@ErnWong

See:

const TARGET_TPS: u64 = 60;

which is used for estimating the remote player's frame for timesyncing purposes:

pub fn set_local_frame_number(&self, local_frame: Frame) {
let mut stats = self.stats.write();
// Estimate which frame the other guy is one by looking at the
// last frame they gave us plus some delta for the one-way packet
// trip time.
let remote_frame = self.input_decoder.last_decoded_frame()
+ (stats.round_trip_time.as_secs() * TARGET_TPS) as i32;
// Our frame advantage is how many frames *behind* the other guy
// we are. Counter-intuative, I know. It's an advantage because
// it means they'll have to predict more often and our moves will
// pop more frequently.
stats.local_frame_advantage = remote_frame - local_frame;
}

On an unrelated note, it that calculation correct? The comment seems to suggest round_trip_time.as_secs() / 2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions