marked_route now keeps an internal plain_route...

...and directly exposes its 'steps' and 'move_cost' variables.
This commit is contained in:
Gabriel Morin 2010-07-22 00:31:40 +00:00
parent e4186a3b11
commit 3edcc8486f
2 changed files with 36 additions and 12 deletions

View file

@ -388,7 +388,7 @@ pathfind::marked_route pathfind::mark_route(const plain_route &rt,
marked_route res;
if (rt.steps.empty()) return res;
res.steps = rt.steps;
res.route = rt;
int turns = 0;
int movement = u.movement_left();

View file

@ -112,15 +112,43 @@ struct paths
dest_vect destinations;
};
/** Structure which holds a single route between one location and another. */
struct plain_route
{
plain_route() : steps(), move_cost(0) {}
std::vector<map_location> steps;
/** Movement cost for reaching the end of the route. */
int move_cost;
};
/** Structure which holds a single route and marks for special events. */
struct marked_route
{
marked_route()
: steps()
: route()
, steps(route.steps)
, move_cost(route.move_cost)
, marks()
{
}
marked_route(const marked_route& rhs)
: route(rhs.route)
, steps(route.steps)
, move_cost(route.move_cost)
, marks(rhs.marks)
{
}
marked_route& operator=(const marked_route& rhs)
{
this->route = rhs.route;
this->steps = this->route.steps;
this->move_cost = this->route.move_cost;
this->marks = rhs.marks;
return *this;
}
struct mark
{
mark(int turns_number = 0, bool pass = false, bool in_zoc = false,
@ -134,17 +162,13 @@ struct marked_route
bool invisible;
};
typedef std::map<map_location, mark> mark_map;
std::vector<map_location> steps;
mark_map marks;
};
plain_route route;
/** Structure which holds a single route between one location and another. */
struct plain_route
{
plain_route() : steps(), move_cost(0) {}
std::vector<map_location> steps;
/** Movement cost for reaching the end of the route. */
int move_cost;
//make steps and move_cost of the underlying plain_route directly accessible
std::vector<map_location>& steps;
int& move_cost;
mark_map marks;
};
plain_route a_star_search(map_location const &src, map_location const &dst,