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: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: [Patch] is_city_center
From: Raahul Kumar <raahul_da_man@xxxxxxxxx>
Date: Mon, 1 Oct 2001 06:09:38 -0700 (PDT)

How many different ways to check if a tile is in the city radius Raimar? Far
too many in my opinion.

/**************************************************************************
1296 Normalizes the map position. Returns TRUE if it is real, FALSE otherwise.
1297
**************************************************************************/
1298 int normalize_map_pos(int *x, int *y)
1299 {
1300 while (*x < 0)
1301 *x += map.xsize;
1302 while (*x >= map.xsize)
1303 *x -= map.xsize;
1304 1305 if (!is_real_tile(*x, *y))
1306 return FALSE;
1307 1308 return TRUE;
1309 }

/**************************************************************************
127 Finds the map position for a given city map coordinate of a certain
128 city. Returns true if the map position found is real.
129 **************************************************************************/
130 int base_city_map_to_map(int *map_x, int *map_y,
131 int city_center_x, int city_center_y,
132 int city_map_x, int city_map_y)
133 {
134 assert(is_valid_city_coords(city_map_x, city_map_y));
135 *map_x = city_center_x + city_map_x - CITY_MAP_SIZE / 2;
136 *map_y = city_center_y + city_map_y - CITY_MAP_SIZE / 2;
137 return normalize_map_pos(map_x, map_y);
138 }

int is_valid_city_coords(const int city_x, const int city_y)
 83 {
 84 if ((city_x == 0 || city_x == CITY_MAP_SIZE-1)
 85 && (city_y == 0 || city_y == CITY_MAP_SIZE-1))
 86 return 0;
 87 if (city_x < 0 || city_y < 0
 88 || city_x >= CITY_MAP_SIZE
89 || city_y >= CITY_MAP_SIZE)
 90 return 0;
 91 92 return 1;
 93 }




__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com


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