Desync in Smugglers scenario

Bug #1751440 reported by GunChleoc
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
widelands
Fix Released
High
Unassigned

Bug Description

I encountered a desync in the Smugglers scenario. It happens during the smuggling of wares.

I am attaching a savegame. Although it was created on a branch, the bug will also reproduce on trunk.

The bug was introduced somewhere between Build 18 and Build 19.

build18 6828
build19-rc1 8143

The problem is the random selection of wares - some shortened test output:

[Client]: sending timestamp: 2154276
Player: GunChleoc Warping ware: granite
[Client]: sending timestamp: 2156444
[Client]: sending timestamp: 2162867
Player: Player 2 Warping ware: granite
[Client]: sending timestamp: 2165167
Player: GunChleoc Warping ware: blackwood
[Client]: sending timestamp: 2167347

[Host]: Client 0: Time 2154276
Player: GunChleoc Warping ware: granite
[Host]: Client 0: Time 2156444
[Host]: Client 0: Time 2162867
Player: Player 2 Warping ware: granite
[Host]: Client 0: Time 2165167
Player: GunChleoc Warping ware: barbarians_bread
[Host]: Client 0: Time 2167347

Related branches

Revision history for this message
GunChleoc (gunchleoc) wrote :
Revision history for this message
GunChleoc (gunchleoc) wrote :

The bug is already present in Build 19

Revision history for this message
GunChleoc (gunchleoc) wrote :

Build 18 doesn't seem to have the bug

description: updated
GunChleoc (gunchleoc)
description: updated
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
Revision history for this message
GunChleoc (gunchleoc) wrote :

I tried replacing math.random with game:logic_rand(), which didn't help. The attached branch uses the most abundant ware instead of a random ware. This is more stable, but will desync eventually.

I think the source of the problem is that the loop is called at slightly different time stamps by the different clients, so the contents of the warehouses can be different too when a ware is picked for smuggling.

GunChleoc (gunchleoc)
Changed in widelands:
assignee: GunChleoc (gunchleoc) → nobody
GunChleoc (gunchleoc)
Changed in widelands:
status: New → In Progress
assignee: nobody → GunChleoc (gunchleoc)
GunChleoc (gunchleoc)
Changed in widelands:
status: In Progress → Confirmed
assignee: GunChleoc (gunchleoc) → nobody
Revision history for this message
Teppo Mäenpää (kxq) wrote :

I faced this, too, some days ago.

I did not understand #4: Does the lua run asynchronously?

Revision history for this message
GunChleoc (gunchleoc) wrote :

It should not, but it seems that there is some problem with it anyway - eventually, the wares picked will be different from each other, even if the server and clients are running on the same machine. I don't know what the solution will be at this point: maybe we will need to shift some stuff to C++.

GunChleoc (gunchleoc)
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
status: Confirmed → In Progress
Revision history for this message
GunChleoc (gunchleoc) wrote :

Seems like the heart of the problem is that we have the smuggling running in concurrent coroutines - the order in which those are run seems to be nondeterministic now. I have attached a branch that should fix it.

Revision history for this message
Teppo Mäenpää (kxq) wrote :

Wonderful. Thanks.

Smuggling the most abundant ware modification. sounded good, are we keeping it too?

Revision history for this message
GunChleoc (gunchleoc) wrote :

I decided to go round robin, because I still had the code for that, and I got a bit tired of testing this for now.

Another bonus: If you hack the player names packet, you can play any tribe now :)

GunChleoc (gunchleoc)
Changed in widelands:
status: In Progress → Fix Committed
assignee: GunChleoc (gunchleoc) → nobody
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.