Fixes bug #7308: Next Unit returns to same unit.
This commit is contained in:
parent
5f42f9868b
commit
8d41e59f68
3 changed files with 32 additions and 6 deletions
|
@ -1106,7 +1106,7 @@ bool clear_shroud(display& disp, const gamemap& map, const game_data& gamedata,
|
|||
size_t move_unit(display* disp, const game_data& gamedata, const gamemap& map,
|
||||
unit_map& units, std::vector<team>& teams,
|
||||
const std::vector<gamemap::location>& route,
|
||||
replay* move_recorder, undo_list* undo_stack)
|
||||
replay* move_recorder, undo_list* undo_stack, gamemap::location *next_unit)
|
||||
{
|
||||
//stop the user from issuing any commands while the unit is moving
|
||||
const command_disabler disable_commands;
|
||||
|
@ -1184,6 +1184,9 @@ size_t move_unit(display* disp, const game_data& gamedata, const gamemap& map,
|
|||
|
||||
assert(steps.size() <= route.size());
|
||||
|
||||
if (next_unit != NULL )
|
||||
*next_unit = steps.back();
|
||||
|
||||
//if we can't get all the way there and have to set a go-to,
|
||||
//unless we stop early because of sighting a unit
|
||||
if(steps.size() != route.size() && !seen_unit) {
|
||||
|
|
|
@ -174,7 +174,8 @@ typedef std::deque<undo_action> undo_list;
|
|||
size_t move_unit(display* disp, const game_data& gamedata, const gamemap& map,
|
||||
unit_map& units, std::vector<team>& teams,
|
||||
const std::vector<gamemap::location>& steps,
|
||||
replay* move_recorder, undo_list* undos);
|
||||
replay* move_recorder, undo_list* undos,
|
||||
gamemap::location *next_unit = NULL);
|
||||
|
||||
//function which will clear shroud away for the given 0-based team based on
|
||||
//current unit positions. Returns true if some shroud is actually cleared away.
|
||||
|
|
|
@ -542,7 +542,7 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
|
|||
|
||||
|
||||
const size_t moves = move_unit(&gui_,gameinfo_,map_,units_,teams_,
|
||||
current_route_.steps,&recorder,&undo_stack_);
|
||||
current_route_.steps,&recorder,&undo_stack_, &next_unit_);
|
||||
|
||||
gui_.invalidate_game_status();
|
||||
|
||||
|
@ -598,6 +598,8 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event)
|
|||
current_paths_ = paths(map_,gameinfo_,units_,hex,teams_,
|
||||
ignore_zocs,teleport,path_turns_);
|
||||
|
||||
next_unit_ = it->first;
|
||||
|
||||
show_attack_options(it);
|
||||
|
||||
gui_.set_paths(¤t_paths_);
|
||||
|
@ -738,13 +740,22 @@ void turn_info::show_menu(const std::vector<std::string>& items_arg)
|
|||
|
||||
void turn_info::cycle_units()
|
||||
{
|
||||
|
||||
unit_map::const_iterator it = units_.find(next_unit_);
|
||||
unit_map::const_iterator yellow_it = units_.end();
|
||||
if(it != units_.end()) {
|
||||
for(++it; it != units_.end(); ++it) {
|
||||
if(it->second.side() == team_num_ &&
|
||||
unit_can_move(it->first,units_,map_,teams_) &&
|
||||
!gui_.fogged(it->first.x,it->first.y)) {
|
||||
break;
|
||||
if (it->second.movement_left() !=
|
||||
it->second.total_movement()) {
|
||||
if (yellow_it == units_.end()) {
|
||||
yellow_it = it;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -754,11 +765,22 @@ void turn_info::cycle_units()
|
|||
if(it->second.side() == team_num_ &&
|
||||
unit_can_move(it->first,units_,map_,teams_) &&
|
||||
!gui_.fogged(it->first.x,it->first.y)) {
|
||||
break;
|
||||
if (it->second.movement_left() !=
|
||||
it->second.total_movement()) {
|
||||
if (yellow_it == units_.end()) {
|
||||
yellow_it = it;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (it == units_.end()) {
|
||||
it = yellow_it;
|
||||
}
|
||||
|
||||
if(it != units_.end() && !gui_.fogged(it->first.x,it->first.y)) {
|
||||
const bool ignore_zocs = it->second.type().is_skirmisher();
|
||||
const bool teleport = it->second.type().teleports();
|
||||
|
@ -775,7 +797,7 @@ void turn_info::cycle_units()
|
|||
gui_.select_hex(selected_hex_);
|
||||
current_route_.steps.clear();
|
||||
gui_.set_route(NULL);
|
||||
} else
|
||||
} else
|
||||
next_unit_ = gamemap::location();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue