I think I found a source for a/one/the desync-bug.
In src/economy/economy.cc around line 960 the code checks the requirements to create a new worker (called when a new building is finished but no matching worker is currently in a warehouse). For this, the buildcosts of the worker are checked (e.g. for a fisher: carrier + fishing rod). However, for all buildcosts
is called to get the ware index, even for the carrier. This results in id_w=255 (= not found since "barbarian_carrier" is no known ware). In
ware_target_quantity(id_w).permanent
this gives an array access behind the end of the target-quantity-array with varying return values; on each call and most important on client and server. Most of the time this is non-zero but sometimes it is, resulting in a different code path later on (and in the end, in a request which is only created locally).
Oh, and an easy way to produce this desync:
- Start a (localhost) multiplayer game
- On the client build three fisher huts (so the last one stays vacant)
- Build a connected street with multiple flags
- Split and reconnect this street so the game creates/destroys new economies (one per street-network). Doing this often enough results in a desync for me
I think I found a source for a/one/the desync-bug. economy. cc around line 960 the code checks the requirements to create a new worker (called when a new building is finished but no matching worker is currently in a warehouse). For this, the buildcosts of the worker are checked (e.g. for a fisher: carrier + fishing rod). However, for all buildcosts
In src/economy/
DescriptionIndex id_w = tribe.ware_ index(bc. first);
is called to get the ware index, even for the carrier. This results in id_w=255 (= not found since "barbarian_carrier" is no known ware). In
ware_target_ quantity( id_w).permanent
this gives an array access behind the end of the target- quantity- array with varying return values; on each call and most important on client and server. Most of the time this is non-zero but sometimes it is, resulting in a different code path later on (and in the end, in a request which is only created locally).
Oh, and an easy way to produce this desync:
- Start a (localhost) multiplayer game
- On the client build three fisher huts (so the last one stays vacant)
- Build a connected street with multiple flags
- Split and reconnect this street so the game creates/destroys new economies (one per street-network). Doing this often enough results in a desync for me