mail[Wesnoth-commits] r44897 - in /trunk/src/whiteboard: manager.cpp manager.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by gabrielmorin on July 30, 2010 - 04:01:
Author: gabba
Date: Fri Jul 30 04:01:07 2010
New Revision: 44897

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44897&view=rev
Log:
Whiteboard: add a new scoped_planned_pathfind_map struct that builds a unit 
map including recruits (and eventually recalls, dead actions, etc.).

Modified:
    trunk/src/whiteboard/manager.cpp
    trunk/src/whiteboard/manager.hpp

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=44897&r1=44896&r2=44897&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Fri Jul 30 04:01:07 2010
@@ -208,14 +208,14 @@
        viewer_actions()->validate_actions();
 }
 
-void manager::set_planned_unit_map()
+void manager::set_planned_unit_map(bool include_recruits)
 {
        if (!executing_actions_ && !wait_for_side_init_)
        {
                if (!planned_unit_map_active_)
                {
                        DBG_WB << "Building planned unit map.\n";
-                       mapbuilder_.reset(new 
mapbuilder_visitor(*resources::units, viewer_actions()));
+                       mapbuilder_.reset(new 
mapbuilder_visitor(*resources::units, viewer_actions(), include_recruits));
                        mapbuilder_->build_map();
                        planned_unit_map_active_ = true;
                }
@@ -640,4 +640,21 @@
                resources::whiteboard->set_planned_unit_map();
 }
 
+scoped_planned_pathfind_map::scoped_planned_pathfind_map()
+:has_planned_unit_map_(resources::whiteboard->has_planned_unit_map())
+{
+       if (has_planned_unit_map_)
+               resources::whiteboard->set_real_unit_map();
+
+       resources::whiteboard->set_planned_unit_map(true);
+}
+
+scoped_planned_pathfind_map::~scoped_planned_pathfind_map()
+{
+       resources::whiteboard->set_real_unit_map();
+
+       if (has_planned_unit_map_)
+               resources::whiteboard->set_planned_unit_map();
+}
+
 } // end namespace wb

Modified: trunk/src/whiteboard/manager.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.hpp?rev=44897&r1=44896&r2=44897&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Fri Jul 30 04:01:07 2010
@@ -169,6 +169,17 @@
        bool has_planned_unit_map_;
 };
 
+/** A variant on the regular planned unit map, that includes units only 
useful for pathfinding,
+ * such as those from planned recruits and recalls.
+ * It replaces any the regular planned unit map, and rebuilds it afterwards 
if needed.
+ *  */
+struct scoped_planned_pathfind_map
+{
+       scoped_planned_pathfind_map();
+       ~scoped_planned_pathfind_map();
+       bool has_planned_unit_map_;
+};
+
 } // end namespace wb
 
 #endif /* WB_MANAGER_HPP_ */




Related Messages


Powered by MHonArc, Updated Fri Jul 30 04:20:26 2010