Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2001:
[Freeciv-Dev] Re: [PATCH] city_map_iterate cleanup
Home

[Freeciv-Dev] Re: [PATCH] city_map_iterate cleanup

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Jason Dorje Short <jshort@xxxxxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: [PATCH] city_map_iterate cleanup
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 22 Aug 2001 09:54:46 +0200
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Wed, Aug 22, 2001 at 03:21:30AM -0400, Jason Dorje Short wrote:
> This small patch changes about 20 lines, adding in another
> city_map_iterate and some is_valid_city_coords calls and removing about
> a dozen lines of code.  Unfortunately, it doesn't look like any of the
> other city coordinate iterations can be replaced by city_map_iterate.

Partly applied.

> -#define map_city_radius_iterate(city_x, city_y, x_itr, y_itr) \
> -{ \
> -  int x_itr, y_itr; \
> -  int MCMI_x, MCMI_y; \
> -  for (MCMI_x=0; MCMI_x<CITY_MAP_SIZE; MCMI_x++) { \
> -    for (MCMI_y=0; MCMI_y<CITY_MAP_SIZE; MCMI_y++) { \
> -      if (! ((MCMI_x == 0 || MCMI_x == (CITY_MAP_SIZE-1)) \
> -          && (MCMI_y == 0 || MCMI_y == (CITY_MAP_SIZE-1))) ) { \
> -        y_itr = city_y + MCMI_y - CITY_MAP_SIZE/2; \
> -        if (y_itr < 0 || y_itr >= map.ysize) \
> -       continue; \
> -     x_itr = map_adjust_x(city_x + MCMI_x - CITY_MAP_SIZE/2);
> +#define map_city_radius_iterate(city_x, city_y, x_itr, y_itr)                
>  \
> +{                                                                            
>  \
> +  int _city_x = (city_x), _city_y = (city_y);                                
>  \
> +  city_map_iterate(_city_x_itr, _city_y_itr) {                               
>  \
> +    int x_itr = _city_x + _city_x_itr - CITY_MAP_SIZE/2;                     
>  \
> +    int y_itr = _city_y + _city_y_itr - CITY_MAP_SIZE/2;                     
>  \
> +    if (!normalize_map_pos(&x_itr, &y_itr)) continue;
>  
> -#define map_city_radius_iterate_end \
> -      } \
> -    } \
> -  } \
> +#define map_city_radius_iterate_end                                          
>  \
> +  } city_map_iterate_end;                                                    
>  \
>  }

I haven't applied this one because of the CITY_MAP_SIZE/2 thing.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx


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