lookUpWorldName() halts immediately after logging world discovery (main.cpp line 816) #1

Closed
opened 2024-01-29 03:59:36 -05:00 by bonkmaykr · 1 comment
Owner

The bot quits in the middle of lookUpWorldName() and then returns to idling, as soon as it reaches line 817 where it tries to create a new position struct to hold the JSON values in. It's believed this is an internal issue with the bot trying to read the data from the iterator *key.

The bot quits in the middle of lookUpWorldName() and then returns to idling, as soon as it reaches line 817 where it tries to create a new position struct to hold the JSON values in. It's believed this is an internal issue with the bot trying to read the data from the iterator *key.
bonkmaykr added the
bug
roadblock
labels 2024-01-29 04:00:24 -05:00
Author
Owner

Narrowed it down to this line causing the issue:
details.position.x = (*key)["position"][0];
all 3 lines after which set the other axis y and z and rotation are affected.

One thing I can't believe I didn't see before: the contents of the array inside of the JSON are stored as STRINGS and not integers:

"atlantis": {
    "name": "Atlantis",
    "url": "http://files.worlio.com/users/aujourd/atlantis/atlantis.world",
    "room": "atlantis#beach",
    "position": [
      "11544",
      "7828",
      "220",
      "203"
    ],
    "blacklist": false
}

Simply changing the values to integers fixes the bug. Tourbot was attempting to store a string into an integer within markEntry.position.x, there was no error handler in place and the compiler did not catch this as there was no way it could have foreseen this would happen since the input that caused it was outside the program (and the return value from json["key"] can be any type).

This probably does not need further fixing, however, adding error handling to detect when this happens and cast the string to an integer for the administrator's sake, a fairly easy thing to do, should be added to the todo list.

Narrowed it down to this line causing the issue: `details.position.x = (*key)["position"][0];` all 3 lines after which set the other axis y and z and rotation are affected. One thing I can't believe I didn't see before: the contents of the array inside of the JSON are stored as STRINGS and not integers: ``` "atlantis": { "name": "Atlantis", "url": "http://files.worlio.com/users/aujourd/atlantis/atlantis.world", "room": "atlantis#beach", "position": [ "11544", "7828", "220", "203" ], "blacklist": false } ``` Simply changing the values to integers fixes the bug. Tourbot was attempting to store a string into an integer within markEntry.position.x, there was no error handler in place and the compiler did not catch this as there was no way it could have foreseen this would happen since the input that caused it was outside the program (and the return value from json["key"] can be any type). This probably does not need further fixing, however, adding error handling to detect when this happens and cast the string to an integer for the administrator's sake, a fairly easy thing to do, should be added to the todo list.
bonkmaykr referenced this issue from a commit 2024-01-29 05:10:02 -05:00
bonkmaykr referenced this issue from a commit 2024-01-29 05:10:02 -05:00
Sign in to join this conversation.
No description provided.