Author: dragonking
Date: Sun Oct 12 23:37:15 2008
New Revision: 30103

URL: http://svn.gna.org/viewcvs/wesnoth?rev=30103&view=rev
Log:
Error handling for shortest_path formula function

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=30103&r1=30102&r2=30103&view=diff
==============================================================================
--- trunk/src/formula_ai.cpp (original)
+++ trunk/src/formula_ai.cpp Sun Oct 12 23:37:15 2008
@@ -474,6 +474,12 @@
                const gamemap::location dst = 
convert_variant<location_callable>(args()[1]->evaluate(variables))->loc();
 
                unit_map::iterator unit_it = ai_.get_info().units.find(src);
+               if( unit_it == ai_.get_info().units.end() ) {
+                       std::ostringstream str;
+                       str << "shortest_path function: expected unit at 
location (" << (src.x+1) << "," << (src.y+1) << ")";
+                       throw formula_error( str.str(), "", "", 0);
+               }
+
                if( (ai_.get_possible_moves().count(src) > 0) ) {
                        std::map<gamemap::location,paths>::const_iterator path 
= ai_.get_possible_moves().find(src);
 
@@ -1575,7 +1581,7 @@
                                if(unit != get_info().units.end()) {
                                        unit->second.set_movement(0);
                                } else {
-                                       throw formula_error("Incorrect result 
of calling the move() formula", "", "", 0);;
+                                       throw formula_error("Incorrect result 
of calling the move() formula", "", "", 0);
                                }
                                made_move = true;
                        }


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to