Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.
Sign upAbort starting / continuing a game upon any kind of error from loading JSON game data. #18137
Conversation
BevapDin
added some commits
Aug 28, 2016
Coolthulhu
self-assigned this
Aug 29, 2016
Coolthulhu
merged commit 64fcaa7
into
CleverRaven:master
Aug 29, 2016
1 check passed
default
This has been rescheduled for testing as the 'master' branch has been updated.
BevapDin
deleted the
BevapDin:iki
branch
Aug 29, 2016
kevingranade
referenced this pull request
Mar 8, 2017
Closed
one missing json field leads to endless errors #11770
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
BevapDin commentedAug 28, 2016
This kind of relates to #18130. If the game encounters an error while loading the JSON data, it cancels loading the game data (items etc.), but otherwise continues loading / starting the actual game. This leads to a various errors about missing definitions.
The PR changes the logic to abort starting / continuing a game and going back to the main menu.
The "load" functions in class
gamenow throw an exception (or simply propagate the exception throw from within further function calls). Callers catch those exceptions:dump_statsreports them viastd::cerr(as the curses system is not initialized there, see surrounding code) and returns immediately,game::check_mod_data,game::quickloadreports viadebugmsg, technically the program should just exit as the game may be in any invalid state, but the user could try to fix the problem and do another quickload.To test this, add some errors to the JSON files and try to start/load a game. It should print a debug message and put you back into the menu.
This is technically an alternative to #18136, it fixes the "When you try to play the game, it throws what must be hundreds of errors at you, saying it can't find tons and tons of stuff" issue.
But #18136 is not an alternative to this PR. #18136 won't fix the main problem: the program allows you to start a game with faulty JSON data. #18136 allows one to reach the actual game despite redundant JSON values.