[freeciv-ai] Re: (PR#6567) AI has too many boats.
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=6567 >
It looks like there's nothing to stop us from looking into cities we
don't own. Maybe the PF takes care of this, but can you at least add an
assertion?
jason
Gregory Berkolaiko wrote:
> + /* We want to consider the place we are currently in too, hence the
> + * do-while loop */
> + do {
> + struct pf_position pos;
> + struct city *pcity;
> +
> + pf_next_get_position(map, &pos);
> +
> + pcity = map_get_city(pos.x, pos.y);
> +
> + if (pcity
> + && (pcity->ai.choice.need_boat
> + || (pcity->is_building_unit
> + && unit_has_role(pcity->currently_building, L_FERRYBOAT)))) {
> + bool really_needed = TRUE;
> +
> + UNIT_LOG(LOGLEVEL_FERRY, pferry, "%s (%d, %d) looks promising, "
> + "checking if it has other ferries already",
> + pcity->name, pcity->x, pcity->y);
> + unit_list_iterate(map_get_tile(pos.x, pos.y)->units, aunit) {
> + if (aunit != pferry && unit_owner(aunit) == unit_owner(pferry)
> + && unit_has_role(aunit->id, L_FERRYBOAT)) {
> +
> + UNIT_LOG(LOGLEVEL_FERRY, pferry, "%s (%d, %d) doesn't "
> + "really want us", pcity->name, pcity->x, pcity->y);
> + really_needed = FALSE;
> + break;
> + }
> + } unit_list_iterate_end;
> +
> + if (really_needed) {
> + set_goto_dest(pferry, pos.x, pos.y);
> + pf_destroy_map(map);
> + return TRUE;
> + }
> + }
> + } while (pf_next(map));
> +
> + UNIT_LOG(LOGLEVEL_FERRY, pferry, "Ferry didn't find an interested city");
> + pf_destroy_map(map);
> + return FALSE;
> +}
|
|