Parameter consistency between can_show() and fire_event().

(These are members of wml_menu_item.)
I opted to get rid of a parameter and use a global. Using globals
is kind of yucky, but in this case, it's basically a choice between
using the global within the procedure or using the global as a
parameter to the procedure. I chose to go with the older function's
approach.
This commit is contained in:
JaMiT 2013-10-27 02:49:04 -05:00
parent 01149e92eb
commit 01b65ff9ba
3 changed files with 6 additions and 8 deletions

View file

@ -119,9 +119,10 @@ bool wml_menu_item::can_show(const map_location & hex) const
* @param[in] event_hex The location of the event (where the menu was opened).
* @param[in] last_select The location of the most recent "select" event.
*/
void wml_menu_item::fire_event(const map_location & event_hex,
const map_location & last_select) const
void wml_menu_item::fire_event(const map_location & event_hex) const
{
const map_location & last_select = resources::gamedata->last_selected;
// No new player-issued commands allowed while this is firing.
const events::command_disabler disable_commands;

View file

@ -55,8 +55,7 @@ public:
/// Returns whether or not *this is applicable given the context.
bool can_show(const map_location & hex) const;
/// Causes the event associated with this item to fire.
void fire_event(const map_location & event_hex,
const map_location & last_select) const;
void fire_event(const map_location & event_hex) const;
/// Change the actions associated with this item.
/// (Internal bookkeeping only; the caller must still update the event handlers.)
void set_command(const config & cfg) { command_ = cfg; }

View file

@ -813,8 +813,7 @@ bool play_controller::execute_command(const hotkey::hotkey_command& cmd, int ind
throw game::load_game_exception(savenames_[i],false,false,false,"");
} else if (i < wml_commands_.size() && wml_commands_[i] != NULL) {
wml_commands_[i]->fire_event(mouse_handler_.get_last_hex(),
gamedata_.last_selected);
wml_commands_[i]->fire_event(mouse_handler_.get_last_hex());
return true;
}
}
@ -837,8 +836,7 @@ bool play_controller::execute_command(const hotkey::hotkey_command& cmd, int ind
if (iter->can_show(hex))
{
iter->fire_event(mouse_handler_.get_last_hex(),
gamedata_.last_selected);
iter->fire_event(mouse_handler_.get_last_hex());
}
}
}