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:
Ignacio R. Morelle 2015-10-19 21:23:19 -03:00
parent 4534767b37
commit ec1cb54aa3
3 changed files with 19 additions and 10 deletions

View file

@ -26,6 +26,9 @@ Version 1.12.4+dev:
* Hanging, stone chasm, and plank bridges are now displayed in-game simply
as "Bridge", retaining their descriptive names in the editor as per
convention.
* Fixed spurious "could not open image 'terrain/.png'" error messages caused
by terrains without a minimap image (symbol_image) such as those from the
Special category in the editor (Impassable Overlay, etc.).
* User interface:
* Force uniform font rendering settings across X11 and Apple OS X, avoiding
color glitches resulting from incorrect applications of subpixel hinting

View file

@ -276,19 +276,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);
}
}
}
}

View file

@ -133,14 +133,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 && map.get_terrain_info(terrain).is_combined()) {
if(tile != NULL && map.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);