[Freeciv-Dev] (PR#3535) Return and Recover
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Using pathfinding for the return-to-nearest-city code I write:
struct city *find_nearest_allied_city(struct unit *punit)
{
struct city *pcity = NULL;
if ((pcity = is_allied_city_tile(map_get_tile(punit->x, punit->y),
game.player_ptr))) {
/* We're already on a city - PF doesn't check for this (!). */
return pcity;
}
simple_unit_path_iterator(punit, pos) {
if ((pcity = is_allied_city_tile(map_get_tile(pos.x, pos.y),
game.player_ptr))) {
/* We use break so that the PF map can be destroyed. */
break;
}
} simple_unit_path_iterator_end;
return pcity;
}
Question 1.
Why does simple_unit_path_iterator not iterate over the current location?
Question 2:
Why does this occasionally send units off to some far-away city? For
instance: load the attached test_game.sav.gz, connect as jshort. Focus
the caravel near Ivanic Grad and choose Orders->Return to nearest city
(shift-G). The caravel runs off toward Sibenik. Is this is a bug in
pathfinding or just in the documentation?
jason
test-game.sav.gz
Description: test-game.sav.gz
|
|