Author: tschmitz
Date: Sat Aug 20 09:57:49 2011
New Revision: 50863
URL: http://svn.gna.org/viewcvs/wesnoth?rev=50863&view=rev
Log:
Fixed movement left when planning a move to a village or into an enemy zoc hex.
Modified:
trunk/src/whiteboard/utility.cpp
Modified: trunk/src/whiteboard/utility.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/utility.cpp?rev=50863&r1=50862&r2=50863&view=diff
==============================================================================
--- trunk/src/whiteboard/utility.cpp (original)
+++ trunk/src/whiteboard/utility.cpp Sat Aug 20 09:57:49 2011
@@ -125,14 +125,18 @@
int path_cost(std::vector<map_location> const& path, unit const& u)
{
- assert(!path.empty());
+ if(path.size() < 2)
+ return 0;
+
+ map_location const& dest = path.back();
+ if((resources::game_map->is_village(dest) &&
!resources::teams->at(u.side()-1).owns_village(dest))
+ ||
pathfind::enemy_zoc(*resources::teams,dest,resources::teams->at(u.side()-1),u.side()))
+ return u.total_movement();
int result = 0;
gamemap const& map = *resources::game_map;
-
foreach(map_location const& loc,
std::make_pair(path.begin()+1,path.end()))
result += u.movement_cost(map[loc]);
-
return result;
}
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits