optimize minimap.cpp
This commit is contained in:
parent
d4cead0d87
commit
8d5440756e
1 changed files with 15 additions and 3 deletions
|
@ -45,6 +45,10 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
const int scale = 8;
|
||||
|
||||
DBG_DP << "creating minimap " << int(map.w()*scale*0.75) << "," << map.h()*scale << "\n";
|
||||
|
||||
const bool preferences_minimap_draw_terrain = preferences::minimap_draw_terrain();
|
||||
const bool preferences_minimap_terrain_coding = preferences::minimap_terrain_coding();
|
||||
const bool preferences_minimap_draw_villages = preferences::minimap_draw_villages();
|
||||
|
||||
const size_t map_width = map.w()*scale*3/4;
|
||||
const size_t map_height = map.h()*scale;
|
||||
|
@ -52,6 +56,14 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
return surface(NULL);
|
||||
}
|
||||
|
||||
if(!preferences_minimap_draw_villages && !preferences_minimap_draw_terrain)
|
||||
{
|
||||
//return if there is nothing to draw.
|
||||
//(optimisation)
|
||||
double ratio = std::min<double>( w*1.0 / map_width, h*1.0 / map_height);
|
||||
return create_neutral_surface(map_width * ratio, map_height * ratio);
|
||||
}
|
||||
|
||||
surface minimap(create_neutral_surface(map_width, map_height));
|
||||
if(minimap == NULL)
|
||||
return surface(NULL);
|
||||
|
@ -90,9 +102,9 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
, 0
|
||||
, 0);
|
||||
|
||||
if (preferences::minimap_draw_terrain()) {
|
||||
if (preferences_minimap_draw_terrain) {
|
||||
|
||||
if (!preferences::minimap_terrain_coding()) {
|
||||
if (!preferences_minimap_terrain_coding) {
|
||||
|
||||
surface surf(NULL);
|
||||
|
||||
|
@ -218,7 +230,7 @@ surface getMinimap(int w, int h, const gamemap &map, const team *vw, const std::
|
|||
}
|
||||
}
|
||||
|
||||
if (terrain_info.is_village() && preferences::minimap_draw_villages()) {
|
||||
if (terrain_info.is_village() && preferences_minimap_draw_villages) {
|
||||
|
||||
int side = village_owner(loc);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue