mail[Wesnoth-commits] r33228 - /trunk/src/pathfind.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by guillaume . melquiond on March 01, 2009 - 15:23:
Author: silene
Date: Sun Mar  1 15:23:50 2009
New Revision: 33228

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33228&view=rev
Log:
Ensure the AI does not take the longest path when entering a ZOC.

Modified:
    trunk/src/pathfind.cpp

Modified: trunk/src/pathfind.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/pathfind.cpp?rev=33228&r1=33227&r2=33228&view=diff
==============================================================================
--- trunk/src/pathfind.cpp (original)
+++ trunk/src/pathfind.cpp Sun Mar  1 15:23:50 2009
@@ -162,6 +162,8 @@
                if(old_move_left >= new_turns_moves + new_move_left)
                        continue;
 
+               paths::route &src_route = routes[loc];
+
                if (!ignore_units) {
                        // we can not traverse enemies
                        const unit_map::const_iterator unit_it =
@@ -176,13 +178,17 @@
                                        && enemy_zoc(map,units,teams, 
currentloc, viewing_team,u.side(),see_all)
                                        && !u.get_ability_bool("skirmisher", 
currentloc)) {
                                new_move_left = 0;
-                               // Recheck if we already have a better route, 
but now with the ZoC effect
-                               if(old_move_left >= new_turns_moves + 0)
+                               // Recheck if we already have a better route, 
but now with the ZoC effect.
+                               // Since the ZOC is cancelling the remaining 
move points, the game cannot
+                               // notice a difference between a short and a 
long path. So check the path
+                               // length too in case of equality.
+                               if (old_move_left > new_turns_moves + 0 ||
+                                   (old_move_left == new_turns_moves + 0 &&
+                                    old_rt->second.steps.size() <= 
src_route.steps.size() + 1))
                                        continue;
                        }
                }
 
-               paths::route& src_route = routes[loc];
                paths::route& new_route = routes[currentloc];
                new_route.steps = src_route.steps;
                new_route.steps.push_back(loc);




Related Messages


Powered by MHonArc, Updated Sun Mar 01 15:40:19 2009