-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent crash when lastworld.json
is corrupted or empty.
#3100
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moderately corrupt JSON
{
"world_name": Very-Empty",
"foo": [1,,2,3]
"character_name": "Maribel Hearn"
}
array in lastworld.json
:
[]
empty lastworld.json
:
corrupt options.json
for comparison:
[adfs
{ "info": "If enabled, when your character dies, the player is given a prompt that gives the option to cancel savefile deletion and other death effects, returning to the main menu without saving instead.", "default": "Default: False", "name": "PROMPT_ON_CHARACTER_DEATH", "value": "true" },
(continues below)
the changes doesn't seem to work, could you have a look?
Dammit, will make draft, can't really do much with a notepad, so will have to wait until I get my computer back. Weird that |
yeah strange. i think cata's JSON parser doesn't handle invalid JSONs very well in general, as seen on corrupt options.json |
According to the debugger, in some cases the game crashes because Other cases were caused by missing check in Lua backtrace code, that should be fixed by #3187 |
Then is there no way to prevent this from crashing? Or just deleting the file and restarting when it would otherwise crash? |
You need to replace that |
Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
So that errors reveal the file path of the offending file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEBUG : Json error: config/lastworld.json:2:23: missing comma
{
"world_name": "Test"
^
"character_name": "Maribel Hearn"
}
FUNCTION : void worldfactory::load_last_world_info()
FILE : /home/scarf/repo/cata/Cataclysm/src/worldfactory.cpp
LINE : 609
VERSION : BN 440e1342128
LGTM
6389933
…bnteam#3100) * Prevent crash when lastworld.json is corrupted or empty. Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Update worldfactory.cpp So that errors reveal the file path of the offending file. --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Summary
SUMMARY: Bugfixes "Prevent crash when
lastworld.json
is corrupted or empty."Purpose of change
Had an issue today where someone's computer didn't end the game appropriately, corrupting
lastworld.json
, this caused a crash that would consistently prevent the game from starting with no warning except crash log messages.Describe the solution
Use try and catch to catch exceptions and report them when they occur loading
lastworld.json
Describe alternatives you've considered
Testing
Need others to test for me, my computer is down. This should be tested via creating
lastworld.json
in the config folder. Either leave it empty or in various states of incomplete/wrong format.Additional context