Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2001:
[Freeciv-Dev] Re: [Patch] is_city_center
Home

[Freeciv-Dev] Re: [Patch] is_city_center

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] is_city_center
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 2 Oct 2001 09:34:13 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Mon, Oct 01, 2001 at 08:18:33PM -0400, Ross W. Wetmore wrote:
> You propagated the bug Gaute introduced in the assignment of pollution. 
> Note, the original code skips on bad squares (preserving probabilities 
> on a per square basis).

Version 1.160 (code before Gautes changes):
1.67         (jjm      08-Aug-99):       x=myrand(5)-2;
1.67         (jjm      08-Aug-99):       y=myrand(5)-2;
1.67         (jjm      08-Aug-99):       if ( ( x != -2 && x != 2 ) || ( y != 
-2 && y != 2 ) ) {
1.67         (jjm      08-Aug-99):      x=map_adjust_x(pcity->x+x); 
y=map_adjust_y(pcity->y+y);
1.67         (jjm      08-Aug-99):      if ( (map_get_terrain(x,y)!=T_OCEAN && 
map_get_terrain(x,y)<=T_TUNDRA) &&
1.67         (jjm      08-Aug-99):           
(!(map_get_special(x,y)&S_POLLUTION)) ) {

This is bad.

What do you think about

+      int cx = myrand(CITY_MAP_SIZE);
+      int cy = myrand(CITY_MAP_SIZE);
+
+      if (is_valid_city_coords(cx, cy)) {
+       int x, y;
+
+       if (!city_map_to_map(&x, &y, pcity, cx, cy)) {
          continue;
+       }
?

> I would also seriously consider making this a macro before you add
> this many extra function calls. At least profile it to justify the
> loss of potential optimizations in surrounding code.

What should be done in a macro?

> Many of them may actually be removed by using the appropriate city
> iterator and/or cleaning up the code.

What cleanup?

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "I was dead ... but I'm better now."
    -- Capitain Sheridan in Babylon 5


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