fixed bug with ai::move_result::is_gamestatus_changed()...

...being incorrectly set, fixed bug with moving (via formula_ai) to
unavailable location triggering an assertion failure during ai move
This commit is contained in:
Iurii Chernyi 2009-08-10 13:55:23 +00:00
parent 650c4f80d2
commit 7f2ca85595
2 changed files with 13 additions and 1 deletions

View file

@ -399,6 +399,10 @@ bool move_result::test_route(const unit &un, const team &my_team, const unit_map
//do an A*-search
route_ = a_star_search(un.get_location(), to_, 10000.0, &calc, map.w(), map.h(), &allowed_teleports);
if (route_.steps.empty()) {
set_error(E_NO_ROUTE);
return false;
}
return true;//@todo 1.7 do some tests on returned route
}
@ -491,7 +495,14 @@ void move_result::do_execute()
/*bool should_clear_shroud*/ true,
/*bool is_replay*/ false);
set_gamestate_changed();
if ( move_spectator.get_ambusher().valid() || !move_spectator.get_seen_enemies().empty() || !move_spectator.get_seen_friends().empty() ) {
set_gamestate_changed();
} else if (move_spectator.get_unit().valid()){
unit_location_ = move_spectator.get_unit()->first;
if (unit_location_ != from_) {
set_gamestate_changed();
}
}
} else {
assert(remove_movement_);
}

View file

@ -174,6 +174,7 @@ public:
static const int E_AMBUSHED = 2005;
static const int E_FAILED_TELEPORT = 2006;
static const int E_NOT_REACHED_DESTINATION = 2007;
static const int E_NO_ROUTE = 2008;
virtual std::string do_describe() const;
virtual const map_location& get_unit_location() const;
protected: