[quote=“Mattaclysm, post:13, topic:5568”]You’re right, again, Sean. The game continues after about 9 items. I really dislike the try/catch code for the JSON parsing, but I don’t know enough about JSON or C++ to propose a better option. Thanks for all the suggestions, everyone. You’ve helped me get debugging up and running!
Perhaps something like istream::peek exists for JSON parsing to check if there’s more than one skill required without triggering an exception?
EDIT: I took another look through the code, and it looks like we already have JsonIn::peek(). I’m hoping a better solution can be found to remedy the try/catch problem in crafting.cpp.[/quote]There’s a “has_array()” you can check for, substituting the try-catch for
if (!jsarr.empty()) {
// could be a single requirement, or multiple
if(!jsarr.has_array(0)){ // test if not array
requires_skills[jsarr.get_string(0)] = jsarr.get_int(1);
} else {
//it's not NOT an array, so jsarr is an array of arrays
while (jsarr.has_more()) {
JsonArray ja = jsarr.next_array();
requires_skills[ja.get_string(0)] = ja.get_int(1);
}
}
}