Author: shadowmaster
Date: Sat Nov 1 18:49:53 2008
New Revision: 30508
URL: http://svn.gna.org/viewcvs/wesnoth?rev=30508&view=rev
Log:
* Fix an assertion failure caused by doing [move_unit_fake] with
unit_types that cannot pass over terrains that are part of a explicit
path given.
Modified:
trunk/src/game_events.cpp
trunk/src/pathfind.cpp
trunk/src/pathfind.hpp
Modified: trunk/src/game_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_events.cpp?rev=30508&r1=30507&r2=30508&view=diff
==============================================================================
--- trunk/src/game_events.cpp (original)
+++ trunk/src/game_events.cpp Sat Nov 1 18:49:53 2008
@@ -919,7 +919,15 @@
route = a_star_search(src, dst, 10000,
&calc,
game_map->w(),
game_map->h());
- assert(route.steps.size() > 0);
+ if(route.steps.size() == 0) {
+ // This would occur when trying
to do a MUF of a unit
+ // over locations which are
unreachable to it (infinite movement
+ // costs). This really cannot
fail.
+ WRN_NG << "Could not find
move_unit_fake route from " << src << " to " << dst << ": ignoring terrain\n";
+ dummy_path_calculator
calc(dummy_unit, *game_map);
+ route = a_star_search(src, dst,
10000, &calc, game_map->w(), game_map->h());
+ assert(route.steps.size() > 0);
+ }
}
unit_display::move_unit(route.steps,
dummy_unit, *teams);
Modified: trunk/src/pathfind.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind.cpp?rev=30508&r1=30507&r2=30508&view=diff
==============================================================================
--- trunk/src/pathfind.cpp (original)
+++ trunk/src/pathfind.cpp Sat Nov 1 18:49:53 2008
@@ -383,6 +383,15 @@
return unit_.movement_cost(map_[loc]);
}
+dummy_path_calculator::dummy_path_calculator(const unit&, const gamemap&)
+{
+}
+
+double dummy_path_calculator::cost(const map_location&, const map_location&,
const double) const
+{
+ return 0.0;
+}
+
std::ostream& operator << (std::ostream& outstream, const paths::route& rt) {
outstream << "\n[route]\n\tsteps=\"";
bool first_loop = true;
Modified: trunk/src/pathfind.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind.hpp?rev=30508&r1=30507&r2=30508&view=diff
==============================================================================
--- trunk/src/pathfind.hpp (original)
+++ trunk/src/pathfind.hpp Sat Nov 1 18:49:53 2008
@@ -174,4 +174,14 @@
gamemap const &map_;
};
+/**
+ * Function which doesn't take anything into account. Used by
+ * move_unit_fake for the last-chance case.
+ */
+struct dummy_path_calculator : cost_calculator
+{
+ dummy_path_calculator(const unit& u, const gamemap& map);
+ virtual double cost(const map_location& src, const map_location& loc,
const double so_far) const;
+};
+
#endif
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits