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

[Freeciv-Dev] Re: [PATCH] split-up of caravan capabilities

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: gregor@xxxxxxxxxxxxx
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [PATCH] split-up of caravan capabilities
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Sun, 16 Dec 2001 12:18:02 +0100

Dear diary, on Sat, Dec 15, 2001 at 09:06:26PM CET, I got a letter,
where Gregor Zeitlinger <zeitling@xxxxxxxxxxxxxxxxxxxxxxx> told me, that...
> diff -ruN -X mod/diff_ignore 20011215-1800/ai/advdomestic.c 
> mod/ai/advdomestic.c
> --- 20011215-1800/ai/advdomestic.c    Sat Dec 15 19:09:44 2001
> +++ mod/ai/advdomestic.c      Sat Dec 15 20:26:49 2001
> @@ -243,7 +243,8 @@
>        if (!unit_type_flag(acity->currently_building, F_NONMIL) &&
>            unit_types[acity->currently_building].move_type == LAND_MOVING)
>          j += prod;
> -      else if (unit_type_flag(acity->currently_building, F_CARAVAN) &&
> +      else if ((unit_type_flag(acity->currently_building, F_TRADE_ROUTE) ||
> +                unit_type_flag(acity->currently_building, F_HELP_WONDER)) &&
shouldn't this be only F_HELP_WONDER?
>          built_elsewhere(acity, B_SUNTZU)) j += prod; /* this also stops 
> flip-flops */
>      } else if (acity->currently_building == B_BARRACKS || /* this stops 
> flip-flops */
>               acity->currently_building == B_BARRACKS2 ||
> @@ -599,12 +600,13 @@
>    }
>  
>    unit_list_iterate(pplayer->units, punit)
> -    if (unit_flag(punit, F_CARAVAN) &&
> +    if ((unit_flag(punit, F_TRADE_ROUTE) || unit_flag(punit, F_HELP_WONDER)) 
> &&
ditto - we only use [cara]vans variable in code where we check if some wonder
city doesn't need help
>          map_get_continent(punit->x, punit->y) == con) vans++;
>    unit_list_iterate_end;
>    city_list_iterate(pplayer->cities, acity)
>      if (acity->is_building_unit && acity->shield_stock >= 50 &&
> -        unit_type_flag(acity->currently_building, F_CARAVAN) &&
> +       (unit_type_flag(acity->currently_building, F_TRADE_ROUTE) ||
> +        unit_type_flag(acity->currently_building, F_HELP_WONDER)) &&
ditto
>          map_get_continent(acity->x, acity->y) == con) vans++;
>    city_list_iterate_end;
>  
> @@ -617,18 +619,18 @@
>  /* if we just started building a wonder during a_c_c_b, the started_building 
> */
>  /* notify comes equipped with an update.  It calls generate_warmap, but this 
> */
>  /* is a lot less warmap generation than there would be otherwise. -- Syela */
> -      iunit = best_role_unit(pcity, F_CARAVAN);
> +      iunit = best_role_unit(pcity, F_HELP_WONDER);
>        dw = pcity->ai.distance_to_wonder_city * 8 /
>       ((iunit==U_LAST) ? SINGLE_MOVE : get_unit_type(iunit)->move_rate);
>        want -= dw;
>        /* value of 8 is a total guess and could be wrong,
>         * but it's better than 0 -- Syela */
> -      iunit = get_role_unit(F_CARAVAN, 0);
> +      iunit = get_role_unit(F_HELP_WONDER, 0);
>        if (can_build_unit_direct(pcity, iunit)) {
>          if (want > choice->want) {
>            choice->want = want;
>            choice->type = CT_NONMIL;
> -       ai_choose_role_unit(pplayer, pcity, choice, F_CARAVAN, dw/2);
> +       ai_choose_role_unit(pplayer, pcity, choice, F_HELP_WONDER, dw/2);
>          }
>        } else
>       pplayer->ai.tech_want[get_unit_type(iunit)->tech_requirement] += want;
> @@ -646,7 +648,7 @@
>  /* allowing buy of peaceful units after much testing -- Syela */
>  
>    if (!choice->want) { /* oh dear, better think of something! */
> -    iunit = best_role_unit(pcity, F_CARAVAN);
> +    iunit = best_role_unit(pcity, F_HELP_WONDER);
F_TRADE_ROUTE maybe here rather 
>      if (iunit == U_LAST) {
>        iunit = best_role_unit(pcity, F_DIPLOMAT);
>        /* someday, real diplomat code will be here! */
> diff -ruN -X mod/diff_ignore 20011215-1800/ai/advmilitary.c 
> mod/ai/advmilitary.c
> --- 20011215-1800/ai/advmilitary.c    Sat Dec 15 19:09:44 2001
> +++ mod/ai/advmilitary.c      Sat Dec 15 19:59:48 2001
> @@ -1086,7 +1086,7 @@
>    if (!pcity->is_building_unit && is_wonder(pcity->currently_building))
>      wondercity = map_get_continent(pcity->x, pcity->y);
>    else wondercity = 0;
> -  freight = best_role_unit(pcity, F_CARAVAN);
> +  freight = best_role_unit(pcity, F_TRADE_ROUTE);
are you sure?
>    moverate = (freight==U_LAST) ? SINGLE_MOVE : 
> get_unit_type(freight)->move_rate;
>  
>    pcity->ai.downtown = 0;
> diff -ruN -X mod/diff_ignore 20011215-1800/ai/aicity.c mod/ai/aicity.c
> --- 20011215-1800/ai/aicity.c Sat Dec 15 19:09:44 2001
> +++ mod/ai/aicity.c   Sat Dec 15 19:53:48 2001
> @@ -84,7 +84,7 @@
>    Unit_Type_id i;
>  
>    if (is_building_other_wonder(pcity)) {
> -    i = best_role_unit(pcity, F_CARAVAN);
> +    i = best_role_unit(pcity, F_HELP_WONDER);
unused ;)
>      if (i < U_LAST) {
>        ai_do_build_unit(pcity, i);
>        return 1;
> @@ -420,7 +420,8 @@
>           pcity->food_stock < city_granary_size(pcity->size-1))) ;
>        else if (bestchoice.type && bestchoice.type < 3 && /* not a defender */
>          buycost > unit_types[bestchoice.choice].build_cost * 2) { /* too 
> expensive */
> -        if (unit_type_flag(bestchoice.choice, F_CARAVAN) &&
> +        if ((unit_type_flag(bestchoice.choice, F_TRADE_ROUTE) ||
> +             unit_type_flag(bestchoice.choice, F_HELP_WONDER)) &&
>              pplayer->ai.maxbuycost < 100) pplayer->ai.maxbuycost = 100;
>        }
>  #ifdef GRAVEDANGERWORKS
> @@ -458,7 +459,8 @@
>  /* possibly upgrade units here */
>          } /* end panic subroutine */
>          if (is_unit_choice_type(bestchoice.type) &&
> -            unit_type_flag(bestchoice.choice, F_CARAVAN)) {
> +            (unit_type_flag(bestchoice.choice, F_TRADE_ROUTE) ||
> +             unit_type_flag(bestchoice.choice, F_HELP_WONDER))) {
>            if (buycost > pplayer->ai.maxbuycost)
>              pplayer->ai.maxbuycost = buycost;
>  /* Gudy reminded me AI was slow to build wonders, I thought of the above -- 
> Syela */
> diff -ruN -X mod/diff_ignore 20011215-1800/ai/aiunit.c mod/ai/aiunit.c
> --- 20011215-1800/ai/aiunit.c Sat Dec 15 19:09:44 2001
> +++ mod/ai/aiunit.c   Sat Dec 15 20:29:53 2001
> @@ -272,7 +272,8 @@
>         && can_unit_move_to_tile_with_notify(punit, x1, y1, 0)
>         && !((pcity = map_get_city(x1,y1))
>              && (unit_flag(punit, F_DIPLOMAT)
> -                || unit_flag(punit, F_CARAVAN)))
> +                || unit_flag(punit, F_TRADE_ROUTE)   
> +                || unit_flag(punit, F_HELP_WONDER)))
we should travel to another city with  F_HELP_WONDER unit only if a wonder
is actually building there
>         && !(is_barbarian(pplayer) && map_get_special(x1, y1) & S_HUT)) {
>       most_unknown = unknown;
>       best_x = x1;
> @@ -1386,7 +1387,8 @@
>        unit_list_iterate(aplayer->units, aunit)
>          if (map_get_city(aunit->x, aunit->y)) continue; /* already dealt 
> with it */
>          if (handicap && !map_get_known(aunit->x, aunit->y, pplayer)) 
> continue;
> -        if (unit_flag(aunit, F_CARAVAN) && !punit->id) continue; /* kluge */
> +        if ((unit_flag(aunit, F_TRADE_ROUTE) || unit_flag(aunit, 
> F_HELP_WONDER))
> +            && !punit->id) continue; /* kluge */
>          if (ai_fuzzy(pplayer,1) &&
>           (aunit == get_defender(punit, aunit->x, aunit->y) &&
>             ((is_ground_unit(punit) &&
> @@ -1864,7 +1866,7 @@
>      if (!punit->moves_left) return; /* can't do anything with no moves */
>      ai_manage_settler(pplayer, punit);
>      return;
> -  } else if (unit_flag(punit, F_CARAVAN)) {
> +  } else if (unit_flag(punit, F_TRADE_ROUTE) || unit_flag(punit, 
> F_HELP_WONDER)) {
hey! you should  really deal differently with F_TRADE_ROUTE and F_HELP_WONDER
in ai_manage_caravan(), like:
-    if ((pcity = wonder_on_continent(pplayer, map_get_continent(punit->x, 
punit->y))) &&
+    if (unit_flag(punit, F_HELP_WONDER) && (pcity = 
wonder_on_continent(pplayer, map_get_continent(punit->x, punit->y))) &&
         build_points_left(pcity) > (pcity->shield_surplus*2)) {
...
-    else {
+    else if (unit_flag(punit, F_TRADE_WONDER)) {
...
>      ai_manage_caravan(pplayer, punit);
>      return;
>    } else if (unit_has_role(punit->type, L_BARBARIAN_LEADER)) {

-- 

                                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]