Enemy invisible units not displayed in the minimap
This commit is contained in:
parent
2cd5c041ba
commit
ce2d4cf654
4 changed files with 17 additions and 9 deletions
|
@ -1643,7 +1643,9 @@ void display::blit_surface(int x, int y, SDL_Surface* surface)
|
|||
SDL_Surface* display::getMinimap(int w, int h)
|
||||
{
|
||||
if(minimap_ == NULL)
|
||||
minimap_ = image::getMinimap(w,h,map_,team_valid() ? &teams_[currentTeam_] : NULL, &units_);
|
||||
minimap_ = image::getMinimap(w,h,map_,
|
||||
status_.get_time_of_day().lawful_bonus,
|
||||
team_valid() ? &teams_[currentTeam_] : NULL, &units_, &teams_);
|
||||
|
||||
sdl_add_ref(minimap_);
|
||||
return minimap_;
|
||||
|
|
|
@ -285,7 +285,9 @@ SDL_Surface* get_image_dim(const std::string& filename, size_t x, size_t y)
|
|||
return surf;
|
||||
}
|
||||
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map, const team* tm, const unit_map* units)
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map,
|
||||
int lawful_bonus,
|
||||
const team* tm, const unit_map* units, const std::vector<team>* teams)
|
||||
{
|
||||
SDL_Surface* minimap = NULL;
|
||||
if(minimap == NULL) {
|
||||
|
@ -329,13 +331,16 @@ SDL_Surface* getMinimap(int w, int h, const gamemap& map, const team* tm, const
|
|||
|
||||
surf = scale_surface(tile,scale,scale);
|
||||
|
||||
if(units != NULL && !fogged) {
|
||||
if(units != NULL && teams != NULL && tm != NULL && !fogged) {
|
||||
const unit_map::const_iterator u = units->find(loc);
|
||||
if(u != units->end()) {
|
||||
const SDL_Color& colour = font::get_side_colour(u->second.side());
|
||||
SDL_Rect rect = {0,0,surf->w,surf->h};
|
||||
const short col = SDL_MapRGB(surf->format,colour.r,colour.g,colour.b);
|
||||
SDL_FillRect(surf,&rect,col);
|
||||
if(!tm->is_enemy(u->second.side()) ||
|
||||
!u->second.invisible(terrain,lawful_bonus,loc,*units,*teams)){
|
||||
const SDL_Color& colour = font::get_side_colour(u->second.side());
|
||||
SDL_Rect rect = {0,0,surf->w,surf->h};
|
||||
const short col = SDL_MapRGB(surf->format,colour.r,colour.g,colour.b);
|
||||
SDL_FillRect(surf,&rect,col);
|
||||
}
|
||||
}
|
||||
|
||||
//we're not caching the surface, so make sure
|
||||
|
|
|
@ -63,7 +63,8 @@ namespace image {
|
|||
SDL_Surface* get_image_dim(const std::string& filename, size_t x, size_t y);
|
||||
|
||||
//the surface returned must be freed by the user
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map_, const team* tm=NULL, const unit_map* units=NULL);
|
||||
SDL_Surface* getMinimap(int w, int h, const gamemap& map_, int lawful_bonus,
|
||||
const team* tm=NULL, const unit_map* units=NULL, const std::vector<team>* teams=NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -354,7 +354,7 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
|
|||
level_ptr->remove_child("side",level_ptr->get_children("side").size()-1);
|
||||
}
|
||||
|
||||
const scoped_sdl_surface mini(image::getMinimap(145,145,map));
|
||||
const scoped_sdl_surface mini(image::getMinimap(145,145,map,0));
|
||||
|
||||
if(mini != NULL) {
|
||||
rect.x = ((disp.x()-width)/2+10)+35;
|
||||
|
|
Loading…
Add table
Reference in a new issue