fixed assertion failure
This commit is contained in:
parent
74dd9ac141
commit
4ae1f8a704
3 changed files with 29 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
||||||
#include "map.hpp"
|
#include "map.hpp"
|
||||||
#include "pathfind.hpp"
|
#include "pathfind.hpp"
|
||||||
#include "playlevel.hpp"
|
#include "playlevel.hpp"
|
||||||
|
#include "playturn.hpp"
|
||||||
#include "replay.hpp"
|
#include "replay.hpp"
|
||||||
#include "sound.hpp"
|
#include "sound.hpp"
|
||||||
#include "util.hpp"
|
#include "util.hpp"
|
||||||
|
@ -309,6 +310,10 @@ void attack(display& gui, const gamemap& map,
|
||||||
const gamestatus& state,
|
const gamestatus& state,
|
||||||
const game_data& info, bool player_is_attacker)
|
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<gamemap::location,unit>::iterator a = units.find(attacker);
|
std::map<gamemap::location,unit>::iterator a = units.find(attacker);
|
||||||
std::map<gamemap::location,unit>::iterator d = units.find(defender);
|
std::map<gamemap::location,unit>::iterator d = units.find(defender);
|
||||||
|
|
||||||
|
@ -791,6 +796,9 @@ size_t move_unit(display* disp, const gamemap& map,
|
||||||
const std::vector<gamemap::location>& route,
|
const std::vector<gamemap::location>& route,
|
||||||
replay* move_recorder, undo_list* undo_stack)
|
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());
|
assert(!route.empty());
|
||||||
|
|
||||||
const unit_map::iterator ui = units.find(route.front());
|
const unit_map::iterator ui = units.find(route.front());
|
||||||
|
|
|
@ -31,6 +31,13 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
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,
|
void play_turn(game_data& gameinfo, game_state& state_of_game,
|
||||||
gamestatus& status, config& terrain_config, config* level,
|
gamestatus& status, config& terrain_config, config* level,
|
||||||
CVideo& video, CKey& key, display& gui,
|
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)
|
void turn_info::mouse_motion(const SDL_MouseMotionEvent& event)
|
||||||
{
|
{
|
||||||
|
if(commands_disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
const team& current_team = teams_[team_num_-1];
|
const team& current_team = teams_[team_num_-1];
|
||||||
const gamemap::location new_hex = gui_.hex_clicked_on(event.x,event.y);
|
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)
|
void turn_info::mouse_press(const SDL_MouseButtonEvent& event)
|
||||||
{
|
{
|
||||||
|
if(commands_disabled)
|
||||||
|
return;
|
||||||
|
|
||||||
const team& current_team = teams_[team_num_-1];
|
const team& current_team = teams_[team_num_-1];
|
||||||
|
|
||||||
if(event.button == SDL_BUTTON_LEFT && event.state == SDL_PRESSED) {
|
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() &&
|
enemy == units_.end() && !current_route_.steps.empty() &&
|
||||||
current_route_.steps.front() == selected_hex_) {
|
current_route_.steps.front() == selected_hex_) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const size_t moves = move_unit(&gui_,map_,units_,teams_,
|
const size_t moves = move_unit(&gui_,map_,units_,teams_,
|
||||||
current_route_.steps,&recorder,&undo_stack_);
|
current_route_.steps,&recorder,&undo_stack_);
|
||||||
if(moves == 0)
|
if(moves == 0)
|
||||||
|
|
|
@ -45,6 +45,12 @@ private:
|
||||||
display& gui_;
|
display& gui_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct command_disabler
|
||||||
|
{
|
||||||
|
command_disabler();
|
||||||
|
~command_disabler();
|
||||||
|
};
|
||||||
|
|
||||||
class turn_info : public hotkey::command_executor, public events::handler,
|
class turn_info : public hotkey::command_executor, public events::handler,
|
||||||
private paths_wiper
|
private paths_wiper
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue