Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2002:
[Freeciv-Dev] Re: [PATCH] use symbolic types for ai_choice at aicity.c p
Home

[Freeciv-Dev] Re: [PATCH] use symbolic types for ai_choice at aicity.c p

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Markus Linnala <maage@xxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx, bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] use symbolic types for ai_choice at aicity.c part 2 (PR#1315)
From: Petr Baudis <pasky@xxxxxxxxxxx>
Date: Mon, 11 Mar 2002 10:59:35 +0100

Dear diary, on Sun, Mar 10, 2002 at 05:27:54PM CET, I got a letter,
where Markus Linnala <maage@xxxxxxxxx> told me, that...
> 
> Use CT_* instead of ints.
> 
> This is on top of: '[PATCH] use symbolic types for ai_choice at aicity.c'
> 
> --- freeciv-ct-none/ai/aicity.c_old   Sun Mar 10 18:17:37 2002
> +++ freeciv-ct-none/ai/aicity.c       Sun Mar 10 18:24:59 2002
> @@ -437,7 +437,7 @@
>              pplayer->ai.maxbuycost < 100) pplayer->ai.maxbuycost = 100;
>        }
>  #ifdef GRAVEDANGERWORKS
> -      else if (bestchoice.type == 3 && pcity->size == 1 &&
> +      else if (bestchoice.type == CT_DEFENDER && pcity->size == 1 &&

it's not used and probably never be, but it's still nice anyway ;)

>          pcity->ai.grave_danger > (assess_defense_quadratic(pcity) +
>    ai_city_defender_value(pcity, U_LEGION, bestchoice.choice)) * 2 &&
>                 pcity->food_stock + pcity->food_surplus < 10) { /* We're 
> DOOMED */
> @@ -453,13 +453,13 @@
>                                   && assess_defense(pcity) == 0)) {
>         really_handle_city_buy(pplayer, pcity); /* adequately tested now */
>       }
> -      } else if (bestchoice.type != 0 || !is_wonder(bestchoice.choice)) {
> +      } else if (bestchoice.type != CT_NONE || 
> !is_wonder(bestchoice.choice)) {
>       freelog(LOG_DEBUG, "%s wants %s but can't afford to buy it"
>                     " (%d < %d).", pcity->name,
> -                   (bestchoice.type != 0 ? unit_name(bestchoice.choice)
> +                   (bestchoice.type != CT_NONE ? unit_name(bestchoice.choice)
>                      : get_improvement_name(bestchoice.choice)),
>                     pplayer->economic.gold, buycost);
> -        if (bestchoice.type != 0 && !unit_type_flag(bestchoice.choice, 
> F_NONMIL)) {
> +        if (bestchoice.type != CT_NONE && !unit_type_flag(bestchoice.choice, 
> F_NONMIL)) {
>            if (pcity->ai.grave_danger != 0 && assess_defense(pcity) == 0) { 
> /* oh dear */
>              try_to_sell_stuff(pplayer, pcity);
>              if ((pplayer->economic.gold-pplayer->ai.est_upkeep) >= buycost)

I like it.

-- 

                                Petr "Pasky" Baudis

* elinks maintainer                * IPv6 guy (XS26 co-coordinator)
* IRCnet operator                  * FreeCiv AI hacker
.
"If you have acquired knowledge, what do you lack?
    If you lack knowledge, what have you acquired?"
Lev. R. 1:6
.
Public PGP key && geekcode && homepage: http://pasky.ji.cz/~pasky/


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