From 248d6e99434eec470e0165714c813d72f84b4726 Mon Sep 17 00:00:00 2001 From: John Stoecker Date: Wed, 8 Apr 2020 00:24:13 -0700 Subject: [PATCH 1/4] Missing tiles in debug.log no longer ignores looks_like --- src/cata_tiles.cpp | 35 +++++++++++++++++++---------------- src/cata_tiles.h | 8 ++++---- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 296f0d90634c5..10e93f9ce73f1 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -3491,22 +3491,22 @@ void cata_tiles::do_tile_loading_report() return; } - tile_loading_report( ter_t::count(), "Terrain", "" ); - tile_loading_report( furn_t::count(), "Furniture", "" ); + tile_loading_report( ter_t::count(), C_TERRAIN, "" ); + tile_loading_report( furn_t::count(), C_FURNITURE, "" ); std::map items; for( const itype *e : item_controller->all() ) { items.emplace( e->get_id(), e ); } - tile_loading_report( items, "Items", "" ); + tile_loading_report( items, C_ITEM, "" ); auto mtypes = MonsterGenerator::generator().get_all_mtypes(); lr_generic( mtypes.begin(), mtypes.end(), []( const std::vector::iterator & m ) { return ( *m ).id.str(); - }, "Monsters", "" ); - tile_loading_report( vpart_info::all(), "Vehicle Parts", "vp_" ); - tile_loading_report( trap::count(), "Traps", "" ); - tile_loading_report( field_type::count(), "Field Types", "" ); + }, C_MONSTER, "" ); + tile_loading_report( vpart_info::all(), C_VEHICLE_PART, "vp_" ); + tile_loading_report( trap::count(), C_TRAP, "" ); + tile_loading_report( field_type::count(), C_FIELD, "" ); // needed until DebugLog ostream::flush bugfix lands DebugLog( D_INFO, DC_ALL ); @@ -3532,7 +3532,7 @@ point cata_tiles::player_to_screen( const point &p ) const } template -void cata_tiles::lr_generic( Iter begin, Iter end, Func id_func, const std::string &label, +void cata_tiles::lr_generic( Iter begin, Iter end, Func id_func, TILE_CATEGORY category, const std::string &prefix ) { int missing = 0; @@ -3540,46 +3540,49 @@ void cata_tiles::lr_generic( Iter begin, Iter end, Func id_func, const std::stri std::string missing_list; for( ; begin != end; ++begin ) { const std::string id_string = id_func( begin ); - if( !tileset_ptr->find_tile_type( prefix + id_string ) ) { + + std::string mutable_id_string = id_string; + + if( !tileset_ptr->find_tile_type( prefix + id_string ) && !find_tile_looks_like( mutable_id_string, category) ) { missing++; missing_list.append( id_string + " " ); } else { present++; } } - DebugLog( D_INFO, DC_ALL ) << "Missing " << label << ": " << missing_list; + DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << ": " << missing_list; } template -void cata_tiles::tile_loading_report( const maptype &tiletypemap, const std::string &label, +void cata_tiles::tile_loading_report( const maptype &tiletypemap, TILE_CATEGORY category, const std::string &prefix ) { lr_generic( tiletypemap.begin(), tiletypemap.end(), []( const decltype( tiletypemap.begin() ) & v ) { // c_str works for std::string and for string_id! return v->first.c_str(); - }, label, prefix ); + }, category, prefix ); } template -void cata_tiles::tile_loading_report( const size_t count, const std::string &label, +void cata_tiles::tile_loading_report( const size_t count, TILE_CATEGORY category, const std::string &prefix ) { lr_generic( static_cast( 0 ), count, []( const size_t i ) { return int_id( i ).id().str(); - }, label, prefix ); + }, category, prefix ); } template void cata_tiles::tile_loading_report( const arraytype &array, int array_length, - const std::string &label, const std::string &prefix ) + TILE_CATEGORY category, const std::string &prefix ) { const auto begin = &( array[0] ); lr_generic( begin, begin + array_length, []( decltype( begin ) const v ) { return v->id; - }, label, prefix ); + }, category, prefix ); } std::vector cata_tiles::build_renderer_list() diff --git a/src/cata_tiles.h b/src/cata_tiles.h index a71e5c559fcb9..06fa102501f16 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -479,19 +479,19 @@ class cata_tiles static std::vector build_display_list(); protected: template - void tile_loading_report( const maptype &tiletypemap, const std::string &label, + void tile_loading_report( const maptype &tiletypemap, TILE_CATEGORY category, const std::string &prefix = "" ); template - void tile_loading_report( const arraytype &array, int array_length, const std::string &label, + void tile_loading_report( const arraytype &array, int array_length, TILE_CATEGORY category, const std::string &prefix = "" ); template - void tile_loading_report( size_t count, const std::string &label, const std::string &prefix ); + void tile_loading_report( size_t count, TILE_CATEGORY category, const std::string &prefix ); /** * Generic tile_loading_report, begin and end are iterators, id_func translates the iterator * to an id string (result of id_func must be convertible to string). */ template - void lr_generic( Iter begin, Iter end, Func id_func, const std::string &label, + void lr_generic( Iter begin, Iter end, Func id_func, TILE_CATEGORY category, const std::string &prefix ); /** Lighting */ void init_light(); From f64492df8e67127f5b95d775cdfd84ab990eeab0 Mon Sep 17 00:00:00 2001 From: John Stoecker Date: Wed, 8 Apr 2020 08:30:21 -0700 Subject: [PATCH 2/4] update to show missing looks_like, remove unused counts --- src/cata_tiles.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 10e93f9ce73f1..7e96b4042a7ab 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -3535,22 +3535,21 @@ template void cata_tiles::lr_generic( Iter begin, Iter end, Func id_func, TILE_CATEGORY category, const std::string &prefix ) { - int missing = 0; - int present = 0; std::string missing_list; + std::string missing_with_looks_like_list; for( ; begin != end; ++begin ) { const std::string id_string = id_func( begin ); std::string mutable_id_string = id_string; if( !tileset_ptr->find_tile_type( prefix + id_string ) && !find_tile_looks_like( mutable_id_string, category) ) { - missing++; missing_list.append( id_string + " " ); - } else { - present++; + } else if( !tileset_ptr->find_tile_type( prefix + id_string ) ) { + missing_with_looks_like_list.append( id_string + " " ); } } DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << ": " << missing_list; + DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << " (but looks_like tile exists): " << missing_with_looks_like_list; } template From fff93b04b24c4db5144c7caad68bfcde415f59d7 Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Fri, 10 Apr 2020 01:44:10 +0000 Subject: [PATCH 3/4] Astyling --- src/cata_tiles.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 7e96b4042a7ab..3b684865ead25 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -3542,14 +3542,16 @@ void cata_tiles::lr_generic( Iter begin, Iter end, Func id_func, TILE_CATEGORY c std::string mutable_id_string = id_string; - if( !tileset_ptr->find_tile_type( prefix + id_string ) && !find_tile_looks_like( mutable_id_string, category) ) { + if( !tileset_ptr->find_tile_type( prefix + id_string ) && + !find_tile_looks_like( mutable_id_string, category) ) { missing_list.append( id_string + " " ); } else if( !tileset_ptr->find_tile_type( prefix + id_string ) ) { missing_with_looks_like_list.append( id_string + " " ); } } DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << ": " << missing_list; - DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << " (but looks_like tile exists): " << missing_with_looks_like_list; + DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << + " (but looks_like tile exists): " << missing_with_looks_like_list; } template From 605706be625586eb19d54356d194c33e8bbd9aca Mon Sep 17 00:00:00 2001 From: Kevin Granade Date: Sat, 11 Apr 2020 01:09:12 +0000 Subject: [PATCH 4/4] Apply suggestions from code review --- src/cata_tiles.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 3b684865ead25..5a8e588b11dac 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -3543,7 +3543,7 @@ void cata_tiles::lr_generic( Iter begin, Iter end, Func id_func, TILE_CATEGORY c std::string mutable_id_string = id_string; if( !tileset_ptr->find_tile_type( prefix + id_string ) && - !find_tile_looks_like( mutable_id_string, category) ) { + !find_tile_looks_like( mutable_id_string, category ) ) { missing_list.append( id_string + " " ); } else if( !tileset_ptr->find_tile_type( prefix + id_string ) ) { missing_with_looks_like_list.append( id_string + " " ); @@ -3551,7 +3551,7 @@ void cata_tiles::lr_generic( Iter begin, Iter end, Func id_func, TILE_CATEGORY c } DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << ": " << missing_list; DebugLog( D_INFO, DC_ALL ) << "Missing " << TILE_CATEGORY_IDS[category] << - " (but looks_like tile exists): " << missing_with_looks_like_list; + " (but looks_like tile exists): " << missing_with_looks_like_list; } template