diff --git a/src/actions.cpp b/src/actions.cpp index 6acf78d9d19..8d905b7e111 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -21,6 +21,7 @@ #include "map.hpp" #include "pathfind.hpp" #include "playlevel.hpp" +#include "playturn.hpp" #include "replay.hpp" #include "sound.hpp" #include "util.hpp" @@ -309,6 +310,10 @@ void attack(display& gui, const gamemap& map, const gamestatus& state, const game_data& info, bool player_is_attacker) { + + //stop the user from issuing any commands while the units are fighting + const command_disabler disable_commands; + std::map::iterator a = units.find(attacker); std::map::iterator d = units.find(defender); @@ -791,6 +796,9 @@ size_t move_unit(display* disp, const gamemap& map, const std::vector& route, replay* move_recorder, undo_list* undo_stack) { + //stop the user from issuing any commands while the unit is moving + const command_disabler disable_commands; + assert(!route.empty()); const unit_map::iterator ui = units.find(route.front()); diff --git a/src/playturn.cpp b/src/playturn.cpp index cd8b29325eb..894a3a8dd25 100644 --- a/src/playturn.cpp +++ b/src/playturn.cpp @@ -31,6 +31,13 @@ #include #include +namespace { + int commands_disabled = 0; +} + +command_disabler::command_disabler() { ++commands_disabled; } +command_disabler::~command_disabler() { --commands_disabled; } + void play_turn(game_data& gameinfo, game_state& state_of_game, gamestatus& status, config& terrain_config, config* level, CVideo& video, CKey& key, display& gui, @@ -225,6 +232,9 @@ void turn_info::handle_event(const SDL_Event& event) void turn_info::mouse_motion(const SDL_MouseMotionEvent& event) { + if(commands_disabled) + return; + const team& current_team = teams_[team_num_-1]; const gamemap::location new_hex = gui_.hex_clicked_on(event.x,event.y); @@ -288,6 +298,9 @@ void turn_info::mouse_motion(const SDL_MouseMotionEvent& event) void turn_info::mouse_press(const SDL_MouseButtonEvent& event) { + if(commands_disabled) + return; + const team& current_team = teams_[team_num_-1]; if(event.button == SDL_BUTTON_LEFT && event.state == SDL_PRESSED) { @@ -451,6 +464,8 @@ void turn_info::left_click(const SDL_MouseButtonEvent& event) enemy == units_.end() && !current_route_.steps.empty() && current_route_.steps.front() == selected_hex_) { + + const size_t moves = move_unit(&gui_,map_,units_,teams_, current_route_.steps,&recorder,&undo_stack_); if(moves == 0) diff --git a/src/playturn.hpp b/src/playturn.hpp index 32ef8e75b1a..c3c22c364d1 100644 --- a/src/playturn.hpp +++ b/src/playturn.hpp @@ -45,6 +45,12 @@ private: display& gui_; }; +struct command_disabler +{ + command_disabler(); + ~command_disabler(); +}; + class turn_info : public hotkey::command_executor, public events::handler, private paths_wiper {