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: rf13@xxxxxxxxxxxxxxxxxxxxxx
Cc: "Ross W. Wetmore" <rwetmore@xxxxxxxxxxxx>, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] is_city_center
From: Gaute B Strokkenes <gs234@xxxxxxxxx>
Date: Fri, 05 Oct 2001 23:20:26 +0100

On Tue, 2 Oct 2001, hawk@xxxxxxxxxxxxxxxxxxxxxxx wrote:
> 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.

Yes, but not for the reason claimed.  Note the call to map_adjust_y().

> 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 think that looks a lot better.  But please profile it.

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
A KAISER ROLL?!  What good is a Kaiser Roll without a little
 COLE SLAW on the SIDE?


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