Better separate fog/shroud generation from terrain images

This commit is contained in:
Ali El Gariani 2010-07-11 04:28:11 +00:00
parent 4af4a8c46c
commit baae56f633
2 changed files with 18 additions and 28 deletions

View file

@ -594,9 +594,9 @@ static const std::string& get_direction(size_t n)
return dirs[n >= sizeof(dirs)/sizeof(*dirs) ? 0 : n];
}
std::vector<std::string> display::get_fog_shroud_graphics(const map_location& loc)
std::vector<surface> display::get_fog_shroud_images(const map_location& loc, image::TYPE image_type)
{
std::vector<std::string> res;
std::vector<std::string> names;
map_location adjacent[6];
get_adjacent_tiles(loc,adjacent);
@ -617,7 +617,6 @@ std::vector<std::string> display::get_fog_shroud_graphics(const map_location& lo
}
}
for(int v = FOG; v != CLEAR; ++v) {
// Find somewhere that doesn't have overlap to use as a starting point
int start;
@ -654,7 +653,7 @@ std::vector<std::string> display::get_fog_shroud_graphics(const map_location& lo
}
if(!name.empty()) {
res.push_back(name + ".png");
names.push_back(name + ".png");
}
} else {
i = (i+1)%6;
@ -662,6 +661,15 @@ std::vector<std::string> display::get_fog_shroud_graphics(const map_location& lo
}
}
// now get the surfaces
std::vector<surface> res;
foreach(std::string& name, names) {
const surface surf(image::get_image(name, image_type));
if (surf)
res.push_back(surf);
}
return res;
}
@ -672,24 +680,6 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
{
std::vector<surface> res;
if(terrain_type == ADJACENT_FOGSHROUD) {
const std::vector<std::string> fog_shroud = get_fog_shroud_graphics(loc);
if(!fog_shroud.empty()) {
for(std::vector<std::string>::const_iterator it = fog_shroud.begin(); it != fog_shroud.end(); ++it) {
image::locator image(*it);
const surface surface(image::get_image(image, image_type));
if (!surface.null()) {
res.push_back(surface);
}
}
}
return res;
}
terrain_builder::ADJACENT_TERRAIN_TYPE builder_terrain_type =
(terrain_type == ADJACENT_FOREGROUND ?
terrain_builder::ADJACENT_FOREGROUND : terrain_builder::ADJACENT_BACKGROUND);
@ -713,11 +703,11 @@ std::vector<surface> display::get_terrain_images(const map_location &loc,
// not the location, since the transitions are rendered
// over the offmap-terrain and these need a ToD coloring.
const bool off_map = (image.get_filename() == off_map_name);
const surface surface(image::get_image(image,
const surface surf(image::get_image(image,
off_map ? image::UNMASKED : image_type));
if (!surface.null()) {
res.push_back(surface);
if (!surf.null()) {
res.push_back(surf);
}
}
}
@ -2001,7 +1991,7 @@ void display::draw_hex(const map_location& loc) {
if(!shrouded(loc)) {
drawing_buffer_add(LAYER_FOG_SHROUD, loc, tblit(xpos, ypos,
get_terrain_images(loc, tod.id, image_type, ADJACENT_FOGSHROUD)));
get_fog_shroud_images(loc, image_type)));
}
if (on_map) {
if (draw_coordinates_) {

View file

@ -533,14 +533,14 @@ protected:
void draw_minimap();
enum ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, ADJACENT_FOREGROUND, ADJACENT_FOGSHROUD };
enum ADJACENT_TERRAIN_TYPE { ADJACENT_BACKGROUND, ADJACENT_FOREGROUND};
std::vector<surface> get_terrain_images(const map_location &loc,
const std::string& timeid,
image::TYPE type,
ADJACENT_TERRAIN_TYPE terrain_type);
std::vector<std::string> get_fog_shroud_graphics(const map_location& loc);
std::vector<surface> get_fog_shroud_images(const map_location& loc, image::TYPE image_type);
void draw_image_for_report(surface& img, SDL_Rect& rect);