Skip to content
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

Proper unvisited member report fix #35079

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include <utility>

#include "cata_utility.h"
#include "options.h"

extern bool test_mode;

// JSON parsing and serialization tools for Cataclysm-DDA.
// For documentation, see the included header, json.h.
Expand Down Expand Up @@ -100,17 +101,15 @@ JsonObject::JsonObject( JsonIn &j )
void JsonObject::finish()
{
#ifndef CATA_IN_TOOL
if( report_unvisited_members && !reported_unvisited_members && !std::uncaught_exception() &&
get_option<bool>( "JSON_REPORT_UNVISITED_MEMBERS" ) ) {
if( test_mode && report_unvisited_members && !reported_unvisited_members &&
!std::uncaught_exception() ) {
reported_unvisited_members = true;
for( const std::pair<std::string, int> &p : positions ) {
const std::string &name = p.first;
if( !visited_members.count( name ) && !string_starts_with( name, "//" ) &&
name != "blueprint" ) {
dbg( D_ERROR ) << "Failed to visit member '" << name << "' in JsonObject at "
<< ( get_option<bool>( "JSON_POSITION_OF_UNVISITED_MEMBERS" ) ?
jsin->line_number( start ) : "line 0:0,0" )
<< ":\n" << str() << std::endl;
<< jsin->line_number( start ) << ":\n" << str() << std::endl;
}
}
}
Expand Down
14 changes: 0 additions & 14 deletions src/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1887,20 +1887,6 @@ void options_manager::add_options_debug()
translate_marker( "If true, file path names are going to be transcoded from system encoding to UTF-8 when reading and will be transcoded back when writing. Mainly for CJK Windows users." ),
true
);

add( "JSON_REPORT_UNVISITED_MEMBERS", "debug",
translate_marker( "Report unvisited json members" ),
translate_marker( "If true, unvisited json members will be reported to debug.log when loading json files." ),
false
);
add( "JSON_POSITION_OF_UNVISITED_MEMBERS", "debug",
translate_marker( "Show position of unvisited json members" ),
translate_marker( "If true, position of unvisited json members will be reported to debug.log when loading json files. Hinders performance A LOT!" ),
false
);

get_option( "JSON_POSITION_OF_UNVISITED_MEMBERS" ).setPrerequisite( "JSON_REPORT_UNVISITED_MEMBERS" );

}

void options_manager::add_options_world_default()
Expand Down