Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: [CMA 2.3] A few comments
Home

[Freeciv-Dev] Re: [CMA 2.3] A few comments

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [CMA 2.3] A few comments
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 9 Oct 2001 12:24:31 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Tue, Oct 09, 2001 at 02:26:13AM -0700, Raahul Kumar wrote:
> 
> #define MAX_CITY_SIZE                                 30
> 
> In Freeciv cities can reach city size 35. Make it 40 to be on the safe side.

No problem.

> #define MAX_CMAS              (4*6+4)
> Order of precedence, I do not know whether C multiplies or adds first, in 
> maths
> multiplication is done first so result is ((4*6)+4)) = 28. Regardless, just 
> add
> brackets to make intent clear.

C follows the maths way here. IMHO is/should be clear and no brackets
were needed.

> Why these numbers in particular multiplied
> together? Do they come from somewhere? Comments please.

NUM_STATS * 3 (for max. stat, +2 stat and max. stat with out gold
limit) + 6 (+1 food ... +6 food) + 4 (max all, save, max food+prod,
max food+prod+trade).

> static const char *const get_city_growth_string(struct city *pcity,
> +                                             int surplus)
> +{
> +  int stock, cost, turns;
> +  static char buffer[50];
> +
> +  if (surplus == 0) {
> +    my_snprintf(buffer, sizeof(buffer), N_("never"));
> +    return buffer;
> +  }
> +
> +  stock = pcity->food_stock;
> +  cost = city_granary_size(pcity->size);
> +
> +  stock += surplus;
> +
> +  if (stock >= cost) {
> +    turns = 1;
> +  } else if (surplus > 0) {
> +    turns = ((cost - stock - 1) / surplus) + 1 + 1;
> 
> It seems to me that it should be either 
> 1) turns =  ((cost - stock - 1) / surplus) + 1;
> 
> or
> 
> 2) turns =  ((cost - stock - 1) / surplus) + 2;
> 
> +  } else {
> +    if (stock < 0)
> +      turns = -1;
> 
> with 1) being more likely.

I will look at this.

> +int cmafc_predefined_num(void)
> +{
> +  return MAX_CMAS;
> 
> I'm not sure of the purpose of this function. Please explain.

MAX_CMAS is an internal constant. Code from outside has to use
cmafc_predefined_num to get the number of predefined parameters.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Despite all the medical advances of the 20th century, the mortality 
  rate remains unchanged at 1 death per person."


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