Avoid loading terrain minimap images when not specified by WML
Otherwise we build a bogus "terrain/.png" file path and produce spurious `error display: could not open image 'terrain/.png'` messages in stderr. Although this is primarily an issue found with certain special overlay terrains such as ^Xo (Impassable Overlay), this fix covers base terrains as well.
This commit is contained in:
parent
21391f9039
commit
62e84fa240
2 changed files with 16 additions and 10 deletions
|
@ -137,14 +137,14 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
need_highlighting = true;
|
||||
}
|
||||
|
||||
if(i == cache->end()) {
|
||||
if(i == cache->end() && !terrain_info.minimap_image().empty()) {
|
||||
std::string base_file =
|
||||
"terrain/" + terrain_info.minimap_image() + ".png";
|
||||
surface tile = get_image(base_file,image::HEXED);
|
||||
|
||||
//Compose images of base and overlay if necessary
|
||||
// NOTE we also skip overlay when base is missing (to avoid hiding the error)
|
||||
if(tile != NULL && tdata.get_terrain_info(terrain).is_combined()) {
|
||||
if(tile != NULL && tdata.get_terrain_info(terrain).is_combined() && !terrain_info.minimap_image_overlay().empty()) {
|
||||
std::string overlay_file =
|
||||
"terrain/" + terrain_info.minimap_image_overlay() + ".png";
|
||||
surface overlay = get_image(overlay_file,image::HEXED);
|
||||
|
|
|
@ -345,19 +345,25 @@ void terrain_builder::rebuild_terrain(const map_location &loc)
|
|||
btile.images_background.clear();
|
||||
const std::string filename =
|
||||
map().get_terrain_info(loc).minimap_image();
|
||||
animated<image::locator> img_loc;
|
||||
img_loc.add_frame(100,image::locator("terrain/" + filename + ".png"));
|
||||
img_loc.start_animation(0, true);
|
||||
btile.images_background.push_back(img_loc);
|
||||
|
||||
if(!filename.empty()) {
|
||||
animated<image::locator> img_loc;
|
||||
img_loc.add_frame(100,image::locator("terrain/" + filename + ".png"));
|
||||
img_loc.start_animation(0, true);
|
||||
btile.images_background.push_back(img_loc);
|
||||
}
|
||||
|
||||
//Combine base and overlay image if necessary
|
||||
if(map().get_terrain_info(loc).is_combined()) {
|
||||
const std::string filename_ovl =
|
||||
map().get_terrain_info(loc).minimap_image_overlay();
|
||||
animated<image::locator> img_loc_ovl;
|
||||
img_loc_ovl.add_frame(100,image::locator("terrain/" + filename_ovl + ".png"));
|
||||
img_loc_ovl.start_animation(0, true);
|
||||
btile.images_background.push_back(img_loc_ovl);
|
||||
|
||||
if(!filename_ovl.empty()) {
|
||||
animated<image::locator> img_loc_ovl;
|
||||
img_loc_ovl.add_frame(100,image::locator("terrain/" + filename_ovl + ".png"));
|
||||
img_loc_ovl.start_animation(0, true);
|
||||
btile.images_background.push_back(img_loc_ovl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue