jsettlers / settlers-remake

A Remake of "The Settlers III" for Windows, Linux, Mac and Android
http://www.settlers-android-clone.com
MIT License
355 stars 101 forks source link

Implement sync check for multiplayer #3

Open andreas-eberle opened 9 years ago

andreas-eberle commented 9 years ago

In multiplayer the game should check if the players are still in sync. This would prevent a later "manual" detection and therefore the loss of a lot of playing time. Furthermore, it would help to detect bugs that cause the asynchronism.

Suggested Implementation All clients could regularly (all clients at the same game time) send a calculated pseudo random number of the game's random generator. If the game is in sync, these numbers are all equal. If the game is out of snyc, the numbers will differ immediately.

abledbody commented 8 years ago

If the game gets out of sync it may be wise to slow down the users in the future's game slightly until they are in sync to make the proces smooth and unnoticable, especially when playing against a laggy machine.

michaelzangl commented 8 years ago

Delaying slow players is a different proble. In this case here, a game command has already been executed on client but not on the other. This cannot be repaired, we need to restore an older game status or sync back with one master player.

abledbody commented 8 years ago

Ahhh, i see.

Hiradur commented 7 years ago

Return To The Roots, the Settlers II engine reimplementation, additionally provides a log file which makes tracking down causes for desyncs easier. This guide on how to track down a Desync may serve as an inspiration: https://github.com/Return-To-The-Roots/s25client/wiki/Async---What-is-that-and-how-to-help-fixing-it%3F

andreas-eberle commented 7 years ago

@Hiradur: Thanks for the link.

In general, our netcode prevents desyncs by design. So only a bug in that system or the usage of random numbers could cause a desync. That's why I think a simple check would be enough for now. The problem should never occur ;)