Author: tschmitz
Date: Thu Aug 4 08:54:57 2011
New Revision: 50579
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50579&view=rev
Log:
Fixed problem with highlighting allies' actions and attempting to modify them.
Modified:
trunk/src/whiteboard/highlight_visitor.cpp
trunk/src/whiteboard/highlight_visitor.hpp
Modified: trunk/src/whiteboard/highlight_visitor.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/highlight_visitor.cpp?rev=50579&r1=50578&r2=50579&view=diff
==============================================================================
--- trunk/src/whiteboard/highlight_visitor.cpp (original)
+++ trunk/src/whiteboard/highlight_visitor.cpp Thu Aug 4 08:54:57 2011
@@ -85,6 +85,24 @@
// main_highlight_ = *action_it;
// }
}
+
+ //Set the execution/deletion/bump targets.
+ side_actions::iterator itor =
side_actions_->find_first_action_of(owner_unit_);
+ if(itor != side_actions_->end())
+ selected_action_ = *itor;
+ //Overwrite the above selected_action_ if we find a better one
+ BOOST_REVERSE_FOREACH(action_ptr act, *side_actions_)
+ {
+ /**@todo "is_numbering_hex" is not the "correct" criterion by
which to
+ * select the hightlighted/selected action. It's just
convenient for me
+ * to use at the moment since it happens to coincide with the
"correct"
+ * criterion, which is to use FIND_MAIN_HIGHLIGHT mode.*/
+ if(act->is_numbering_hex(hex))
+ {
+ selected_action_ = act;
+ break;
+ }
+ }
}
void highlight_visitor::clear()
@@ -160,36 +178,22 @@
action_ptr highlight_visitor::get_execute_target()
{
- action_ptr action;
-
- if (owner_unit_ && side_actions_->unit_has_actions(owner_unit_))
- {
- action = *side_actions_->find_first_action_of(owner_unit_);
- }
+ if(action_ptr locked = selected_action_.lock())
+ return *side_actions_->find_first_action_of(locked->get_unit());
else
- {
- action = main_highlight_.lock();
- }
-
- return action;
+ return action_ptr();
}
action_ptr highlight_visitor::get_delete_target()
{
- action_ptr action;
- if (owner_unit_ && side_actions_->unit_has_actions(owner_unit_))
- {
- action = *side_actions_->find_last_action_of(owner_unit_);
- }
+ if(action_ptr locked = selected_action_.lock())
+ return *side_actions_->find_last_action_of(locked->get_unit());
else
- {
- action = main_highlight_.lock();
- }
- return action;
+ return action_ptr();
}
action_ptr highlight_visitor::get_bump_target()
{
- return main_highlight_.lock();
+ return selected_action_.lock();
}
unit* highlight_visitor::get_selection_target()
Modified: trunk/src/whiteboard/highlight_visitor.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/highlight_visitor.hpp?rev=50579&r1=50578&r2=50579&view=diff
==============================================================================
--- trunk/src/whiteboard/highlight_visitor.hpp (original)
+++ trunk/src/whiteboard/highlight_visitor.hpp Thu Aug 4 08:54:57 2011
@@ -98,6 +98,7 @@
unit* owner_unit_;
unit* selection_candidate_;
+ weak_action_ptr selected_action_;
weak_action_ptr main_highlight_;
secondary_highlights_t secondary_highlights_;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits