Author: tschmitz
Date: Sat Aug 20 10:05:42 2011
New Revision: 50864
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50864&view=rev
Log:
Renamed mapbuilder_visitor to mapbuilder.
Added:
trunk/src/whiteboard/mapbuilder.cpp
- copied, changed from r50863, trunk/src/whiteboard/mapbuilder_visitor.cpp
trunk/src/whiteboard/mapbuilder.hpp
- copied, changed from r50863, trunk/src/whiteboard/mapbuilder_visitor.hpp
Removed:
trunk/src/whiteboard/mapbuilder_visitor.cpp
trunk/src/whiteboard/mapbuilder_visitor.hpp
Modified:
trunk/projectfiles/VC9/wesnoth.vcproj
trunk/src/CMakeLists.txt
trunk/src/SConscript
trunk/src/whiteboard/manager.cpp
trunk/src/whiteboard/manager.hpp
trunk/src/whiteboard/validate_visitor.hpp
trunk/src/whiteboard/visitor.hpp
Modified: trunk/projectfiles/VC9/wesnoth.vcproj
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/projectfiles/VC9/wesnoth.vcproj?rev=50864&r1=50863&r2=50864&view=diff
==============================================================================
--- trunk/projectfiles/VC9/wesnoth.vcproj (original)
+++ trunk/projectfiles/VC9/wesnoth.vcproj Sat Aug 20 10:05:42 2011
@@ -6797,7 +6797,7 @@
>
</File>
<File
-
RelativePath="..\..\src\whiteboard\mapbuilder_visitor.cpp"
+
RelativePath="..\..\src\whiteboard\mapbuilder.cpp"
>
<FileConfiguration
Name="Debug|Win32"
@@ -6825,7 +6825,7 @@
</FileConfiguration>
</File>
<File
-
RelativePath="..\..\src\whiteboard\mapbuilder_visitor.hpp"
+
RelativePath="..\..\src\whiteboard\mapbuilder.hpp"
>
</File>
<File
Modified: trunk/src/CMakeLists.txt
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/CMakeLists.txt?rev=50864&r1=50863&r2=50864&view=diff
==============================================================================
--- trunk/src/CMakeLists.txt (original)
+++ trunk/src/CMakeLists.txt Sat Aug 20 10:05:42 2011
@@ -573,7 +573,7 @@
whiteboard/attack.cpp
whiteboard/highlight_visitor.cpp
whiteboard/manager.cpp
- whiteboard/mapbuilder_visitor.cpp
+ whiteboard/mapbuilder.cpp
whiteboard/move.cpp
whiteboard/recall.cpp
whiteboard/recruit.cpp
Modified: trunk/src/SConscript
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/SConscript?rev=50864&r1=50863&r2=50864&view=diff
==============================================================================
--- trunk/src/SConscript (original)
+++ trunk/src/SConscript Sat Aug 20 10:05:42 2011
@@ -430,7 +430,7 @@
whiteboard/attack.cpp
whiteboard/highlight_visitor.cpp
whiteboard/manager.cpp
- whiteboard/mapbuilder_visitor.cpp
+ whiteboard/mapbuilder.cpp
whiteboard/move.cpp
whiteboard/recall.cpp
whiteboard/recruit.cpp
Modified: trunk/src/whiteboard/manager.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=50864&r1=50863&r2=50864&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Sat Aug 20 10:05:42 2011
@@ -21,7 +21,7 @@
#include "action.hpp"
#include "highlight_visitor.hpp"
-#include "mapbuilder_visitor.hpp"
+#include "mapbuilder.hpp"
#include "move.hpp"
#include "recruit.hpp"
#include "side_actions.hpp"
@@ -337,7 +337,7 @@
{
validate_actions_if_needed();
log_scope2("whiteboard", "Building planned unit map");
- mapbuilder_.reset(new
mapbuilder_visitor(*resources::units));
+ mapbuilder_.reset(new mapbuilder(*resources::units));
mapbuilder_->build_map();
planned_unit_map_active_ = true;
}
Modified: trunk/src/whiteboard/manager.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.hpp?rev=50864&r1=50863&r2=50864&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.hpp (original)
+++ trunk/src/whiteboard/manager.hpp Sat Aug 20 10:05:42 2011
@@ -38,7 +38,7 @@
namespace wb {
-class mapbuilder_visitor;
+class mapbuilder;
class highlight_visitor;
/**
@@ -181,7 +181,7 @@
/** Track whether the gamestate changed and we need to validate
actions. */
bool gamestate_mutated_;
- boost::scoped_ptr<mapbuilder_visitor> mapbuilder_;
+ boost::scoped_ptr<mapbuilder> mapbuilder_;
boost::shared_ptr<highlight_visitor> highlighter_;
boost::scoped_ptr<pathfind::marked_route> route_;
Copied: trunk/src/whiteboard/mapbuilder.cpp (from r50863,
trunk/src/whiteboard/mapbuilder_visitor.cpp)
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/mapbuilder.cpp?p2=trunk/src/whiteboard/mapbuilder.cpp&p1=trunk/src/whiteboard/mapbuilder_visitor.cpp&r1=50863&r2=50864&rev=50864&view=diff
==============================================================================
--- trunk/src/whiteboard/mapbuilder_visitor.cpp (original)
+++ trunk/src/whiteboard/mapbuilder.cpp Sat Aug 20 10:05:42 2011
@@ -17,7 +17,7 @@
* @file
*/
-#include "mapbuilder_visitor.hpp"
+#include "mapbuilder.hpp"
#include "action.hpp"
#include "side_actions.hpp"
@@ -32,7 +32,7 @@
namespace wb
{
-mapbuilder_visitor::mapbuilder_visitor(unit_map& unit_map)
+mapbuilder::mapbuilder(unit_map& unit_map)
: unit_map_(unit_map)
, applied_actions_()
, resetters_()
@@ -40,13 +40,13 @@
{
}
-mapbuilder_visitor::~mapbuilder_visitor()
+mapbuilder::~mapbuilder()
{
restore_normal_map();
//Remember that the member variable resetters_ is destructed here
}
-void mapbuilder_visitor::reset_moves()
+void mapbuilder::reset_moves()
{
int current_side = resources::controller->current_side();
foreach(unit& u, *resources::units)
@@ -58,13 +58,13 @@
}
}
-void mapbuilder_visitor::build_map()
+void mapbuilder::build_map()
{
reset_moves();
visit_all();
}
-bool mapbuilder_visitor::visit(size_t, team&, side_actions&,
side_actions::iterator itor)
+bool mapbuilder::visit(size_t, team&, side_actions&, side_actions::iterator
itor)
{
action_ptr act = *itor;
unit* u = act->get_unit();
@@ -83,10 +83,10 @@
return true;
}
-bool mapbuilder_visitor::post_visit_team(size_t, team&, side_actions&)
+bool mapbuilder::post_visit_team(size_t, team&, side_actions&)
{acted_this_turn_.clear(); return true;}
-void mapbuilder_visitor::restore_normal_map()
+void mapbuilder::restore_normal_map()
{
//applied_actions_ contain only the actions that we applied to the unit
map
BOOST_REVERSE_FOREACH(action_ptr act, applied_actions_)
Copied: trunk/src/whiteboard/mapbuilder.hpp (from r50863,
trunk/src/whiteboard/mapbuilder_visitor.hpp)
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/mapbuilder.hpp?p2=trunk/src/whiteboard/mapbuilder.hpp&p1=trunk/src/whiteboard/mapbuilder_visitor.hpp&r1=50863&r2=50864&rev=50864&view=diff
==============================================================================
--- trunk/src/whiteboard/mapbuilder_visitor.hpp (original)
+++ trunk/src/whiteboard/mapbuilder.hpp Sat Aug 20 10:05:42 2011
@@ -17,8 +17,8 @@
* @file
*/
-#ifndef WB_MAPBUILDER_VISITOR_HPP_
-#define WB_MAPBUILDER_VISITOR_HPP_
+#ifndef WB_MAPBUILDER_HPP_
+#define WB_MAPBUILDER_HPP_
#include <boost/ptr_container/ptr_vector.hpp>
@@ -35,14 +35,14 @@
* Visitor that collects and applies unit_map modifications from the actions
it visits
* and reverts all changes on destruction.
*/
-class mapbuilder_visitor
- : private enable_visit_all<mapbuilder_visitor>
+class mapbuilder
+ : private enable_visit_all<mapbuilder>
{
- friend class enable_visit_all<mapbuilder_visitor>;
+ friend class enable_visit_all<mapbuilder>;
public:
- mapbuilder_visitor(unit_map& unit_map);
- virtual ~mapbuilder_visitor();
+ mapbuilder(unit_map& unit_map);
+ virtual ~mapbuilder();
///builds every team's actions as far into the future as possible, in
the correct order
void build_map();
@@ -73,4 +73,4 @@
}
-#endif /* WB_MAPBUILDER_VISITOR_HPP_ */
+#endif /* WB_MAPBUILDER_HPP_ */
Removed: trunk/src/whiteboard/mapbuilder_visitor.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/mapbuilder_visitor.cpp?rev=50863&view=auto
==============================================================================
--- trunk/src/whiteboard/mapbuilder_visitor.cpp (original)
+++ trunk/src/whiteboard/mapbuilder_visitor.cpp (removed)
@@ -1,99 +1,0 @@
-/* $Id$ */
-/*
- Copyright (C) 2010 - 2011 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
- Part of the Battle for Wesnoth Project http://www.wesnoth.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY.
-
- See the COPYING file for more details.
- */
-
-/**
- * @file
- */
-
-#include "mapbuilder_visitor.hpp"
-
-#include "action.hpp"
-#include "side_actions.hpp"
-#include "utility.hpp"
-
-#include "foreach.hpp"
-#include "play_controller.hpp"
-#include "resources.hpp"
-#include "unit.hpp"
-#include "unit_map.hpp"
-
-namespace wb
-{
-
-mapbuilder_visitor::mapbuilder_visitor(unit_map& unit_map)
- : unit_map_(unit_map)
- , applied_actions_()
- , resetters_()
- , acted_this_turn_()
-{
-}
-
-mapbuilder_visitor::~mapbuilder_visitor()
-{
- restore_normal_map();
- //Remember that the member variable resetters_ is destructed here
-}
-
-void mapbuilder_visitor::reset_moves()
-{
- int current_side = resources::controller->current_side();
- foreach(unit& u, *resources::units)
- {
- resetters_.push_back(new unit_movement_resetter(u,false));
- //make sure current team's units are not reset to full moves on
first turn
- if(u.side() == current_side)
- acted_this_turn_.insert(&u);
- }
-}
-
-void mapbuilder_visitor::build_map()
-{
- reset_moves();
- visit_all();
-}
-
-bool mapbuilder_visitor::visit(size_t, team&, side_actions&,
side_actions::iterator itor)
-{
- action_ptr act = *itor;
- unit* u = act->get_unit();
-
- if(acted_this_turn_.find(u) == acted_this_turn_.end())
- {
- u->set_movement(u->total_movement());
- acted_this_turn_.insert(u);
- }
- validate(itor);
- if(act->is_valid())
- {
- act->apply_temp_modifier(unit_map_);
- applied_actions_.push_back(act);
- }
- return true;
-}
-
-bool mapbuilder_visitor::post_visit_team(size_t, team&, side_actions&)
- {acted_this_turn_.clear(); return true;}
-
-void mapbuilder_visitor::restore_normal_map()
-{
- //applied_actions_ contain only the actions that we applied to the unit
map
- BOOST_REVERSE_FOREACH(action_ptr act, applied_actions_)
- {
- assert(act->is_valid());
- act->remove_temp_modifier(unit_map_);
- }
-}
-
-} // end namespace wb
Removed: trunk/src/whiteboard/mapbuilder_visitor.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/mapbuilder_visitor.hpp?rev=50863&view=auto
==============================================================================
--- trunk/src/whiteboard/mapbuilder_visitor.hpp (original)
+++ trunk/src/whiteboard/mapbuilder_visitor.hpp (removed)
@@ -1,76 +1,0 @@
-/* $Id$ */
-/*
- Copyright (C) 2010 - 2011 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
- Part of the Battle for Wesnoth Project http://www.wesnoth.org
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY.
-
- See the COPYING file for more details.
- */
-
-/**
- * @file
- */
-
-#ifndef WB_MAPBUILDER_VISITOR_HPP_
-#define WB_MAPBUILDER_VISITOR_HPP_
-
-#include <boost/ptr_container/ptr_vector.hpp>
-
-#include "action.hpp"
-#include "utility.hpp"
-#include "visitor.hpp"
-
-struct unit_movement_resetter;
-
-namespace wb
-{
-
-/**
- * Visitor that collects and applies unit_map modifications from the actions
it visits
- * and reverts all changes on destruction.
- */
-class mapbuilder_visitor
- : private enable_visit_all<mapbuilder_visitor>
-{
- friend class enable_visit_all<mapbuilder_visitor>;
-
-public:
- mapbuilder_visitor(unit_map& unit_map);
- virtual ~mapbuilder_visitor();
-
- ///builds every team's actions as far into the future as possible, in
the correct order
- void build_map();
-
-private:
- //"Inherited" from enable_visit_all
- bool visit(size_t team_index, team&, side_actions&,
side_actions::iterator);
- bool post_visit_team(size_t team_index, team&, side_actions&);
-
- //For validate_visitor to override
- virtual void validate(side_actions::iterator const&) {};
-
- //Helper fcn: Arranges for all units' MP to be restored upon destruction
- void reset_moves();
-
- void restore_normal_map();
-
- unit_map& unit_map_;
-
- action_queue applied_actions_;
-
- //Used by reset_moves()
- boost::ptr_vector<unit_movement_resetter> resetters_;
-
- //Used by visit()
- std::set<unit const*> acted_this_turn_;
-};
-
-}
-
-#endif /* WB_MAPBUILDER_VISITOR_HPP_ */
Modified: trunk/src/whiteboard/validate_visitor.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/validate_visitor.hpp?rev=50864&r1=50863&r2=50864&view=diff
==============================================================================
--- trunk/src/whiteboard/validate_visitor.hpp (original)
+++ trunk/src/whiteboard/validate_visitor.hpp Sat Aug 20 10:05:42 2011
@@ -20,7 +20,7 @@
#ifndef WB_VALIDATE_VISITOR_HPP_
#define WB_VALIDATE_VISITOR_HPP_
-#include "mapbuilder_visitor.hpp"
+#include "mapbuilder.hpp"
#include "side_actions.hpp"
#include <set>
@@ -29,7 +29,7 @@
{
/**
- * Works like mapbuilder_visitor, but with these differences:
+ * Works like mapbuilder, but with these differences:
* * Instead of stopping at viewer_team, it visits all actions of every team.
* * actions are evaluated for validity along the way.
* * Some invalid actions are deleted.
@@ -57,10 +57,10 @@
bool no_previous_invalids(side_actions::iterator const&);
- struct helper: public mapbuilder_visitor
+ struct helper: public mapbuilder
{
helper(unit_map& umap, validate_visitor& parent)
- : mapbuilder_visitor(umap)
+ : mapbuilder(umap)
, parent_(parent)
{}
virtual void validate(side_actions::iterator const& itor);
Modified: trunk/src/whiteboard/visitor.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/visitor.hpp?rev=50864&r1=50863&r2=50864&view=diff
==============================================================================
--- trunk/src/whiteboard/visitor.hpp (original)
+++ trunk/src/whiteboard/visitor.hpp Sat Aug 20 10:05:42 2011
@@ -24,7 +24,7 @@
* mechanism for the double dispatch used in the Visitor Pattern:
* action.accept(visitor) calls visitor.visit_***(action)
* Derived classes will usually derive from both of these.
- * Example usage is seen is highlight_visitor, mapbuilder_visitor,
validate_visitor.
+ * Example usage is seen is highlight_visitor and mapbuilder.
*/
#ifndef WB_VISITOR_HPP_
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits