[Fixed][0.17.79] Desync using Mods in Multiplayer (Endless Resources)

Desyncs in modded game will be ignored most of the time, until it is clearly proven that the desync is not caused by scripting.
Post Reply
MarshMeloz
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Feb 03, 2020 10:40 am
Contact:

[Fixed][0.17.79] Desync using Mods in Multiplayer (Endless Resources)

Post by MarshMeloz »

We started this world a couple of days ago and played the first few hours without any problems. All of a sudden we started having desync issues. There was no specific thing that caused the desync and it happened at random times, sometimes on connection, other times not for 10 or 20 minutes.

We have tried going through disabling mods and have been unable to figure out which mod is causing the issue, if a mod is causing the issue.

I have attached our mod list and a link to the desync report.
mod-list.json
(3.02 KiB) Downloaded 55 times
https://drive.google.com/file/d/1oOk8v_ ... sp=sharing

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 1568
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [0.17.79] Desync using Mods in Multiplayer

Post by boskid »

Thanks for the report.

In desync report, primary differences are around crude-oil resourceAmount and secondary differences are around fluid amounts. I managed to narrow this desync down to one mod: "Endless resources". This mod is flawed as it has variable "tick_counter" that is stored outside of "global" variable so will not be saved, client will start with different(default) value and so it will desync.

User avatar
Philuminati
Inserter
Inserter
Posts: 35
Joined: Sun Aug 05, 2018 1:04 am
Contact:

Re: [0.17.79] Desync using Mods in Multiplayer

Post by Philuminati »

Thanks for the notification. I am the author of the mod and first of all, I don't know much about Lua or the specs of Factorio's API. I was using this counter to make the mod UPS friendly but I understand the problem with it. Could you please explain to me how the global tick counter works and how I access it via Lua, so I can fix this issue.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 1568
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [0.17.79] Desync using Mods in Multiplayer

Post by boskid »

Philuminati wrote:
Tue Feb 04, 2020 9:22 pm
Thanks for the notification. I am the author of the mod and first of all, I don't know much about Lua or the specs of Factorio's API. I was using this counter to make the mod UPS friendly but I understand the problem with it. Could you please explain to me how the global tick counter works and how I access it via Lua, so I can fix this issue.
In control.lua, line 1 you have:

Code: Select all

tick_counter = 17700
This places this variable in lua global scope. Lua context cannot be stored entirely inside save file so only part of its state is stored, for example variable called "global" is serialised using serpent.dump and when loading, is recreated inside new lua state. Shortly speaking: line 1 will be executed inside client's game instance after load and so tick_counter will be different. You have "global.generator" that will be properly handled during save/load since generator is inside "global" variable.

You may want to set initial value of "global.tick_counter" inside callback for script.on_init and then use it inside script.on_event.

Btw, for performance it is better to use script.on_nth_tick rather than catching every tick and counting ticks by yourself.

MarshMeloz
Manual Inserter
Manual Inserter
Posts: 2
Joined: Mon Feb 03, 2020 10:40 am
Contact:

Re: [0.17.79] Desync using Mods in Multiplayer

Post by MarshMeloz »

Thank you so much for the reply, really appreciate the help!!

User avatar
Philuminati
Inserter
Inserter
Posts: 35
Joined: Sun Aug 05, 2018 1:04 am
Contact:

Re: [0.17.79] Desync using Mods in Multiplayer

Post by Philuminati »

I changed the script to use the "on_nth_tick"-method you mentioned. Please tell me if it works without desyncs now. The new version is for 0.18 at the moment so tell me also if you need a version compatible with older savegames.

MagSun
Manual Inserter
Manual Inserter
Posts: 1
Joined: Sun May 17, 2020 7:01 pm
Contact:

Re: [0.17.79] Desync using Mods in Multiplayer

Post by MagSun »

Hello Philuminati,

I've just learned that you've created a fix for 0.18. A friend and I are playing multiplayer on 0.17.79 (current steam version) and suffer from desyncs, where I guess (from the desync-report diff) that the endless resources mod may be one of the troublemakers.

Could you be so kind and provide a 0.17 update as well?

Thanks a lot!

Cheers,
MagSun

User avatar
Philuminati
Inserter
Inserter
Posts: 35
Joined: Sun Aug 05, 2018 1:04 am
Contact:

Re: [Fixed][0.17.79] Desync using Mods in Multiplayer (Endless Resources)

Post by Philuminati »

Sorry for the late answer, I didn't get a notification for your message... :? You can easily modify my latest version to work for 0.17 by editing the "info.json" file in the mods folder. Just edit the part:

Code: Select all

"factorio_version": "0.18",
"dependencies": ["base >= 0.18.0"]
to:

Code: Select all

"factorio_version": "0.17",
"dependencies": ["base >= 0.17.0"]
The mod doesn't use script mechanics that didn't exist in 0.17, so it shouldn't be a problem. If it is though, feel free to write me in the discussion section of the mod... :D

Have fun,

Phil

Post Reply

Return to “Desyncs with mods”