mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 23:33:17 +00:00
fix for crash when moving fake units (I thought I had already commited these)
This commit is contained in:
parent
b3e74f3192
commit
f4a6dacf77
@ -2500,13 +2500,9 @@ size_t move_unit(game_display* disp,
|
||||
return steps.size();
|
||||
}
|
||||
|
||||
bool unit_can_move(const map_location& loc, const unit_map& units,
|
||||
bool unit_can_move(const map_location& loc,const unit& u, const unit_map& units,
|
||||
const gamemap& map, const std::vector<team>& teams)
|
||||
{
|
||||
const unit_map::const_iterator u_it = units.find(loc);
|
||||
assert(u_it != units.end());
|
||||
|
||||
const unit& u = u_it->second;
|
||||
const team& current_team = teams[u.side()-1];
|
||||
|
||||
if(!u.attacks_left() && u.movement_left()==0)
|
||||
|
@ -385,7 +385,7 @@ void apply_shroud_changes(undo_list& undos, game_display* disp, const gamemap& m
|
||||
* Will return true iff the unit at 'loc' has any possible moves
|
||||
* it can do (including attacking etc).
|
||||
*/
|
||||
bool unit_can_move(const map_location& loc, const unit_map& units,
|
||||
bool unit_can_move(const map_location& loc, const unit& u, const unit_map& units,
|
||||
const gamemap& map, const std::vector<team>& teams);
|
||||
|
||||
|
||||
|
@ -1382,7 +1382,7 @@ private:
|
||||
for(unit_map::const_iterator un = units_.begin(); un != units_.end(); ++un) {
|
||||
if(un->second.side() == team_num) {
|
||||
units_alive++;
|
||||
if(unit_can_move(un->first,units_,map_,teams_)) {
|
||||
if(unit_can_move(un->first,un->second,units_,map_,teams_)) {
|
||||
if(!un->second.has_moved()) {
|
||||
unmoved_units = true;
|
||||
}
|
||||
|
@ -716,7 +716,7 @@ bool mouse_handler::unit_in_cycle(unit_map::const_iterator it)
|
||||
return false;
|
||||
|
||||
if(it->second.side() != team_num_ || it->second.user_end_turn()
|
||||
|| gui().fogged(it->first) || !unit_can_move(it->first,units_,map_,teams_))
|
||||
|| gui().fogged(it->first) || !unit_can_move(it->first,it->second,units_,map_,teams_))
|
||||
return false;
|
||||
|
||||
if (current_team().is_enemy(int(gui().viewing_team()+1)) &&
|
||||
|
@ -1935,8 +1935,7 @@ void unit::redraw_unit(game_display& disp, const map_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())) {
|
||||
} else if(unit_can_move(loc,*this,disp.get_units(),map,disp.get_teams())) {
|
||||
movement_file = &game_config::partmoved_ball_image;
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ void move_unit(const std::vector<map_location>& path, unit& u, const std::vector
|
||||
// Original unit is usually hidden (but still on map, so count is correct)
|
||||
unit temp_unit = u;
|
||||
u.set_hidden(true);
|
||||
temp_unit.set_standing(path[0]);
|
||||
temp_unit.set_standing(path[0],false);
|
||||
temp_unit.set_hidden(false);
|
||||
disp->place_temporary_unit(temp_unit,path[0]);
|
||||
disp->draw();
|
||||
|
Loading…
x
Reference in New Issue
Block a user