Prevent a bug+assert crash with fake_unit_move when it needs a scrolling.

It seems that after the scrolling and before the move, orb & bars were
briefly visible and this also trigger an assert.

Now always hide orb and bars of fake unit, and allow the drawing unit
function to know if it's a fake (and so skip undefined stuff)
This commit is contained in:
Ali El Gariani 2008-02-14 21:35:30 +00:00
parent 1f4653e97b
commit 5a03a0bc84
3 changed files with 8 additions and 5 deletions

View file

@ -481,7 +481,7 @@ void game_display::draw(bool update,bool force)
}
if (temp_unit_ && temp_unit_loc_ == *it2) {
temp_unit_->redraw_unit(*this, temp_unit_loc_);
temp_unit_->redraw_unit(*this, temp_unit_loc_, true);
//simulate_delay += 1;
}
}

View file

@ -1625,7 +1625,7 @@ void unit::set_facing(gamemap::location::DIRECTION dir) {
// Else look at yourself (not available so continue to face the same direction)
}
void unit::redraw_unit(game_display& disp, const gamemap::location& loc)
void unit::redraw_unit(game_display& disp, const gamemap::location& loc, const bool fake)
{
const gamemap & map = disp.get_map();
if(!loc.valid() || hidden_ || disp.fogged(loc)
@ -1743,8 +1743,8 @@ void unit::redraw_unit(game_display& disp, const gamemap::location& loc)
blend_ratio = 0.25;
}
// We draw bars only if wanted and visible on the map view
bool draw_bars = draw_bars_;
// We draw bars only if wanted, visible on the map view and not a fake unit
bool draw_bars = draw_bars_ && !fake;
if (draw_bars) {
const int d = disp.hex_size();
SDL_Rect unit_rect = {xsrc, ysrc_adjusted, d, d};
@ -1809,6 +1809,7 @@ void unit::redraw_unit(game_display& disp, const gamemap::location& loc)
if(disp.playing_team() == disp.viewing_team() && !user_end_turn()) {
if (movement_left() == total_movement()) {
movement_file = &game_config::unmoved_ball_image;
// unit_can_move assumes that it's not a fake unit (= in unit_map)
} else if(unit_can_move(loc,disp.get_units(),map,disp.get_teams())) {
movement_file = &game_config::partmoved_ball_image;
}

View file

@ -172,7 +172,9 @@ public:
//! A SDL surface, ready for display for place where we need a still-image of the unit.
const surface still_image(bool scaled = false) const;
void redraw_unit(game_display& disp, const gamemap::location& loc);
//! draw a unit, fake is used for temporary unit not in unit_map
//! (so we can skip functions assuming that)
void redraw_unit(game_display& disp, const gamemap::location& loc, const bool fake = false);
//! Clear unit_halo_ and unit_anim_halo_
void clear_haloes();