Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2001:
[Freeciv-Dev] Re: PATCH split-up of caravan capabilities v2 (PR#1148)
Home

[Freeciv-Dev] Re: PATCH split-up of caravan capabilities v2 (PR#1148)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: PATCH split-up of caravan capabilities v2 (PR#1148)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Wed, 19 Dec 2001 02:28:41 -0800 (PST)

Dear diary, on Tue, Dec 18, 2001 at 11:15:55PM CET, I got a letter,
where Gregor Zeitlinger <zeitling@xxxxxxxxxxxxxxxxxxxxxxx> told me, that...
> @@ -1556,48 +1557,47 @@
>    if (punit->activity != ACTIVITY_IDLE)
>      return;
>    if (punit->ai.ai_role == AIUNIT_NONE) {
> -    if ((pcity = wonder_on_continent(pplayer, map_get_continent(punit->x, 
> punit->y))) &&
> -     build_points_left(pcity) > (pcity->shield_surplus*2)) {
> +    if (pcity = wonder_on_continent(pplayer, map_get_continent(punit->x, 
> punit->y))
> +        && unit_flag(punit, F_HELP_WONDER)
> +        && build_points_left(pcity) > (pcity->shield_surplus*2)) {
>        if (!same_pos(pcity->x, pcity->y, punit->x, punit->y)) {
>          if (!punit->moves_left) return;
> -     auto_settler_do_goto(pplayer,punit, pcity->x, pcity->y);
> +        auto_settler_do_goto(pplayer,punit, pcity->x, pcity->y);
>          handle_unit_activity_request(punit, ACTIVITY_IDLE);
>        } else {
> -      /*
> -       * We really don't want to just drop all caravans in immediately.
> -       * Instead, we want to aggregate enough caravans to build instantly.
> -       * -AJS, 990704
> -       */
> -     req.unit_id = punit->id;
> -     req.city_id = pcity->id;
> -     handle_unit_help_build_wonder(pplayer, &req);
> +        /*
> +         * We really don't want to just drop all caravans in immediately.
> +         * Instead, we want to aggregate enough caravans to build instantly.
> +         * -AJS, 990704
> +         */
> +        req.unit_id = punit->id;
> +        req.city_id = pcity->id;
> +        handle_unit_help_build_wonder(pplayer, &req);
>        }
> -    }
> -     else {
> -       /* A caravan without a home?  Kinda strange, but it might happen.  */
> -       pcity=player_find_city_by_id(pplayer, punit->homecity);
> -       city_list_iterate(pplayer->cities,pdest)
> -         if (pcity
> -             && can_establish_trade_route(pcity, pdest)
> -             && map_get_continent(pcity->x, pcity->y) == 
> map_get_continent(pdest->x, pdest->y)) {
> -           tradeval=trade_between_cities(pcity, pdest);
> -           if (tradeval) {
> -             if (best < tradeval) {
> -               best=tradeval;
> -               best_city=pdest->id;
> -             }
> -           }
> -         }
> -       city_list_iterate_end;
> -       pcity=player_find_city_by_id(pplayer, best_city);
> -       if (pcity) {
> -         if (!same_pos(pcity->x, pcity->y, punit->x, punit->y)) {
> -           if (!punit->moves_left) return;
> -           auto_settler_do_goto(pplayer,punit, pcity->x, pcity->y);
> -         } else {
> -           req.unit_id = punit->id;
> -           req.city_id = pcity->id;
> -           handle_unit_establish_trade(pplayer, &req);
> +    } else {
no way
       } else if (unit_flag(punit, F_TRADE_ROUTE)) {
> +      /* A caravan without a home?  Kinda strange, but it might happen.  */
> +      pcity=player_find_city_by_id(pplayer, punit->homecity);
> +      city_list_iterate(pplayer->cities,pdest) {
> +        if (pcity && can_establish_trade_route(pcity, pdest) &&
> +            map_get_continent(pcity->x, pcity->y) == 
> map_get_continent(pdest->x, pdest->y)) {
> +          tradeval=trade_between_cities(pcity, pdest);
> +          if (tradeval) {
> +            if (best < tradeval) {
> +              best=tradeval;
> +              best_city=pdest->id;
> +            }
> +          }
> +        }
> +      } city_list_iterate_end;
> +      pcity=player_find_city_by_id(pplayer, best_city);
> +      if (pcity) {
> +        if (!same_pos(pcity->x, pcity->y, punit->x, punit->y)) {
> +          if (!punit->moves_left) return;
> +          auto_settler_do_goto(pplayer,punit, pcity->x, pcity->y);
> +        } else {
> +          req.unit_id = punit->id;
> +          req.city_id = pcity->id;
> +          handle_unit_establish_trade(pplayer, &req);
>          }
>        }
>      }

otherwise AI part looks fine to me now

-- 

                                Petr "Pasky" Baudis

UN*X programmer, UN*X administrator, hobbies = IPv6, IRC, FreeCiv hacking
.
  "A common mistake that people make, when trying to design
   something completely foolproof is to underestimate the
   ingenuity of complete fools."
     -- Douglas Adams in Mostly Harmless
.
Public PGP key, geekcode and stuff: http://pasky.ji.cz/~pasky/



[Prev in Thread] Current Thread [Next in Thread]