fix the "can't end turn" bug

This commit is contained in:
Patrick Parker 2007-03-26 21:37:30 +00:00
parent 61b6838a78
commit e98ca04d31
8 changed files with 13 additions and 13 deletions

View file

@ -707,7 +707,7 @@ void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* ex
const int zoom_amount = 4;
if(executor != NULL) {
if(!executor->can_execute_command(command) || executor->execute_command(command, index))
if(!executor->can_execute_command(command, index) || executor->execute_command(command, index))
return;
}
switch(command) {
@ -773,10 +773,10 @@ void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* ex
}
}
void command_executor::show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool /*context_menu*/, display& gui, const std::vector<std::string>& savenames)
void command_executor::show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool /*context_menu*/, display& gui)
{
std::vector<std::string> items = items_arg;
if (can_execute_command(hotkey::get_hotkey(items.front()).get_id())){
if (can_execute_command(hotkey::get_hotkey(items.front()).get_id(), 0)){
//if just one item is passed in, that means we should execute that item
if(items.size() == 1 && items_arg.size() == 1) {
hotkey::execute_command(gui,hotkey::get_hotkey(items.front()).get_id(),this);

View file

@ -226,7 +226,7 @@ public:
//Returns a vector of images for a given menu
std::vector<std::string> get_menu_images(const std::vector<std::string>& items_arg);
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& gui,const std::vector<std::string>& savenames = std::vector<std::string>());
void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu, display& gui);
virtual bool can_execute_command(HOTKEY_COMMAND command, int index=-1) const = 0;
virtual bool execute_command(HOTKEY_COMMAND command, int index=-1);

View file

@ -305,7 +305,7 @@ void playmp_controller::handle_generic_event(const std::string& name){
}
}
bool playmp_controller::can_execute_command(hotkey::HOTKEY_COMMAND command) const
bool playmp_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
{
bool res = true;
switch (command){
@ -317,7 +317,7 @@ bool playmp_controller::can_execute_command(hotkey::HOTKEY_COMMAND command) cons
res = res && network::nconnections() > 0;
break;
default:
return playsingle_controller::can_execute_command(command);
return playsingle_controller::can_execute_command(command, index);
}
return res;
}

View file

@ -35,7 +35,7 @@ protected:
virtual void speak();
virtual void clear_labels();
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command) const;
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
virtual void play_side(const unsigned int team_index, bool save);
virtual void before_human_turn(bool save);

View file

@ -566,7 +566,7 @@ void playsingle_controller::check_time_over(){
}
}
bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command) const
bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
{
bool res = true;
switch (command){
@ -607,7 +607,7 @@ bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command)
if (i == units_.end()) return false;
return i->second.move_interrupted();
}
default: return play_controller::can_execute_command(command);
default: return play_controller::can_execute_command(command, index);
}
return res;
}

View file

@ -39,7 +39,7 @@ public:
virtual void recruit();
virtual void repeat_recruit();
virtual void recall();
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command) const;
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
virtual void toggle_shroud_updates();
virtual void update_shroud_now();
virtual void end_turn();

View file

@ -353,9 +353,9 @@ void replay_controller::show_statistics(){
menu_handler_.show_statistics(gui_->playing_team()+1);
}
bool replay_controller::can_execute_command(hotkey::HOTKEY_COMMAND command) const
bool replay_controller::can_execute_command(hotkey::HOTKEY_COMMAND command, int index) const
{
bool result = play_controller::can_execute_command(command);
bool result = play_controller::can_execute_command(command,index);
switch(command) {

View file

@ -38,7 +38,7 @@ public:
const int ticks, const int num_turns, const config& game_config, CVideo& video);
~replay_controller();
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command) const;
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
std::vector<team>& get_teams();
unit_map get_units();