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: rf13@xxxxxxxxxxxxxxxxxxxxxx, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [CMA 2.3] A few comments
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Tue, 9 Oct 2001 02:26:13 -0700 (PDT)

#define MAX_CITY_SIZE                                   30

In Freeciv cities can reach city size 35. Make it 40 to be on the safe side.

#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. Why these numbers in particular multiplied
together? Do they come from somewhere? Comments please.

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.

+int cmafc_predefined_num(void)
+{
+  return MAX_CMAS;

I'm not sure of the purpose of this function. Please explain.

__________________________________________________
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


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