I was helping to make some server side scripts for explosive gaming when I encountered a lot of desyncs around the use of a certain custom command, this lead me to try and find the cause and after much testing I cam to it being the use of tostring and player.print or game.print
To make sure that it was not a scripting problem I opened a non modded multyplayer and got a friend to join, the command of /c game.print(tostring({})) and /c game.print(tostring(game.player)) both caused my friend to desync.
To test that it was not the use of /c causing the desync I made a simple script to run on a dedicated headless server (see control.lua) every 30 seconds it will run game.print(tostring({})) and every 30 seconds with an offset of 15 seconds it will run tostring({}) I created this map using a scenario but it is reproducible without with use of /c.
And as I thought I desynced once the game.print(tostring({})) was ran by the script (see desync report)
I hope that you can find what is causing this desync as it was not like this in previous versions, I'll be bale to provide more context or files if they are needed. Thank you in advanced.
[15.34] print and tostring desync
- Cooldude2606
- Long Handed Inserter
- Posts: 87
- Joined: Sat Sep 16, 2017 9:04 pm
- Contact:
[15.34] print and tostring desync
- Attachments
-
- factorio-current.log
- Headless server log if needed (server owner is badgamernl)
- (23.37 KiB) Downloaded 54 times
-
- control.lua
- Small script added to headless server.
- (450 Bytes) Downloaded 56 times
Re: [15.34] print and tostring desync
You printed the memory address of the table, so just don't do it,Cooldude2606 wrote:I was helping to make some server side scripts for explosive gaming when I encountered a lot of desyncs around the use of a certain custom command, this lead me to try and find the cause and after much testing I cam to it being the use of tostring and player.print or game.print
To make sure that it was not a scripting problem I opened a non modded multyplayer and got a friend to join, the command of /c game.print(tostring({})) and /c game.print(tostring(game.player)) both caused my friend to desync.
To test that it was not the use of /c causing the desync I made a simple script to run on a dedicated headless server (see control.lua) every 30 seconds it will run game.print(tostring({})) and every 30 seconds with an offset of 15 seconds it will run tostring({}) I created this map using a scenario but it is reproducible without with use of /c.
And as I thought I desynced once the game.print(tostring({})) was ran by the script (see desync report)
I hope that you can find what is causing this desync as it was not like this in previous versions, I'll be bale to provide more context or files if they are needed. Thank you in advanced.
Its been like this for every version of the game
- Cooldude2606
- Long Handed Inserter
- Posts: 87
- Joined: Sat Sep 16, 2017 9:04 pm
- Contact:
Re: [15.34] print and tostring desync
Thank you for the fast reply, i just find it strange how i have not found this out yet but also that it is able to write to file with /c game.write_file('temp.log',tostring({})) and not cause a desync but does when printing.
And for context i used a function to return a table as a string but some of the tables had lua:player inside of them which was caussing the desyncs, i will make sure to use player names or indexes from now on.
Thanks again for the fast reply.
And for context i used a function to return a table as a string but some of the tables had lua:player inside of them which was caussing the desyncs, i will make sure to use player names or indexes from now on.
Thanks again for the fast reply.
Re: [15.34] print and tostring desync
In a nutshell write_file is writing to a file and doesn't care what you write since the game doesn't see it afterword, However print is something everyone sees. so A sees XXXX and B sees YYYYY and since they are not the same things go boom