Author: alink
Date: Fri Mar 21 05:54:52 2008
New Revision: 24925
URL: http://svn.gna.org/viewcvs/wesnoth?rev=24925&view=rev
Log:
Remove the unused special pathfinding cost for destination. The only place
where still used (finish a move in ZoC) was made incorrect since a long time.
This make function calls simpler and it's easy to add again if a new
pathfinding feature need it.
Modified:
trunk/src/astarsearch.cpp
trunk/src/cavegen.cpp
trunk/src/mapgen.cpp
trunk/src/pathfind.cpp
trunk/src/pathfind.hpp
Modified: trunk/src/astarsearch.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/astarsearch.cpp?rev=24925&r1=24924&r2=24925&view=diff
==============================================================================
--- trunk/src/astarsearch.cpp (original)
+++ trunk/src/astarsearch.cpp Fri Mar 21 05:54:52 2008
@@ -108,7 +108,7 @@
if (locLocation.valid(int(parWidth), int(parHeight)) == false)
continue;
locNextNode = aStarGameWorld.getNodeFromLocation(locLocation,
locIsCreated);
- locCost = locCostFather +
costCalculator->cost(parCurNode->loc,locLocation, locCostFather, locLocation ==
dst);
+ locCost = locCostFather +
costCalculator->cost(parCurNode->loc,locLocation, locCostFather);
if (locIsCreated) {
locNextNode->initNode(locLocation, dst, locCost,
parCurNode, teleports);
if (locNextNode->g + locNextNode->h < stop_at) {
@@ -161,7 +161,7 @@
DBG_PF << "A* search: " << src << " -> " << dst << '\n';
- if (costCalculator->cost(src,dst, 0, true) >= stop_at) {
+ if (costCalculator->cost(src,dst, 0) >= stop_at) {
LOG_PF << "aborted A* search because Start or Dest is
invalid\n";
locRoute.move_left = int(costCalculator->getNoPathValue());
return locRoute;
Modified: trunk/src/cavegen.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/cavegen.cpp?rev=24925&r1=24924&r2=24925&view=diff
==============================================================================
--- trunk/src/cavegen.cpp (original)
+++ trunk/src/cavegen.cpp Fri Mar 21 05:54:52 2008
@@ -293,7 +293,7 @@
map_(mapdata), wall_(wall), laziness_(laziness),
windiness_(windiness)
{}
- virtual double cost(const gamemap::location& src,const
gamemap::location& loc, const double so_far, const bool is_dest) const;
+ virtual double cost(const gamemap::location& src,const
gamemap::location& loc, const double so_far) const;
private:
const t_translation::t_map& map_;
t_translation::t_terrain wall_;
@@ -301,7 +301,7 @@
size_t windiness_;
};
-double passage_path_calculator::cost(const gamemap::location& /*src*/,const
gamemap::location& loc, const double, const bool) const
+double passage_path_calculator::cost(const gamemap::location& /*src*/,const
gamemap::location& loc, const double) const
{
assert(loc.x >= 0 && loc.y >= 0 && size_t(loc.x) < map_.size() &&
!map_.empty() && size_t(loc.y) < map_.front().size());
Modified: trunk/src/mapgen.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mapgen.cpp?rev=24925&r1=24924&r2=24925&view=diff
==============================================================================
--- trunk/src/mapgen.cpp (original)
+++ trunk/src/mapgen.cpp Fri Mar 21 05:54:52 2008
@@ -366,7 +366,7 @@
// Find out how windy roads should be.
windiness_(maximum<int>(1,atoi(cfg["road_windiness"].c_str()))),
seed_(rand()) {}
- virtual double cost(const location& src, const location& loc, const
double so_far, const bool isDst) const;
+ virtual double cost(const location& src, const location& loc, const
double so_far) const;
mutable int calls;
private:
@@ -378,7 +378,7 @@
};
double road_path_calculator::cost(const location& /*src*/, const location& loc,
- const double /*so_far*/, const bool /*isDst*/) const
+ const double /*so_far*/) const
{
++calls;
if (loc.x < 0 || loc.y < 0 || loc.x >= static_cast<long>(map_.size()) ||
@@ -1015,7 +1015,7 @@
continue;
}
- if (calc.cost(src,src, 0.0, false) >= 1000.0 ||
calc.cost(src,dst, 0.0, true) >= 1000.0) {
+ if (calc.cost(src,src, 0.0) >= 1000.0 || calc.cost(src,dst,
0.0) >= 1000.0) {
continue;
}
Modified: trunk/src/pathfind.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind.cpp?rev=24925&r1=24924&r2=24925&view=diff
==============================================================================
--- trunk/src/pathfind.cpp (original)
+++ trunk/src/pathfind.cpp Fri Mar 21 05:54:52 2008
@@ -288,7 +288,7 @@
{
}
-double shortest_path_calculator::cost(const gamemap::location& /*src*/,const
gamemap::location& loc, const double so_far, const bool isDst) const
+double shortest_path_calculator::cost(const gamemap::location& /*src*/,const
gamemap::location& loc, const double so_far) const
{
assert(map_.on_board(loc));
@@ -336,11 +336,7 @@
if (need_new_turn)
cost += remaining_movement;
- // FIXME: The isDist check is obsolete and introduce a little
inaccurancy.
- // It comes trom the time when we returned getNoPathValue() in ZoC
- // But pathfinding calls with a small maximum path length
- // (like some AI stuff do) maybe rely on this.
- if (!isDst && enemy_zoc(map_,units_,teams_, loc, viewing_team_,
unit_.side())
+ if (enemy_zoc(map_,units_,teams_, loc, viewing_team_, unit_.side())
&& !unit_.get_ability_bool("skirmisher", loc)) {
// Should cost us remaining movement.
// return getNoPathValue();
@@ -358,7 +354,7 @@
{
}
-double emergency_path_calculator::cost(const gamemap::location&,const
gamemap::location& loc, const double, const bool) const
+double emergency_path_calculator::cost(const gamemap::location&,const
gamemap::location& loc, const double) const
{
assert(map_.on_board(loc));
Modified: trunk/src/pathfind.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind.hpp?rev=24925&r1=24924&r2=24925&view=diff
==============================================================================
--- trunk/src/pathfind.hpp (original)
+++ trunk/src/pathfind.hpp Fri Mar 21 05:54:52 2008
@@ -75,7 +75,7 @@
struct cost_calculator
{
- virtual double cost(const gamemap::location& src, const
gamemap::location& loc, const double so_far, const bool isDst) const = 0;
+ virtual double cost(const gamemap::location& src, const
gamemap::location& loc, const double so_far) const = 0;
virtual ~cost_calculator() {}
inline double getNoPathValue(void) const { return (42424242.0); }
};
@@ -142,7 +142,7 @@
shortest_path_calculator(const unit& u, const team& t,
const unit_map& units, const
std::vector<team>& teams,
const gamemap& map);
- virtual double cost(const gamemap::location& src, const
gamemap::location& loc, const double so_far, const bool isDst) const;
+ virtual double cost(const gamemap::location& src, const
gamemap::location& loc, const double so_far) const;
private:
unit const &unit_;
@@ -159,7 +159,7 @@
struct emergency_path_calculator : cost_calculator
{
emergency_path_calculator(const unit& u, const gamemap& map);
- virtual double cost(const gamemap::location& src, const
gamemap::location& loc, const double so_far, const bool isDst) const;
+ virtual double cost(const gamemap::location& src, const
gamemap::location& loc, const double so_far) const;
private:
unit const &unit_;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits