<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40347 >

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.


 - ML

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:32:33.000000000 +0300
@@ -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:34:27.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;
 }
 
 /****************************************************************************
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:33:16.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);
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) {
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to