[0.15.19] Desync with softmod (scenario) on connect

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
User avatar
distortions864
Fast Inserter
Fast Inserter
Posts: 110
Joined: Thu Apr 20, 2017 12:56 am
Contact:

[0.15.19] Desync with softmod (scenario) on connect

Post by distortions864 »

Don't know if this is the script, or a vanilla factorio problem.
But the same script is running on 3 servers... So far only occurred on one server with very large map.
Desync occurs on connect.

Im posting it here, so it is known the cause could possibly be script related.
But, restarting the factorio client seemed to fix issue.

If you need any additional information, let me know.
Thank you!

User avatar
distortions864
Fast Inserter
Fast Inserter
Posts: 110
Joined: Thu Apr 20, 2017 12:56 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by distortions864 »

I did some digging in the report... and it's a bit odd.
See below:

Image
http://i.imgur.com/4qWZKkI.png <--(Click to enlarge)

Is this location object lock data or something else?

daniel34
Global Moderator
Global Moderator
Posts: 2761
Joined: Thu Dec 25, 2014 7:30 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by daniel34 »

If you only show Diffs (4th icon in the toolbar) in Beyond Compare then the cause becomes apparent:
Image
It is an issue with the get_permgroup() function in your softmod, I looked through the code for a few minutes but didn't find the actual cause.

I'm sure though that for some reason the player.print and message_debug calls (lines 353-354) are only executed on the server (reference-level) and not on the client (desynced-level), which is the cause of the desync.
quick links: log file | graphical issues | wiki

User avatar
distortions864
Fast Inserter
Fast Inserter
Posts: 110
Joined: Thu Apr 20, 2017 12:56 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by distortions864 »

Interesting, i'll take a look at it.

Thanks for the feedback.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by Rseding91 »

Code: Select all

script.on_event(defines.events.on_tick, function(event)

if ( is_init == nil or is_init == false ) then
init_vars()
is_init = true
end
Just delete that. It's incorrect in every way possible and what's causing your desync.

You init variables in on_init and nowhere else. Always store any variable you ever plan on changing in the "global" table.
If you want to get ahold of me I'm almost always on Discord.

User avatar
distortions864
Fast Inserter
Fast Inserter
Posts: 110
Joined: Thu Apr 20, 2017 12:56 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by distortions864 »

Roger that.

Thank you for taking the time to look, and reply.
That was very kind of you! This company has great people.

I think the only reason I did that, was I think I started with someone else's script originally, and they had done things that way. I tried putting it in on_load (incase the timing of the on_tick handler was somehow a problem) and it complained about CRC immediately.

I should have looked more closely, into the differences between on_load and on_init. Thank you again, for taking the time out of your day to fix my stupid mistake.

--Very sincerely, Carl Otto.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by Rseding91 »

distortions864 wrote:... I tried putting it in on_load (incase the timing of the on_tick handler was somehow a problem) and it complained about CRC immediately. ...
Indeed :) It also causes desyncs when people do that in on_load but I'm able to detect when they do that and stop the game before the desync happens.
If you want to get ahold of me I'm almost always on Discord.

User avatar
distortions864
Fast Inserter
Fast Inserter
Posts: 110
Joined: Thu Apr 20, 2017 12:56 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by distortions864 »

Code: Select all

  13.449 Error MainLoop.cpp:943: Exception at tick 5121: Error while running event level::on_tick (ID 0)
...ect/Users/CarlO/17266/temp/currently-playing/control.lua:395: attempt to perform arithmetic on field 'last_s_tick' (a nil value)
  13.449 Error ServerMultiplayerManager.cpp:94: MultiplayerManager failed: "Error while running event level::on_tick (ID 0)
...ect/Users/CarlO/17266/temp/currently-playing/control.lua:395: attempt to perform arithmetic on field 'last_s_tick' (a nil value)"
last_s_tick is set to 0 in on_init

The changes you had me made were working fine, until i put this into a new map.
I think this is why I may have resorted to a tick-handler init.

Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by Nexela »

on_init only ever runs when a mod is added (or in your case scenario is created)

You would need to check if on_configuration_changed is triggered if the scenario control file changes and if so add your new variables to global in that event. If on_configuration changed doesn't run when a scenarios control file checksum changes than this would be a good time to ask for it too :)

If on_configuration_changed doesn't work for scenarios then the next best thing is a quick on tick check

if not global["version_num"] then
global.new_var = new_value
global[version_num] = true
end
... rest of on tick here

User avatar
distortions864
Fast Inserter
Fast Inserter
Posts: 110
Joined: Thu Apr 20, 2017 12:56 am
Contact:

Re: [0.15.19] Desync with softmod (scenario) on connect

Post by distortions864 »

Interesting, ill check when i get home.

Post Reply

Return to “Desyncs with mods”