<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40347 >
2008/7/1 Marko Lindqvist: > 2008/7/1 Jarmo: >> where 'Adjacent' seems to be interpreted as 'Next to the city tile, but >> not the city tile itself' by the game. > > Untested patch for fixing this. Problem affected all terrain type > requirements. - Specials type requirements are affected (river requirement is of this type) also. Fixed - Patch for S2_2/TRUNK also - ML
diff -Nurd -X.diff_ignore freeciv/common/requirements.c freeciv/common/requirements.c --- freeciv/common/requirements.c 2008-01-22 03:37:24.000000000 +0200 +++ freeciv/common/requirements.c 2008-07-01 16:56:20.000000000 +0300 @@ -726,7 +726,7 @@ case REQ_RANGE_LOCAL: return target_tile && tile_has_special(target_tile, special); case REQ_RANGE_ADJACENT: - return target_tile && is_special_near_tile(target_tile, special); + return target_tile && is_special_near_tile(target_tile, special, TRUE); case REQ_RANGE_CITY: case REQ_RANGE_CONTINENT: case REQ_RANGE_PLAYER: @@ -755,7 +755,7 @@ /* The requirement is filled if the tile has the terrain. */ return pterrain && tile_terrain(target_tile) == pterrain; case REQ_RANGE_ADJACENT: - return pterrain && is_terrain_near_tile(target_tile, pterrain); + return pterrain && is_terrain_near_tile(target_tile, pterrain, TRUE); case REQ_RANGE_CITY: case REQ_RANGE_CONTINENT: case REQ_RANGE_PLAYER: diff -Nurd -X.diff_ignore freeciv/common/terrain.c freeciv/common/terrain.c --- freeciv/common/terrain.c 2008-06-18 18:49:36.000000000 +0300 +++ freeciv/common/terrain.c 2008-07-01 16:57:49.000000000 +0300 @@ -468,15 +468,20 @@ Returns TRUE iff any adjacent tile contains the given terrain. ****************************************************************************/ bool is_terrain_near_tile(const struct tile *ptile, - const struct terrain *pterrain) + const struct terrain *pterrain, + bool check_self) { + if (!pterrain) { + return FALSE; + } + adjc_iterate(ptile, adjc_tile) { - if (pterrain && tile_terrain(adjc_tile) == pterrain) { + if (tile_terrain(adjc_tile) == pterrain) { return TRUE; } } adjc_iterate_end; - return FALSE; + return check_self && ptile->terrain == pterrain; } /**************************************************************************** @@ -636,7 +641,8 @@ /**************************************************************************** Returns TRUE iff any tile adjacent to (map_x,map_y) has the given special. ****************************************************************************/ -bool is_special_near_tile(const struct tile *ptile, enum tile_special_type spe) +bool is_special_near_tile(const struct tile *ptile, enum tile_special_type spe, + bool check_self) { adjc_iterate(ptile, adjc_tile) { if (tile_has_special(adjc_tile, spe)) { @@ -644,7 +650,7 @@ } } adjc_iterate_end; - return FALSE; + return check_self && tile_has_special(ptile, spe); } /**************************************************************************** diff -Nurd -X.diff_ignore freeciv/common/terrain.h freeciv/common/terrain.h --- freeciv/common/terrain.h 2008-06-28 20:49:38.000000000 +0300 +++ freeciv/common/terrain.h 2008-07-01 16:56:20.000000000 +0300 @@ -252,7 +252,8 @@ /* Functions to operate on a general terrain type. */ bool is_terrain_near_tile(const struct tile *ptile, - const struct terrain *pterrain); + const struct terrain *pterrain, + bool check_self); int count_terrain_near_tile(const struct tile *ptile, bool cardinal_only, bool percentage, const struct terrain *pterrain); @@ -292,7 +293,8 @@ /* Functions to operate on a terrain special. */ bool is_special_near_tile(const struct tile *ptile, - enum tile_special_type spe); + enum tile_special_type spe, + bool check_self); int count_special_near_tile(const struct tile *ptile, bool cardinal_only, bool percentage, enum tile_special_type spe); diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c --- freeciv/server/citytools.c 2008-07-01 01:07:31.000000000 +0300 +++ freeciv/server/citytools.c 2008-07-01 16:58:17.000000000 +0300 @@ -228,7 +228,7 @@ terrain_type_iterate(pterrain) { /* Now we do the same for every available terrain. */ - goodness = is_terrain_near_tile(ptile, pterrain) + goodness = is_terrain_near_tile(ptile, pterrain, TRUE) ? nc->terrain[terrain_index(pterrain)] : -nc->terrain[terrain_index(pterrain)]; if (goodness > 0) { diff -Nurd -X.diff_ignore freeciv/server/generator/mapgen.c freeciv/server/generator/mapgen.c --- freeciv/server/generator/mapgen.c 2008-06-30 12:02:12.000000000 +0300 +++ freeciv/server/generator/mapgen.c 2008-07-01 16:56:20.000000000 +0300 @@ -1481,11 +1481,11 @@ /* the first condition helps make terrain more contiguous, the second lets it avoid the coast: */ if ( ( i*3>k*2 - || is_terrain_near_tile(ptile, warm0) - || is_terrain_near_tile(ptile, warm1) + || is_terrain_near_tile(ptile, warm0, FALSE) + || is_terrain_near_tile(ptile, warm1, FALSE) || myrand(100)<50 - || is_terrain_near_tile(ptile, cold0) - || is_terrain_near_tile(ptile, cold1) + || is_terrain_near_tile(ptile, cold0, FALSE) + || is_terrain_near_tile(ptile, cold1, FALSE) ) &&( !is_cardinally_adj_to_ocean(ptile) || myrand(100) < coast )) { if (map_colatitude(ptile) < COLD_LEVEL) { diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c --- freeciv/server/maphand.c 2008-06-28 20:49:38.000000000 +0300 +++ freeciv/server/maphand.c 2008-07-01 16:56:21.000000000 +0300 @@ -71,9 +71,8 @@ **************************************************************************/ static bool is_terrain_ecologically_wet(struct tile *ptile) { - return (tile_has_special(ptile, S_RIVER) - || is_ocean_near_tile(ptile) - || is_special_near_tile(ptile, S_RIVER)); + return (is_ocean_near_tile(ptile) + || is_special_near_tile(ptile, S_RIVER, TRUE)); } /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/common/requirements.c freeciv/common/requirements.c --- freeciv/common/requirements.c 2008-01-22 03:47:26.000000000 +0200 +++ freeciv/common/requirements.c 2008-07-01 16:48:23.000000000 +0300 @@ -654,7 +654,7 @@ case REQ_RANGE_LOCAL: return target_tile && tile_has_special(target_tile, special); case REQ_RANGE_ADJACENT: - return target_tile && is_special_near_tile(target_tile, special); + return target_tile && is_special_near_tile(target_tile, special, TRUE); case REQ_RANGE_CITY: case REQ_RANGE_CONTINENT: case REQ_RANGE_PLAYER: @@ -683,7 +683,7 @@ /* The requirement is filled if the tile has the terrain. */ return pterrain && target_tile->terrain == pterrain; case REQ_RANGE_ADJACENT: - return pterrain && is_terrain_near_tile(target_tile, pterrain); + return pterrain && is_terrain_near_tile(target_tile, pterrain, TRUE); case REQ_RANGE_CITY: case REQ_RANGE_CONTINENT: case REQ_RANGE_PLAYER: diff -Nurd -X.diff_ignore freeciv/common/terrain.c freeciv/common/terrain.c --- freeciv/common/terrain.c 2008-04-09 16:01:51.000000000 +0300 +++ freeciv/common/terrain.c 2008-07-01 16:46:49.000000000 +0300 @@ -324,15 +324,20 @@ Returns TRUE iff any adjacent tile contains the given terrain. ****************************************************************************/ bool is_terrain_near_tile(const struct tile *ptile, - const struct terrain *pterrain) + const struct terrain *pterrain, + bool check_self) { + if (!pterrain) { + return FALSE; + } + adjc_iterate(ptile, adjc_tile) { - if (pterrain && adjc_tile->terrain == pterrain) { + if (adjc_tile->terrain == pterrain) { return TRUE; } } adjc_iterate_end; - return FALSE; + return check_self && ptile->terrain == pterrain; } /**************************************************************************** @@ -472,7 +477,8 @@ /**************************************************************************** Returns TRUE iff any tile adjacent to (map_x,map_y) has the given special. ****************************************************************************/ -bool is_special_near_tile(const struct tile *ptile, enum tile_special_type spe) +bool is_special_near_tile(const struct tile *ptile, enum tile_special_type spe, + bool check_self) { adjc_iterate(ptile, adjc_tile) { if (tile_has_special(adjc_tile, spe)) { @@ -480,7 +486,7 @@ } } adjc_iterate_end; - return FALSE; + return check_self && tile_has_special(ptile, spe); } /**************************************************************************** diff -Nurd -X.diff_ignore freeciv/common/terrain.h freeciv/common/terrain.h --- freeciv/common/terrain.h 2007-11-28 02:28:29.000000000 +0200 +++ freeciv/common/terrain.h 2008-07-01 16:47:09.000000000 +0300 @@ -212,7 +212,8 @@ /* Functions to operate on a general terrain type. */ bool is_terrain_near_tile(const struct tile *ptile, - const struct terrain *pterrain); + const struct terrain *pterrain, + bool check_self); int count_terrain_near_tile(const struct tile *ptile, bool cardinal_only, bool percentage, const struct terrain *pterrain); @@ -233,7 +234,8 @@ /* Functions to operate on a terrain special. */ bool is_special_near_tile(const struct tile *ptile, - enum tile_special_type spe); + enum tile_special_type spe, + bool check_self); int count_special_near_tile(const struct tile *ptile, bool cardinal_only, bool percentage, enum tile_special_type spe); diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c --- freeciv/server/citytools.c 2008-06-22 09:39:18.000000000 +0300 +++ freeciv/server/citytools.c 2008-07-01 16:34:52.000000000 +0300 @@ -185,7 +185,7 @@ terrain_type_iterate(pterrain) { /* Now we do the same for every available terrain. */ goodness - = is_terrain_near_tile(ptile, pterrain) + = is_terrain_near_tile(ptile, pterrain, TRUE) ? nc->terrain[pterrain->index] : -nc->terrain[pterrain->index]; if (goodness > 0) { diff -Nurd -X.diff_ignore freeciv/server/generator/mapgen.c freeciv/server/generator/mapgen.c --- freeciv/server/generator/mapgen.c 2007-07-04 14:04:16.000000000 +0300 +++ freeciv/server/generator/mapgen.c 2008-07-01 16:32:49.000000000 +0300 @@ -1446,11 +1446,11 @@ /* the first condition helps make terrain more contiguous, the second lets it avoid the coast: */ if ( ( i*3>k*2 - || is_terrain_near_tile(ptile, warm0) - || is_terrain_near_tile(ptile, warm1) + || is_terrain_near_tile(ptile, warm0, FALSE) + || is_terrain_near_tile(ptile, warm1, FALSE) || myrand(100)<50 - || is_terrain_near_tile(ptile, cold0) - || is_terrain_near_tile(ptile, cold1) + || is_terrain_near_tile(ptile, cold0, FALSE) + || is_terrain_near_tile(ptile, cold1, FALSE) ) &&( !is_cardinally_adj_to_ocean(ptile) || myrand(100) < coast )) { if (map_colatitude(ptile) < COLD_LEVEL) { diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c --- freeciv/server/maphand.c 2008-06-22 09:39:18.000000000 +0300 +++ freeciv/server/maphand.c 2008-07-01 16:51:09.000000000 +0300 @@ -207,9 +207,8 @@ **************************************************************************/ static bool is_terrain_ecologically_wet(struct tile *ptile) { - return (tile_has_special(ptile, S_RIVER) - || is_ocean_near_tile(ptile) - || is_special_near_tile(ptile, S_RIVER)); + return (is_ocean_near_tile(ptile) + || is_special_near_tile(ptile, S_RIVER, TRUE)); } /**************************************************************************
_______________________________________________ Freeciv-dev mailing list Freeciv-dev@gna.org https://mail.gna.org/listinfo/freeciv-dev