SAMPSON icon indicating copy to clipboard operation
SAMPSON copied to clipboard

Node types are interpreted differently on each OS

Open Southclaws opened this issue 9 years ago • 2 comments

I just upgrade to this since DJson (despite having write capability) was fucking SQLite up and decided to just wait for writing to be added to this (or add it myself). But it seems to be failing to read a lot of the settings on the linux server, I found this was because my type checks were returning odd values:

Both these tests loaded the same settings.json file, it has Unix line endings on both the linux and windows machine (exact same file).

Windows server output: everything loads fine

Loading Settings...
[07/04/2015 10:58:13] [JSON] type of 'server/motd' is 1
[07/04/2015 10:58:13] server/motd: Current bug with vehicles on restarts, always exit a vehicle before a restart!
[07/04/2015 10:58:13] [JSON] type of 'server/website' is 1
[07/04/2015 10:58:13] server/website: forum.scavengesurvive.com
[07/04/2015 10:58:13] [JSON] type of 'server/rules' is 4
[07/04/2015 10:58:13] server/rules[0]: 1. Only English in global chat. Please use the radio (/chatinfo) for other languages.
[07/04/2015 10:58:13] server/rules[1]: 2. No global chat use if local or radio is available. (/chatinfo) You will be muted for spam.
[07/04/2015 10:58:13] server/rules[2]: 3. No hacking, cheating or client modifications that give you advantages.
[07/04/2015 10:58:13] server/rules[3]: 4. No exploiting of map bugs such as hiding/building bases inside models.
[07/04/2015 10:58:13] server/rules[4]: 5. No exploiting server bugs, report them using the /bug command.
[07/04/2015 10:58:13] server/rules[5]: 6. No arguments, flaming or discrimination. You will be muted!
[07/04/2015 10:58:13] server/rules[6]: 7. You may insult a player's skills in the game, but don't make things personal.
[07/04/2015 10:58:13] server/rules[7]: 8. Report all hackers, playing with/alongside them will be punished.
[07/04/2015 10:58:13] server/rules[8]: 9. One account per person, break this rule and you and your base will get deleted.
[07/04/2015 10:58:13] [JSON] type of 'server/staff' is 4
[07/04/2015 10:58:13] server/staff[0]: Southclaw
[07/04/2015 10:58:13] server/staff[1]: Atomsk
[07/04/2015 10:58:13] server/staff[2]: VIRUXE
[07/04/2015 10:58:13] [JSON] type of 'server/max-uptime' is 2
[07/04/2015 10:58:13] server/max-uptime: 18000

And this is the linux log of the same loading sequence:

Loading Settings...
[07/04/2015 10:33:54] [JSON] type of 'server/motd' is 1
[07/04/2015 10:33:54] server/motd: Experimental testing build is currently in use. Last backup was 2015/04/04. Always exit a vehicle before a restart!
[07/04/2015 10:33:54] [JSON] type of 'server/website' is 1
[07/04/2015 10:33:54] server/website: forum.scavengesurvive.com
[07/04/2015 10:33:54] [JSON] type of 'server/rules' is 0
[07/04/2015 10:33:54] WARNING: JSON writing currently not supported by KingHual's plugin! Cannot auto-write default values.
[07/04/2015 10:33:54] [JSON] type of 'server/staff' is 4
[07/04/2015 10:33:54] server/staff[0]: Southclaw
[07/04/2015 10:33:54] server/staff[1]: Atomsk
[07/04/2015 10:33:54] server/staff[2]: VIRUXE
[07/04/2015 10:33:54] [JSON] type of 'server/max-uptime' is 2
[07/04/2015 10:33:54] server/max-uptime: 18000

It interpreted the node type of 'server/rules' as 0 which resulted in that message getting printed whereas I expected it to return 4 for an array type. This happens all over the load sequence with various settings and no visible pattern to it, the nodes it affects are ints, floats, strings, arrays, etc.

Here's the extract from that file:

{
  "server":{
    "file-check":0,
    "global-debug-level":0,
    "loot-spawn-multiplier":1.0,
    "max-uptime":18000,
    "motd":"Current bug with vehicles on restarts, always exit a vehicle before a restart!",
    "rules":[
      "1. Only English in global chat. Please use the radio (/chatinfo) for other languages.",
      "2. No global chat use if local or radio is available. (/chatinfo) You will be muted for spam.",
      "3. No hacking, cheating or client modifications that give you advantages.",
      "4. No exploiting of map bugs such as hiding/building bases inside models.",
      "5. No exploiting server bugs, report them using the /bug command.",
      "6. No arguments, flaming or discrimination. You will be muted!",
      "7. You may insult a player's skills in the game, but don't make things personal.",
      "8. Report all hackers, playing with/alongside them will be punished.",
      "9. One account per person, break this rule and you and your base will get deleted."
    ],
    "staff":[
      "Southclaw",
      "Atomsk",
      "VIRUXE"
    ],
    "website":"forum.scavengesurvive.com",
    "whitelist":0,
    "whitelist-auto-toggle":0
  },
...etc

And the loading functions are located here except the latest version uses if(json_get_type(json, path) != JSON_TYPE) instead of if(!json_get_node(json, path)) which also didn't work on these particular nodes. (ignore the fact that I try to print a multidimensional on line 163, I thought that might have been the cause at first but then realised the error pops up just before any arrays are read anyway).

I would switch back to DJson but for some reason it just fucks SQLitei up completely so for now I just have to hardcode the settings until this is fixed (I'd try to help but am in no way a C++ expert!)

Southclaws avatar Apr 07 '15 10:04 Southclaws

Did you download the release builds or did you build the plugin from source?

Hual avatar Apr 07 '15 22:04 Hual

I downloaded the release builds, the server machine is Debian 7.

Southclaws avatar Apr 08 '15 09:04 Southclaws