Comment 18 for bug 1811583

Revision history for this message
Notabilis (notabilis27) wrote :

Hey, who said that I will be fixing all these bugs??? ;-)

But I have enough data to look at for now, thanks. The game played by Teppo and kaputtnik doesn't seem to be useful for debugging, but I will have another look at it. The syncstream contains the entry that the client is doing something with entity 3619. Well, whatever that might be. Maybe I should add huge amounts of debug output for this desync, but I have to think about it first.

Debugging the desync between Hasi50 and kaputtnik was more successful. The syncstream pointed to a problem with Lua code running only on the host. Based on the script files, I think it was the code path:
[territorial_lord.lua]main loop -> _send_state() -> [messages.lua]send_message() -> [ui.lua]wait_for_roadbuilding() -> _await_animation() -> sleep(41).
I guess what happened is that the player moved the map view (possibly by clicking on the minimap, see _await_animation()) when the status message was received, resulting in the sleep call being triggered. The sleep command results in the script execution to be rescheduled for 41ms later. This leads to another entry in the command queue and in the syncstream, leading to desynchronized games. The same can probably happen in all other scenarios where popup messages are used. Besides moving the map this desync can also be triggered by being in road building mode when a message should be received (I tested this one) and probably also in other cases (don't know, but someone should check the sleep() calls in all multiplayer scripts).
I am unsure how to fix this, if someone has an idea feel free to give it a try. Hm, spontaneous idea, uh, suggestion: Check whether it is a single- or multiplayer game and only be nice (i.e., wait for the player to finish the road) when in singleplayer. And probably add a documentation command that the sleep() call always has to be run for all participants of a game.

Oh, and regarding your question about testing internet games: It shouldn't make any difference whether it is on the same computer, over the LAN or over the relay server. The (relevant) code paths should always be the same. Besides, desyncs are due to bugs in the logic code somewhere and not in the network code.