Page 1 of 1
[0.15.19] Desync with softmod (scenario) on connect
Posted: Sat Jun 10, 2017 11:28 am
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!
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Sat Jun 10, 2017 2:46 pm
by distortions864
I did some digging in the report... and it's a bit odd.
See below:
http://i.imgur.com/4qWZKkI.png <--(Click to enlarge)
Is this location object lock data or something else?
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Sat Jun 10, 2017 5:30 pm
by daniel34
If you only show Diffs (4th icon in the toolbar) in Beyond Compare then the cause becomes apparent:
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.
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Sat Jun 10, 2017 6:09 pm
by distortions864
Interesting, i'll take a look at it.
Thanks for the feedback.
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Sat Jun 10, 2017 6:34 pm
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.
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Sat Jun 10, 2017 9:51 pm
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.
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Sat Jun 10, 2017 10:01 pm
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.
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Mon Jun 12, 2017 10:26 am
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.
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Mon Jun 12, 2017 10:33 am
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
Re: [0.15.19] Desync with softmod (scenario) on connect
Posted: Mon Jun 12, 2017 10:39 am
by distortions864
Interesting, ill check when i get home.