Whiteboard: allow out-of-turn recruit/recall planning.

Take future position of leader into account when determining
recruit/recall possibilities.
This commit is contained in:
Gabriel Morin 2010-08-09 22:04:44 +00:00
parent fb918b2e76
commit 3863896e80
2 changed files with 11 additions and 2 deletions

View file

@ -1167,12 +1167,13 @@ bool play_controller::in_context_menu(hotkey::HOTKEY_COMMAND command) const
case hotkey::HOTKEY_RECRUIT:
case hotkey::HOTKEY_REPEAT_RECRUIT:
case hotkey::HOTKEY_RECALL: {
wb::scoped_planned_pathfind_map future; //< lasts until method returns.
// last_hex_ is set by mouse_events::mouse_motion
// Enable recruit/recall on castle/keep tiles
for(unit_map::const_iterator leader = units_.begin();
leader != units_.end();++leader) {
if (leader->can_recruit() &&
leader->side() == player_number_ &&
leader->side() == resources::screen->viewing_side() &&
can_recruit_on(map_, leader->get_location(), mouse_handler_.get_last_hex()))
return true;
}

View file

@ -44,6 +44,7 @@
#include "save_blocker.hpp"
#include "soundsource.hpp"
#include "storyscreen/interface.hpp"
#include "whiteboard/manager.hpp"
static lg::log_domain log_engine("engine");
#define ERR_NG LOG_STREAM(err, log_engine)
@ -102,16 +103,22 @@ void playsingle_controller::init_gui(){
void playsingle_controller::recruit(){
if (!browse_)
menu_handler_.recruit(player_number_, mouse_handler_.get_last_hex());
else if (resources::whiteboard->is_active())
menu_handler_.recruit(resources::screen->viewing_side(), mouse_handler_.get_last_hex());
}
void playsingle_controller::repeat_recruit(){
if (!browse_)
menu_handler_.repeat_recruit(player_number_, mouse_handler_.get_last_hex());
else if (resources::whiteboard->is_active())
menu_handler_.repeat_recruit(resources::screen->viewing_side(), mouse_handler_.get_last_hex());
}
void playsingle_controller::recall(){
if (!browse_)
menu_handler_.recall(player_number_, mouse_handler_.get_last_hex());
else if (resources::whiteboard->is_active())
menu_handler_.recall(resources::screen->viewing_side(), mouse_handler_.get_last_hex());
}
void playsingle_controller::toggle_shroud_updates(){
@ -954,10 +961,11 @@ bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command,
case hotkey::HOTKEY_ADD_WAYPOINT:
case hotkey::HOTKEY_UNIT_HOLD_POSITION:
case hotkey::HOTKEY_END_UNIT_TURN:
return !browse_ && !linger_ && !events::commands_disabled;
case hotkey::HOTKEY_RECRUIT:
case hotkey::HOTKEY_REPEAT_RECRUIT:
case hotkey::HOTKEY_RECALL:
return !browse_ && !linger_ && !events::commands_disabled;
return (!browse_ || resources::whiteboard->is_active()) && !linger_ && !events::commands_disabled;
case hotkey::HOTKEY_ENDTURN:
return (!browse_ || linger_) && !events::commands_disabled;