Latest Posts

Topic: Diverging score graphs in multiplayer

Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1583
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-02-27, 14:03

At gametime 0:17:19, player 5 (black) tries to build a stonemason's house. This succeeds on the host but fails on the client due to a tree having grown on the site of interest. By this time the tree growth pattern around the foresters has already visibly diverged. Will debug in more detail now.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2161
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2022-02-27, 14:10

At least we now have a suspect face-wink.png


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1583
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-02-27, 14:33

We don't, this was just an observation to narrow down the time of the desync face-smile.png The sync output is 21 million lines up to then as it is, which is kind of hard to work with.

The first desync happens when a bob's position changes: In the host replay, the bob (serial 20cf) moves to 25×50; in the client replay, it moves to 24×4f. This happens at the exact gametime 00:12:15.517.
Interestingly the code that creates this sync statement has a comment:

    // Since pretty much everything in Widelands eventually results in the
    // movement of a worker (e.g. transporting wares etc.), this should
    // help us to find desyncs pretty rapidly.
    // In particular, I wanted to add something to set_position because
    // it involves coordinates and will thus additionally highlight desyncs
    // in pathfinding even when two paths have the same length, and in
    // randomly generated movements.

Makes things easier face-grin.png

Will now try to catch the erratic bob with a debugger…


Edit: The bob in question is a barbarian fisher belonging to player 7 who is walking towards node 39×77 (host) or 39×85 (client)

Another edit: The desync happens in the pathfinding code, specifically template Map::find_reachable in which the queue is being built and iterated in a different order. The immovables etc on all fields seem to be the same so walkability should not be a problem.

Still investigating further…


I found a discrepancy that happens right at the start: Node 39×84 contains the resource water for the host but fish for the client. So the first time a fisher is built nearby it goes out of sync. This map does not seem to define resources there so probably a bug in default resources computation…

I can reproduce that starting a new LAN game on this map causes this divergence to arise immediately on the same node. Definitely a problem with default resources.


Edit: Found the root cause, as always in an unexpected place: The main menu map preview! Preparing a fix now.

Edited: 2022-02-27, 18:44

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1583
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-02-27, 18:50

Fix is up: https://github.com/widelands/widelands/pull/5288

The problem was that the code that renders the map preview in the Launch Game screen dirtied the map's description load order, which can affect the game state in unpredictable ways.


Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1583
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2022-02-28, 12:33

The fix has been merged now.


Top Quote
hessenfarmer
Avatar
Joined: 2014-12-11, 23:16
Posts: 2161
Ranking
One Elder of Players
Location: Bavaria
Posted at: 2022-02-28, 13:50

Nordfriese wrote:

The fix has been merged now.

@pkk It would be good if you could verify it is gone now.


Top Quote
PkK
Joined: 2012-01-06, 12:19
Posts: 235
Ranking
Widelands-Forum-Junkie
Posted at: 2022-03-13, 16:58

hessenfarmer wrote:

Nordfriese wrote:

The fix has been merged now.

@pkk It would be good if you could verify it is gone now.

I just finished a 12 game hours game (4 players, 2 human, 2 ai), and did not encounter any problems.


Top Quote