Skip to content

Add frame aware advance gate - #74

Draft
11EJDE11 wants to merge 3 commits into
CnCNet:mainfrom
11EJDE11:frame-aware-gate
Draft

Add frame aware advance gate#74
11EJDE11 wants to merge 3 commits into
CnCNet:mainfrom
11EJDE11:frame-aware-gate

Conversation

@11EJDE11

@11EJDE11 11EJDE11 commented Aug 5, 2026

Copy link
Copy Markdown
Member

To advance a frame, Wait_For_Players currently checks their[i].recv >= their[i].sent. If a peer is behind on that count, the game stalls, even if the missing commands are for future frames and MaxAhead still allows simulation to continue.

This PR replaces the count-based check with a frame-aware one. A peer is considered caught up once all commands for frames <= current are known to have been received, based on each packet's (Frame, cumulative count) stamp.

In practice, this lets the game continue for a few more frames instead of stalling immediately. If the delayed packet arrives before those frames are reached, the stall is avoided entirely.

Also fixes a bug found along the way: CommandCountStalls was writing to the wrong per-peer index under packet loss, corrupting and unrelated frame-timing accumulator.

I've tested a few games. 3 players, 1 with 20% drop (using Clumsy) in/out.

Build Effective FPS
Baseline (current implementation) 11.6-12.6
With this change 14.7-15.8

So not huge savings, but in my testing with a < 5000 frame game, there were about ~50 times this kicked in.


Vanilla:
bad_frame_gate

With this PR:
good_frame_gate

Draft until Phobos-developers/YRpp#75

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant