redraw_unit takes display & as an argument
This commit is contained in:
parent
f0fc9ff5c7
commit
4ff77b84c8
5 changed files with 14 additions and 10 deletions
|
@ -32,6 +32,7 @@
|
|||
#include "minimap.hpp"
|
||||
#include "play_controller.hpp" //note: this can probably be refactored out
|
||||
#include "reports.hpp"
|
||||
#include "team.hpp"
|
||||
#include "terrain_builder.hpp"
|
||||
#include "text.hpp"
|
||||
#include "time_of_day.hpp"
|
||||
|
@ -2554,7 +2555,7 @@ void display::draw_invalidated() {
|
|||
exclusive_unit_draw_requests_t::iterator request = exclusive_unit_draw_requests_.find(loc);
|
||||
if (u_it != dc_->units().end()
|
||||
&& (request == exclusive_unit_draw_requests_.end() || request->second == u_it->id()))
|
||||
(static_cast<const drawable_unit*> (&*u_it))->redraw_unit();
|
||||
(static_cast<const drawable_unit*> (&*u_it))->redraw_unit(*this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ public:
|
|||
|
||||
void change_display_context(const display_context * dc);
|
||||
|
||||
const display_context & get_disp_context() { return *dc_; }
|
||||
const display_context & get_disp_context() const { return *dc_; }
|
||||
|
||||
static Uint32 rgb(Uint8 red, Uint8 green, Uint8 blue)
|
||||
{ return 0xFF000000 | (red << 16) | (green << 8) | blue; }
|
||||
|
|
|
@ -25,12 +25,15 @@
|
|||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
void drawable_unit::redraw_unit () const
|
||||
void drawable_unit::redraw_unit (display & disp) const
|
||||
{
|
||||
display &disp = *display::get_singleton();
|
||||
const gamemap &map = disp.get_map();
|
||||
const display_context & dc = disp.get_disp_context();
|
||||
const gamemap &map = dc.map();
|
||||
const std::vector<team> &teams = dc.teams();
|
||||
|
||||
if ( hidden_ || disp.is_blindfolded() || !is_visible_to_team(disp.get_teams()[disp.viewing_team()],map, disp.show_everything()) )
|
||||
const team & viewing_team = teams[disp.viewing_team()];
|
||||
|
||||
if ( hidden_ || disp.is_blindfolded() || !is_visible_to_team(viewing_team,map, disp.show_everything()) )
|
||||
{
|
||||
clear_haloes();
|
||||
if(anim_) {
|
||||
|
@ -197,7 +200,7 @@ void drawable_unit::redraw_unit () const
|
|||
|
||||
if(size_t(side()) != disp.viewing_team()+1) {
|
||||
if(disp.team_valid() &&
|
||||
disp.get_teams()[disp.viewing_team()].is_enemy(side())) {
|
||||
viewing_team.is_enemy(side())) {
|
||||
if (preferences::show_enemy_orb() && !get_state(STATE_PETRIFIED))
|
||||
orb_img = &enemy_orb;
|
||||
else
|
||||
|
@ -217,7 +220,7 @@ void drawable_unit::redraw_unit () const
|
|||
if (preferences::show_unmoved_orb())
|
||||
orb_img = &unmoved_orb;
|
||||
else orb_img = NULL;
|
||||
} else if ( disp.get_disp_context().unit_can_move(*this) ) {
|
||||
} else if ( dc.unit_can_move(*this) ) {
|
||||
if (preferences::show_partial_orb())
|
||||
orb_img = &partmoved_orb;
|
||||
else orb_img = NULL;
|
||||
|
|
|
@ -33,7 +33,7 @@ class drawable_unit : protected unit //TODO: Get rid of inheritance and use comp
|
|||
{ //IMO, it would be better for drawable unit to hold a unit reference, and be marked as a friend class.
|
||||
//But I don't want to rewrite the redraw() function right now.
|
||||
/** draw a unit. */
|
||||
void redraw_unit() const;
|
||||
void redraw_unit(display & disp) const;
|
||||
|
||||
friend class display;
|
||||
friend class game_display;
|
||||
|
|
|
@ -252,7 +252,7 @@ void game_display::draw_invalidated()
|
|||
exclusive_unit_draw_requests_t::iterator request = exclusive_unit_draw_requests_.find(loc);
|
||||
if (invalidated_.find(loc) != invalidated_.end()
|
||||
&& (request == exclusive_unit_draw_requests_.end() || request->second == temp_unit->id()))
|
||||
(static_cast<const drawable_unit*> (temp_unit))->redraw_unit();
|
||||
(static_cast<const drawable_unit*> (temp_unit))->redraw_unit(*this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue