Skip to content

Commit

Permalink
Merge pull request #39358 from johnstoecker/missing-tiles-debug-log
Browse files Browse the repository at this point in the history
Missing tiles in debug.log separate from missing with looks_like
  • Loading branch information
kevingranade authored Apr 11, 2020
2 parents 1963ae3 + 605706b commit 0201326
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 25 deletions.
46 changes: 25 additions & 21 deletions src/cata_tiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3496,22 +3496,22 @@ void cata_tiles::do_tile_loading_report()
return;
}

tile_loading_report<ter_t>( ter_t::count(), "Terrain", "" );
tile_loading_report<furn_t>( furn_t::count(), "Furniture", "" );
tile_loading_report<ter_t>( ter_t::count(), C_TERRAIN, "" );
tile_loading_report<furn_t>( furn_t::count(), C_FURNITURE, "" );

std::map<itype_id, const itype *> 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<mtype>::iterator & m ) {
return ( *m ).id.str();
}, "Monsters", "" );
tile_loading_report( vpart_info::all(), "Vehicle Parts", "vp_" );
tile_loading_report<trap>( trap::count(), "Traps", "" );
tile_loading_report<field_type>( field_type::count(), "Field Types", "" );
}, C_MONSTER, "" );
tile_loading_report( vpart_info::all(), C_VEHICLE_PART, "vp_" );
tile_loading_report<trap>( trap::count(), C_TRAP, "" );
tile_loading_report<field_type>( field_type::count(), C_FIELD, "" );

// needed until DebugLog ostream::flush bugfix lands
DebugLog( D_INFO, DC_ALL );
Expand All @@ -3537,54 +3537,58 @@ point cata_tiles::player_to_screen( const point &p ) const
}

template<typename Iter, typename Func>
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;
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 );
if( !tileset_ptr->find_tile_type( prefix + id_string ) ) {
missing++;

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_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 " << label << ": " << missing_list;
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 <typename maptype>
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 <typename base_type>
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<size_t>( 0 ), count,
[]( const size_t i ) {
return int_id<base_type>( i ).id().str();
}, label, prefix );
}, category, prefix );
}

template <typename arraytype>
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<options_manager::id_and_option> cata_tiles::build_renderer_list()
Expand Down
8 changes: 4 additions & 4 deletions src/cata_tiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,19 +480,19 @@ class cata_tiles
static std::vector<options_manager::id_and_option> build_display_list();
protected:
template <typename maptype>
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 <typename arraytype>
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 <typename basetype>
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<typename Iter, typename Func>
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();
Expand Down

0 comments on commit 0201326

Please sign in to comment.