FakeFishGames / Barotrauma

A 2D online multiplayer game taking place in a submarine travelling through the icy depths of Jupiter's moon Europa.
http://www.barotraumagame.com/
1.75k stars 407 forks source link

Hidden submarine list sometimes desyncs if you have specific(?) custom submarines #10195

Closed evilfactory closed 1 year ago

evilfactory commented 2 years ago

Disclaimers

What happened?

For some reason the hidden submarine list will from it looks like desync between the server and client, causing some really weird behavior such as the wrong voted submarines being picked and submarines randomly being put into the hidden submarine list.

These are the two submarines that i used for testing: LocalMods.zip

Reproduction steps

  1. Enable the two submarines i mentioned earlier
  2. Host a server (the bug happens on dedicated server as well as player-hosted servers)
  3. Hide most submarines, leaving only 2 vanilla subs visible
  4. Leave the server
  5. Re-host/re-join the server again
  6. Notice how some visible submarines have swapped places with the hidden submarine section

Bug prevalence

Happens regularly

Version

0.19.14.0

-

No response

Which operating system did you encounter this bug on?

Windows

Relevant error messages and crash reports

No response

evilfactory commented 2 years ago

I did some debugging and found out that ServerSettings.HiddenSubs was different between the server and client, so there's definitely some desync in settings going on.

Hegny commented 1 year ago

I have found similar problem, it looks like in my case it is caused by translation. The list of submarines on the dedicated server is ordered as it should be. The connected client has Russian language. Names for vanilla subs are different (taken from Content\Texts\Russian\RussianVanilla.xml) and the list of subs on the client is ordered accordingly. When the client hides any sub, the sub with the same position in the server list is hidden on the server side (it is stored in serversettings.xml). For beginning of the list (Azimuth, Barsuk) both list have the same numbering, but after that wrong subs are hidden. If all connected clients have the same language installed it has no impact - all clients have the same submarine lists. However, if I want to manually enter a hidden sub in the settings file I have to find a corresponding sub in the server list to write a "fake" subname in to the settings file.

Hegny commented 1 year ago

I managed to solve the problem just by ordering the sub list on the server side: Barotrauma\BarotraumaServer\ServerSource\Screens\NetLobbyScreen.cs

just after string #130: subs = SubmarineInfo.SavedSubmarines.Where(s => s.Type == SubmarineType.Player && !s.HasTag(SubmarineTag.HideInMenus)).ToList();

added: subs = subs.OrderBy(s => s.Name).ToList();

juanjp600 commented 1 year ago

Should be fixed in https://github.com/Regalis11/Barotrauma-development/commit/4d8d014801d96a5b817b890a59ab010609945d90

Regalis11 commented 1 year ago

Tested, no issues found. Closing.