Page MenuHomeWildfire Games

Prevent OOS on rejoin by preventing the NetServer from changing GameSettings after starting the game

Authored by elexis on Jun 4 2018, 8:40 PM.



As reported in #5199 and fixed in the GUI in D1558, when doubleclicking on the StartGame button of the gamesetup as a host, launchGame of gamesetup.js will be executed twice.
This will cause the NetServer to start the game, then compute a new RNG seed and broadcast that. So the mapgen is done with the first seed but the simulation uses the second seed.
Then rejoiners will compute the mapgen with the first seed.

This patch fixes this issue more at the root of the problem and doesn't rely on the JS GUI being sane.

Similar to D1513 and D1556, we notice that splitting the PREGAME state into GAMESETUP and LOADING might have prevented this issue.

Test Plan

Start to host, join the gamesetup in a second window, press F9 with the host, type launchGame(); launchGame();.
You'll get an OOS if the terrain happens to change territory borders near gaia entities (or when moving units across elevation changes I believe).
For both clients, press F9 and type g_GameAttributes.settings.Seed and notice that both clients use different seeds.
Apply the patch and see that it's fixed.
Notice that clients may be as broken as they want without being able to introduce an OOS.

Diff Detail

rP 0 A.D. Public Repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

elexis created this revision.Jun 4 2018, 8:40 PM
Vulcan added a subscriber: Vulcan.Jun 4 2018, 8:48 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build:

temple accepted this revision.Jun 5 2018, 1:48 AM
temple added a subscriber: temple.

I'm not familiar with the NetServer code, but the test plan worked. (I can't double-click fast enough to test D1558.)

This revision is now accepted and ready to land.Jun 5 2018, 1:48 AM
This revision was automatically updated to reflect the committed changes.