Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make framerate / TPS configurable #14

Open
ErnWong opened this issue Jun 17, 2021 · 2 comments
Open

Make framerate / TPS configurable #14

ErnWong opened this issue Jun 17, 2021 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ErnWong
Copy link

ErnWong commented Jun 17, 2021

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.

@james7132 james7132 added enhancement New feature or request good first issue Good for newcomers labels Jun 17, 2021
@james7132
Copy link
Member

For most 60FPS games this is likely OK, but this should really be configurable.

This was directly ported from GGPO. The calculation does seem to be off. We should have a divide by two there.

james7132 pushed a commit that referenced this issue Jun 17, 2021
Addresses an issue mentioned in #14. 

Authored by: ValorZard
Signed off by: james7132
@james7132
Copy link
Member

The RTT computation should be fixed now as of #15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants