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

Fix GameConditionManager.MapBrightnessTracker (Unnatural Darkness) desyncs #453

Merged
merged 1 commit into from
May 24, 2024

Conversation

SokyranTheDragon
Copy link
Member

GameConditionManager.MapBrightnessTracker:Tick uses Time.deltaTime, the value of which will be different between the players. With similar FPS they'll be very close to one another, but if there's a big change between FPS values (for example, 60 and 144) the issue will be much bigger.

The issue with MapBrightnessTracker is the map will get darker at a different rate for each player - in one of my tests, the client finished the transition 10 ticks faster than the host.

The fix here is rather simple - replace deltaTime with a constant value of 1 / 60 or 0.166666... to ensure each 60 ticks in-game will be treated as a second, no matter the game speed.

…syncs

GameConditionManager.MapBrightnessTracker:Tick uses Time.deltaTime, the value of which will be different between the players. With similar FPS they'll be very close to one another, but if there's a big change between FPS values (for example, 60 and 144) the issue will be much bigger.

The issue with MapBrightnessTracker is the map will get darker at a different rate for each player - in one of my tests, the client finished the transition 10 ticks faster than the host.

The fix here is rather simple - replace `deltaTime` with a constant value of `1 / 60` or `0.166666...` to ensure each 60 ticks in-game will be treated as a second, no matter the game speed.
@SokyranTheDragon SokyranTheDragon added fix Fixes for a bug or desync. 1.5 Fixes or bugs relating to 1.5 (Not Anomaly). labels Apr 29, 2024
@SokyranTheDragon
Copy link
Member Author

To add a bit more on why it's going to cause desyncs - there's a bit of code that checks for the darkness value during simulation - from what I saw, it's used to decide if a specific hediff should be removed as well as affecting the duration of weather changes.

@SokyranTheDragon SokyranTheDragon mentioned this pull request May 6, 2024
@Zetrith Zetrith merged commit d980e3b into rwmt:master May 24, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.5 Fixes or bugs relating to 1.5 (Not Anomaly). fix Fixes for a bug or desync.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants