Author: dfranke
Date: Sun Mar 29 09:31:11 2009
New Revision: 34226
URL: http://svn.gna.org/viewcvs/wesnoth?rev=34226&view=rev
Log:
Port r34225 (bug #13280) to 1.6
Modified:
branches/1.6/src/formula_ai.cpp
Modified: branches/1.6/src/formula_ai.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/branches/1.6/src/formula_ai.cpp?rev=34226&r1=34225&r2=34226&view=diff
==============================================================================
--- branches/1.6/src/formula_ai.cpp (original)
+++ branches/1.6/src/formula_ai.cpp Sun Mar 29 09:31:11 2009
@@ -380,10 +380,26 @@
int weapon;
if (args().size() > 3) weapon =
args()[3]->evaluate(variables).as_int();
else weapon = -1;
+
+ map_location attacker_location =
+
convert_variant<location_callable>(args()[0]->evaluate(variables))->loc();
+ if(ai_.get_info().units.count(attacker_location) == 0) {
+ ERR_AI << "Performing calculate_outcome() with
non-existent attacker at (" <<
+ attacker_location.x+1 << "," <<
attacker_location.y+1 << ")\n";
+ return variant();
+ }
+
+ map_location defender_location =
+
convert_variant<location_callable>(args()[2]->evaluate(variables))->loc();
+ if(ai_.get_info().units.count(defender_location) == 0) {
+ ERR_AI << "Performing calculate_outcome() with
non-existent defender at (" <<
+ defender_location.x+1 << "," <<
defender_location.y+1 << ")\n";
+ return variant();
+ }
+
battle_context bc(ai_.get_info().map, ai_.get_info().teams,
ai_.get_info().units,
ai_.get_info().state,
convert_variant<location_callable>(args()[1]->evaluate(variables))->loc(),
-
convert_variant<location_callable>(args()[2]->evaluate(variables))->loc(),
weapon, -1, 1.0, NULL,
-
&ai_.get_info().units.find(convert_variant<location_callable>(args()[0]->evaluate(variables))->loc())->second);
+ defender_location, weapon, -1, 1.0, NULL,
&ai_.get_info().units.find(attacker_location)->second);
std::vector<double> hp_dist =
bc.get_attacker_combatant().hp_dist;
std::vector<double>::iterator it = hp_dist.begin();
int i = 0;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits