[freeciv-ai] Re: Findjob
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
There is (or was at one time) the concept of (body)guarding a city.
In fact the code below specifically deals with the city case.
It is quite possible that the ids are no longer distinguished, but
ai.charge is (was) not just a unitId, but could also be a cityId.
Cheers,
RossW
=====
At 06:18 PM 02/10/26 +0200, Jordi Negrevernis i Font wrote:
>
>In aiunit.c:ai_military_findjob() there is this code...
>
> if (punit->ai.charge != BODYGUARD_NONE) { /* I am a bodyguard */
> aunit = player_find_unit_by_id(pplayer, punit->ai.charge);
> acity = find_city_by_id(punit->ai.charge);
>
> /* Check if city we are on our way to rescue is still in danger,
> * or unit we should protect is still alive */
> if ((acity && acity->owner == punit->owner && acity->ai.urgency != 0 &&
> acity->ai.danger > assess_defense_quadratic(acity))
> || aunit) {
> if (punit->ai.ai_role != AIUNIT_ESCORT) {
> /* We forgot what we were doing. Incredible! */
> BODYGUARD_LOG(LOG_ERROR, punit, "lost role as bodyguard in
>findjob");
> punit->ai.ai_role = AIUNIT_ESCORT; /* do not use
>ai_unit_new_role() */
> }
> return;
> } else {
> ai_unit_ready(punit);
> }
> }
>
>The 3th line assigns an id of a unit to a city!!!!
>Is this an error?
>
>
>
>
>
>
|
|