[Freeciv-Dev] (PR#8952) CITY_TILES as a variable
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
<URL: http://rt.freeciv.org/Ticket/Display.html?id=8952 >
Currently CITY_TILES is a hard-coded 21. This is the only thing
restricting the size of the city map. Changing it to a variable is all
that is needed to allow variable-sized citymaps.
Variable-sized citymaps are needed for PR#7350 (variable city radius)
and PR#7481 (hex tiles).
jason
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.217
diff -u -r1.217 city.c
--- common/city.c 10 Jun 2004 01:04:54 -0000 1.217
+++ common/city.c 11 Jun 2004 05:46:35 -0000
@@ -57,6 +57,8 @@
struct citystyle *city_styles = NULL;
+int city_tiles;
+
/**************************************************************************
Return TRUE if the given city coordinate pair is "valid"; that is, if it
is a part of the citymap and thus is workable by the city.
@@ -205,6 +207,11 @@
int i = 0, dx, dy;
struct iter_index *array = city_map_iterate_outwards_indices;
+ city_tiles = 0;
+ city_map_iterate(city_x, city_y) {
+ city_tiles++;
+ } city_map_iterate_end;
+
/* Realloc is used because this function may be called multiple times. */
array = fc_realloc(array, CITY_TILES * sizeof(*array));
Index: common/city.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.h,v
retrieving revision 1.147
diff -u -r1.147 city.h
--- common/city.h 10 Jun 2004 01:04:54 -0000 1.147
+++ common/city.h 11 Jun 2004 05:46:36 -0000
@@ -66,7 +66,7 @@
#define CITY_MAP_SIZE (CITY_MAP_RADIUS * 2 + 1)
/* Number of tiles a city can use */
-#define CITY_TILES (CITY_MAP_SIZE * CITY_MAP_SIZE - 4)
+#define CITY_TILES city_tiles
#define INCITE_IMPOSSIBLE_COST (1000 * 1000 * 1000)
@@ -105,6 +105,7 @@
extern struct iter_index {
int dx, dy, dist;
} *city_map_iterate_outwards_indices;
+extern int city_tiles;
/* Iterate a city map, from the center (the city) outwards.
* (city_x, city_y) will be the city coordinates. */
Index: common/aicore/cm.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/aicore/cm.c,v
retrieving revision 1.23
diff -u -r1.23 cm.c
--- common/aicore/cm.c 2 Jun 2004 22:54:14 -0000 1.23
+++ common/aicore/cm.c 11 Jun 2004 05:46:36 -0000
@@ -190,7 +190,7 @@
struct cm_result *cache1;
struct cm_result all_entertainer;
} combinations[MAX_COMBINATIONS];
- } results[MAX_FIELDS_USED + 1];
+ } *results;
struct city *pcity;
} cache3;
@@ -1152,6 +1152,10 @@
struct tile_stats tile_stats;
bool is_celebrating = base_city_celebrating(pcity);
+ cache3.results
+ = fc_realloc(cache3.results,
+ (MAX_FIELDS_USED + 1) * sizeof(*cache3.results));
+
if (cache3.pcity != pcity) {
cache3.pcity = NULL;
} else {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#8952) CITY_TILES as a variable,
Jason Short <=
|
|