Page 1 of 1

[Rseding91] [0.16.20] Cannot connect to server: Mod settings mismatch

Posted: Wed Jan 31, 2018 8:36 pm
by Mylon
I'm trying to configure a server with some mods and it won't let me connect.

I created a save file using a scenario (but I forgot to turn on Bobs Inserters during this step)
I uploaded the save file to the server
I tried to connect: got error mods mismatch, bobs inserters on server)
I enabled that mod
I tried to connect: Mod startup settings mismatch.
I clicked yes to sync settings and restarted the game.
I tried to connect: Mod startup settings mismatch.

I do not recall changing any of the mod settings locally and the server should be running with everything on default settings.

I don't know if the Bobs Inserters bit is relevant.

Attached is the save file. The mod pack I'm using is here: https://www.dropbox.com/s/s2x3kaql5v7dt ... 0.zip?dl=0

Re: [0.16.20] Cannot connect to server: Mod settings mismatch

Posted: Wed Jan 31, 2018 10:49 pm
by Rseding91
Thanks for the report. I found the problem but don't currently have a fix I like.

The problem is JSON doesn't support saving numbers in hex format so saving 0.299999999999999 as a string ends up saving 0.3 and then when loaded back into binary format it's 0.3000000000021 and you get different numbers.

Right now there are 2 options proposed:
  • Change the mod-settings.json file to mod-settings.dat and it will write the settings in binary format
  • Update to JSON 5 which theoretically supports hex formats for numbers which means we could save floats correctly

Re: [Rseding91] [0.16.20] Cannot connect to server: Mod settings mismatch

Posted: Thu Feb 01, 2018 3:08 am
by kovarex
That is weird, because we had similar problems when saving numbers in lua state, and as far as I remember, we solved it without using hexes for numbers.

Re: [Rseding91] [0.16.20] Cannot connect to server: Mod settings mismatch

Posted: Thu Feb 01, 2018 1:58 pm
by posila
kovarex wrote:That is weird, because we had similar problems when saving numbers in lua state, and as far as I remember, we solved it without using hexes for numbers.
In the end, we did solve it by serializing numbers in lua state in hex format

Re: [Rseding91] [0.16.20] Cannot connect to server: Mod settings mismatch

Posted: Thu Feb 01, 2018 3:24 pm
by gheift
If you use code like this, there shouldn't be any rounding errors:

Code: Select all

#include <float.h>

fprintf(file, "%.*lg", DBL_DIG, v);
See also man float.h, search for DBL_DIG.

Re: [Rseding91] [0.16.20] Cannot connect to server: Mod settings mismatch

Posted: Thu Feb 01, 2018 11:28 pm
by Rseding91
Ok, I found the underlying problem and it should be fixed for the next version of 0.16.

At least testing with the files you provided works correctly now.