[0.15.19] Desync with softmod (scenario) on connect
- distortions864
- Fast Inserter
- Posts: 121
- Joined: Thu Apr 20, 2017 12:56 am
- Contact:
[0.15.19] Desync with softmod (scenario) on connect
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!
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!
M45 Science: A Factorio Community since 2017! https://m45sci.xyz/
- distortions864
- Fast Inserter
- Posts: 121
- Joined: Thu Apr 20, 2017 12:56 am
- Contact:
Re: [0.15.19] Desync with softmod (scenario) on connect
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?
See below:
http://i.imgur.com/4qWZKkI.png <--(Click to enlarge)
Is this location object lock data or something else?
M45 Science: A Factorio Community since 2017! https://m45sci.xyz/
Re: [0.15.19] Desync with softmod (scenario) on connect
If you only show Diffs (4th icon in the toolbar) in Beyond Compare then the cause becomes apparent:
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.
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.
- distortions864
- Fast Inserter
- Posts: 121
- Joined: Thu Apr 20, 2017 12:56 am
- Contact:
Re: [0.15.19] Desync with softmod (scenario) on connect
Interesting, i'll take a look at it.
Thanks for the feedback.
Thanks for the feedback.
M45 Science: A Factorio Community since 2017! https://m45sci.xyz/
Re: [0.15.19] Desync with softmod (scenario) on connect
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
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.
- distortions864
- Fast Inserter
- Posts: 121
- Joined: Thu Apr 20, 2017 12:56 am
- Contact:
Re: [0.15.19] Desync with softmod (scenario) on connect
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.
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.
M45 Science: A Factorio Community since 2017! https://m45sci.xyz/
Re: [0.15.19] Desync with softmod (scenario) on connect
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.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. ...
If you want to get ahold of me I'm almost always on Discord.
- distortions864
- Fast Inserter
- Posts: 121
- Joined: Thu Apr 20, 2017 12:56 am
- Contact:
Re: [0.15.19] Desync with softmod (scenario) on connect
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)"
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.
M45 Science: A Factorio Community since 2017! https://m45sci.xyz/
Re: [0.15.19] Desync with softmod (scenario) on connect
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
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
- distortions864
- Fast Inserter
- Posts: 121
- Joined: Thu Apr 20, 2017 12:56 am
- Contact:
Re: [0.15.19] Desync with softmod (scenario) on connect
Interesting, ill check when i get home.
M45 Science: A Factorio Community since 2017! https://m45sci.xyz/