Whiteboard: validate actions at critical places...
...instead of every time the gamestate changes.
This commit is contained in:
parent
17ea65ce66
commit
8a14da7e1e
2 changed files with 18 additions and 2 deletions
|
@ -43,6 +43,7 @@ manager::manager():
|
|||
wait_for_side_init_(true),
|
||||
planned_unit_map_active_(false),
|
||||
executing_actions_(false),
|
||||
gamestate_mutated_(false),
|
||||
mapbuilder_(),
|
||||
highlighter_(new highlight_visitor(*resources::units, viewer_actions())),
|
||||
route_(),
|
||||
|
@ -214,6 +215,7 @@ void manager::set_planned_unit_map(bool include_recruits)
|
|||
{
|
||||
if (!planned_unit_map_active_)
|
||||
{
|
||||
validate_actions_if_needed();
|
||||
DBG_WB << "Building planned unit map.\n";
|
||||
mapbuilder_.reset(new mapbuilder_visitor(*resources::units, viewer_actions(), include_recruits));
|
||||
mapbuilder_->build_map();
|
||||
|
@ -307,8 +309,8 @@ void manager::on_mouseover_change(const map_location& hex)
|
|||
|
||||
void manager::on_gamestate_change()
|
||||
{
|
||||
DBG_WB << "Manager received gamestate change notification, validating actions.\n";
|
||||
validate_viewer_actions();
|
||||
DBG_WB << "Manager received gamestate change notification.\n";
|
||||
gamestate_mutated_ = true;
|
||||
}
|
||||
|
||||
void manager::create_temp_move()
|
||||
|
@ -620,6 +622,16 @@ void manager::fake_unit_deleter::operator() (unit*& fake_unit)
|
|||
}
|
||||
}
|
||||
|
||||
void manager::validate_actions_if_needed()
|
||||
{
|
||||
if (gamestate_mutated_)
|
||||
{
|
||||
LOG_WB << "'gamestate_mutated_' flag dirty, validating actions.\n";
|
||||
validate_viewer_actions();
|
||||
}
|
||||
gamestate_mutated_ = false;
|
||||
}
|
||||
|
||||
scoped_planned_unit_map::scoped_planned_unit_map()
|
||||
:has_planned_unit_map_(resources::whiteboard->has_planned_unit_map())
|
||||
{
|
||||
|
|
|
@ -131,6 +131,8 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
void validate_actions_if_needed();
|
||||
|
||||
///Tracks whether the whiteboard is active.
|
||||
bool active_;
|
||||
bool inverted_behavior_;
|
||||
|
@ -139,6 +141,8 @@ private:
|
|||
bool planned_unit_map_active_;
|
||||
/** Track whenever we're modifying actions, to avoid dual execution etc. */
|
||||
bool executing_actions_;
|
||||
/** Track whether the gamestate changed and we need to validate actions. */
|
||||
bool gamestate_mutated_;
|
||||
|
||||
boost::scoped_ptr<mapbuilder_visitor> mapbuilder_;
|
||||
boost::scoped_ptr<highlight_visitor> highlighter_;
|
||||
|
|
Loading…
Add table
Reference in a new issue