PhilippvK / playforia-minigolf

Client & Server for Minigolf Game known from Playforia/Playray/Appeli. Written in Java.
84 stars 31 forks source link

Desyncs while playing multiplayer #99

Open pehala opened 3 years ago

pehala commented 3 years ago

In the current network scheme, the server doesn't check clients positions so sometimes the client goes out of sync (he sees different ball positions) than the rest of the players.

PhilippvK commented 3 years ago

Yes, I experienced that a lot when testing the 10-player multiplayer lobby feature I was working on.

pehala commented 3 years ago

Yeah, it is surprisingly common even in 4 player games.

The solution that I plan on implementing in #98 is to have player clients "vote" on what is the right position and the server then decides based on a majority of players (ties would be decided based on who round it is). WDYT of this solution?

A better solution would be to have a copy of the game logic on the server so we could validate turns there, however, this would mean ripping the game logic out of UI (Who thought mixing logic and UI was a good idea in the first place? :D), deciphering it and adding it to the server.

PhilippvK commented 3 years ago

Majority vote is totally fine for me. Even for 2-player matches it should not lead to inconsistencies if I understood correctly.

thewavelength commented 2 years ago

I even experience this on 2 player games. I really don't understand why this is happening. Seems to randomly happen and we didn't find a way to reproduce it.

Does somebody has an idea? If I could get a hint where to start searching I could have a look.

Or is this a fundamental flaw in the way the communication works and is basically "unfixable" without the proposed voting system (or relocation of positioning code to the server)?

pehala commented 2 years ago

I think it happens because it is inherently a chaos system and slightest desynchronization or a small change in some float variable yields a very different result. It sadly a black box system too because the code is unreadable. My proposed solution would be server check which would synchronize it between players after each turn. Sadly this requires rewrite of a network system, because current code base is terrible. I am working on the rewrite (and this issue will definitely be fixed once that is finished) but it takes a very long time. ( I have linked PR open for that)