mail[Wesnoth-commits] r33855 - /trunk/src/formula_ai.cpp


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

Header


Content

Posted by dragonking on March 19, 2009 - 20:52:
Author: dragonking
Date: Thu Mar 19 20:52:22 2009
New Revision: 33855

URL: http://svn.gna.org/viewcvs/wesnoth?rev=33855&view=rev
Log:
Patch by Crab - fixed bug #13218

Modified:
    trunk/src/formula_ai.cpp

Modified: trunk/src/formula_ai.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/formula_ai.cpp?rev=33855&r1=33854&r2=33855&view=diff
==============================================================================
--- trunk/src/formula_ai.cpp (original)
+++ trunk/src/formula_ai.cpp Thu Mar 19 20:52:22 2009
@@ -1901,15 +1901,22 @@
                                 map_location destination = 
path_calculator(move->src(), move->dst(), unit_it);
 
                                 if( destination != map_location()) {
-                                    move_unit(move->src(), destination, 
possible_moves_);
-                                    unit_map::iterator unit = 
get_info().units.find(destination);
-                                    if(unit != get_info().units.end()) {
-                                            unit->second.set_movement(0);
+                                    map_location new_location = 
move_unit(move->src(), destination, possible_moves_);
+                                    if ( (new_location != move->src()) || 
(move->src()==move->dst()) ){
+                                        unit_map::iterator unit = 
get_info().units.find(new_location);
+
+                                        if(unit != get_info().units.end()) {
+                                                unit->second.set_movement(0);
+                                        } else {
+                                                throw 
formula_error("Incorrect result of calling the move() formula", "", "", 0);
+                                        }
+                                        
+                                        LOG_AI << "MOVE: " << move->src().x 
<< "," << move->src().y << " -> " << move->dst().x << "," << move->dst().y << 
"\n";
+                                        made_move = true;
+                                        
                                     } else {
-                                            throw formula_error("Incorrect 
result of calling the move() formula", "", "", 0);
+                                           ERR_AI << "IMPOSSIBLE MOVE ORDER 
- MOVE FAILED\n";
                                     }
-                                    LOG_AI << "MOVE: " << move->src().x << 
"," << move->src().y << " -> " << move->dst().x << "," << move->dst().y << 
"\n";
-                                    made_move = true;
                                 } else
                                     ERR_AI << "IMPOSSIBLE MOVE ORDER\n";
                        }




Related Messages


Powered by MHonArc, Updated Thu Mar 19 21:20:16 2009