[Freeciv-Dev] Re: [Patch] is_city_center
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
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?
|
|