diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index fa4cf3238196e..9e9e8c403544d 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -332,7 +332,7 @@ tile_type &tileset::create_tile_type( const std::string &id, tile_type &&new_til } void cata_tiles::load_tileset( const std::string &tileset_id, const bool precheck, - const bool force, const bool pump_events ) + const bool force, const bool pump_events, const bool terrain ) { if( tileset_ptr && tileset_ptr->get_tileset_id() == tileset_id && !force ) { return; @@ -341,7 +341,7 @@ void cata_tiles::load_tileset( const std::string &tileset_id, const bool prechec // reset the overlay ordering from the previous loaded tileset tileset_mutation_overlay_ordering.clear(); - tileset_ptr = cache.load_tileset( tileset_id, renderer, precheck, force, pump_events ); + tileset_ptr = cache.load_tileset( tileset_id, renderer, precheck, force, pump_events, terrain ); set_draw_scale( 16 ); @@ -625,7 +625,7 @@ void cata_tiles::set_draw_scale( int scale ) } void tileset_cache::loader::load( const std::string &tileset_id, const bool precheck, - const bool pump_events ) + const bool pump_events, const bool terrain ) { std::string json_conf; std::string layering; @@ -765,8 +765,9 @@ void tileset_cache::loader::load( const std::string &tileset_id, const bool prec } } - if( !ts.find_tile_type( "unknown" ) ) { - dbg( D_ERROR ) << "The tileset you're using has no 'unknown' tile defined!"; + if( !ts.find_tile_type( terrain ? "unknown_terrain" : "unknown" ) ) { + dbg( D_ERROR ) << "The tileset you're using has no '" << ( terrain ? "unknown_terrain" : "unknown" ) + << "' tile defined!"; } ensure_default_item_highlight(); @@ -4411,14 +4412,15 @@ bool cata_tiles::draw_item_highlight( const tripoint &pos, int &height_3d ) } std::shared_ptr tileset_cache::load_tileset( const std::string &tileset_id, - const SDL_Renderer_Ptr &renderer, const bool precheck, const bool force, const bool pump_events ) + const SDL_Renderer_Ptr &renderer, const bool precheck, const bool force, const bool pump_events, + const bool terrain ) { const auto get_or_create_tileset = [&]() { const auto it = tilesets_.find( tileset_id ); if( it == tilesets_.end() || it->second.expired() ) { std::shared_ptr new_ts = std::make_shared(); loader loader( *new_ts, renderer ); - loader.load( tileset_id, precheck, pump_events ); + loader.load( tileset_id, precheck, pump_events, terrain ); tilesets_.emplace( tileset_id, new_ts ); return new_ts; } @@ -4429,7 +4431,7 @@ std::shared_ptr tileset_cache::load_tileset( const std::string &t if( force || ( ts->get_tileset_id().empty() && !precheck ) ) { loader loader( *ts, renderer ); - loader.load( tileset_id, precheck, pump_events ); + loader.load( tileset_id, precheck, pump_events, terrain ); } return ts; } diff --git a/src/cata_tiles.h b/src/cata_tiles.h index 01af515574368..d875a4dc1de97 100644 --- a/src/cata_tiles.h +++ b/src/cata_tiles.h @@ -280,7 +280,7 @@ class tileset_cache public: std::shared_ptr load_tileset( const std::string &tileset_id, const SDL_Renderer_Ptr &renderer, bool precheck, - bool force, bool pump_events ); + bool force, bool pump_events, bool terrain ); private: class loader; std::unordered_map> tilesets_; @@ -379,8 +379,10 @@ class tileset_cache::loader * @param pump_events Handle window events and refresh the screen when necessary. * Please ensure that the tileset is not accessed when this method is * executing if you set it to true. + * @param terrain If true, this will be an overmap/terrain tileset */ - void load( const std::string &tileset_id, bool precheck, bool pump_events = false ); + void load( const std::string &tileset_id, bool precheck, bool pump_events = false, + bool terrain = false ); }; enum class text_alignment : int { @@ -682,10 +684,11 @@ class cata_tiles * @param pump_events Handle window events and refresh the screen when necessary. * Please ensure that the tileset is not accessed when this method is * executing if you set it to true. + * @param terrain If true, this will be an overmap/terrain tileset * @throw std::exception On any error. */ void load_tileset( const std::string &tileset_id, bool precheck = false, - bool force = false, bool pump_events = false ); + bool force = false, bool pump_events = false, bool terrain = false ); /** * Reinitializes the current tileset, like @ref init, but using the original screen information. * @throw std::exception On any error. diff --git a/src/game.cpp b/src/game.cpp index 216520999e00c..0e47000335cf2 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -727,7 +727,7 @@ void game::reload_tileset() closetilecontext->reinit(); closetilecontext->load_tileset( get_option( "TILES" ), /*precheck=*/false, /*force=*/true, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); closetilecontext->do_tile_loading_report(); tilecontext = closetilecontext; @@ -741,7 +741,7 @@ void game::reload_tileset() } fartilecontext->load_tileset( get_option( "DISTANT_TILES" ), /*precheck=*/false, /*force=*/true, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); fartilecontext->do_tile_loading_report(); } catch( const std::exception &err ) { popup( _( "Loading the zoomed out tileset failed: %s" ), err.what() ); @@ -751,7 +751,7 @@ void game::reload_tileset() overmap_tilecontext->reinit(); overmap_tilecontext->load_tileset( get_option( "OVERMAP_TILES" ), /*precheck=*/false, /*force=*/true, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/true ); overmap_tilecontext->do_tile_loading_report(); } catch( const std::exception &err ) { popup( _( "Loading the overmap tileset failed: %s" ), err.what() ); diff --git a/src/options.cpp b/src/options.cpp index 12cf9f63d2a02..e5823e6596a64 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -3273,7 +3273,7 @@ static void refresh_tiles( bool used_tiles_changed, bool pixel_minimap_height_ch closetilecontext->reinit(); closetilecontext->load_tileset( get_option( "TILES" ), /*precheck=*/false, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); //game_ui::init_ui is called when zoom is changed g->reset_zoom(); g->mark_main_ui_adaptor_resize(); @@ -3290,7 +3290,7 @@ static void refresh_tiles( bool used_tiles_changed, bool pixel_minimap_height_ch } fartilecontext->load_tileset( get_option( "DISTANT_TILES" ), /*precheck=*/false, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); //game_ui::init_ui is called when zoom is changed g->reset_zoom(); g->mark_main_ui_adaptor_resize(); @@ -3305,7 +3305,7 @@ static void refresh_tiles( bool used_tiles_changed, bool pixel_minimap_height_ch overmap_tilecontext->reinit(); overmap_tilecontext->load_tileset( get_option( "OVERMAP_TILES" ), /*precheck=*/false, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/true ); //game_ui::init_ui is called when zoom is changed g->reset_zoom(); g->mark_main_ui_adaptor_resize(); diff --git a/src/sdltiles.cpp b/src/sdltiles.cpp index cdb61263f1572..476e7be2d513f 100644 --- a/src/sdltiles.cpp +++ b/src/sdltiles.cpp @@ -3680,7 +3680,7 @@ void catacurses::init_interface() ui_adaptor dummy( ui_adaptor::disable_uis_below{} ); fartilecontext->load_tileset( get_option( "DISTANT_TILES" ), /*precheck=*/true, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); } catch( const std::exception &err ) { dbg( D_ERROR ) << "failed to check for tileset: " << err.what(); // use_tiles is the cached value of the USE_TILES option. @@ -3695,7 +3695,7 @@ void catacurses::init_interface() ui_adaptor dummy( ui_adaptor::disable_uis_below{} ); closetilecontext->load_tileset( get_option( "TILES" ), /*precheck=*/true, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); tilecontext = closetilecontext; } catch( const std::exception &err ) { dbg( D_ERROR ) << "failed to check for tileset: " << err.what(); @@ -3710,7 +3710,7 @@ void catacurses::init_interface() ui_adaptor dummy( ui_adaptor::disable_uis_below{} ); overmap_tilecontext->load_tileset( get_option( "OVERMAP_TILES" ), /*precheck=*/true, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/true ); } catch( const std::exception &err ) { dbg( D_ERROR ) << "failed to check for overmap tileset: " << err.what(); // use_tiles is the cached value of the USE_TILES option. @@ -3755,11 +3755,11 @@ void load_tileset() } closetilecontext->load_tileset( get_option( "TILES" ), /*precheck=*/false, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); if( use_far_tiles ) { fartilecontext->load_tileset( get_option( "DISTANT_TILES" ), /*precheck=*/false, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/false ); } tilecontext = closetilecontext; tilecontext->do_tile_loading_report(); @@ -3767,7 +3767,7 @@ void load_tileset() if( overmap_tilecontext ) { overmap_tilecontext->load_tileset( get_option( "OVERMAP_TILES" ), /*precheck=*/false, /*force=*/false, - /*pump_events=*/true ); + /*pump_events=*/true, /*terrain=*/true ); overmap_tilecontext->do_tile_loading_report(); } }