Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#6947) [Bug] is_at_coast is misleading
Home

[Freeciv-Dev] (PR#6947) [Bug] is_at_coast is misleading

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#6947) [Bug] is_at_coast is misleading
From: "Gregory Berkolaiko" <Gregory.Berkolaiko@xxxxxxxxxxxxx>
Date: Wed, 4 Aug 2004 10:34:24 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=6947 >

Per changed most wrong uses of is_at_coast, I now change the last one
and also change the name of is_at_coast (to is_cardinally_adj_to_coast)
in hope that this will deter people from misusing the function.

G.
? log.txt
? log1.txt
? ttt.gz
Index: ai/aiunit.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aiunit.c,v
retrieving revision 1.322
diff -u -r1.322 aiunit.c
--- ai/aiunit.c 28 Jul 2004 15:24:42 -0000      1.322
+++ ai/aiunit.c 4 Aug 2004 17:26:08 -0000
@@ -2638,7 +2638,7 @@
   } players_iterate_end;
 
   /* Disappearance - 33% chance on coast, when older than barbarian life span 
*/
-  if (is_at_coast(leader->x, leader->y) && leader->fuel == 0) {
+  if (is_ocean_near_tile(leader->x, leader->y) && leader->fuel == 0) {
     if(myrand(3) == 0) {
       UNIT_LOG(LOG_DEBUG, leader, "barbarian leader disappearing...");
       wipe_unit(leader);
Index: common/map.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.c,v
retrieving revision 1.185
diff -u -r1.185 map.c
--- common/map.c        4 Aug 2004 00:13:55 -0000       1.185
+++ common/map.c        4 Aug 2004 17:26:09 -0000
@@ -604,10 +604,12 @@
   return count;
 }
 
-/***************************************************************
-...
-***************************************************************/
-bool is_at_coast(int x, int y)
+/*************************************************************************
+  This is used in mapgen for rivers going into ocen.  The name is 
+  intentionally made awkward to prevent people from using it in place of
+  is_ocean_near_tile
+*************************************************************************/
+bool is_cardinally_adj_to_coast(int x, int y)
 {
   cardinal_adjc_iterate(x, y, x1, y1) {
     if (is_ocean(map_get_terrain(x1, y1))) {
Index: common/map.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/map.h,v
retrieving revision 1.202
diff -u -r1.202 map.h
--- common/map.h        28 Jul 2004 15:24:43 -0000      1.202
+++ common/map.h        4 Aug 2004 17:26:09 -0000
@@ -381,7 +381,7 @@
 bool is_special_near_tile(int x, int y, enum tile_special_type spe);
 int count_special_near_tile(int x, int y, enum tile_special_type spe);
 bool is_safe_ocean(int x, int y);
-bool is_at_coast(int x, int y);
+bool is_cardinally_adj_to_coast(int x, int y);
 bool is_sea_usable(int x, int y);
 int get_tile_food_base(struct tile * ptile);
 int get_tile_shield_base(struct tile * ptile);
Index: server/mapgen.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/mapgen.c,v
retrieving revision 1.141
diff -u -r1.141 mapgen.c
--- server/mapgen.c     4 Aug 2004 00:13:55 -0000       1.141
+++ server/mapgen.c     4 Aug 2004 17:26:10 -0000
@@ -1953,7 +1953,7 @@
             || is_terrain_near_tile(x,y,cold0) 
             || is_terrain_near_tile(x,y,cold1) 
             )
-          &&( !is_at_coast(x, y) || myrand(100) < coast )) {
+          &&( !is_cardinally_adj_to_coast(x, y) || myrand(100) < coast )) {
        if (map_pos_is_cold(x, y)) {
          map_set_terrain(x, y, (myrand(cold0_weight
                                        + cold1_weight) < cold0_weight) 
@@ -1999,7 +1999,7 @@
             || count_special_near_tile(x, y, S_RIVER) > 0
             || myrand(100)<50 
             )
-          &&( !is_at_coast(x, y) || myrand(100) < coast )) {
+          &&( !is_cardinally_adj_to_coast(x, y) || myrand(100) < coast )) {
        if (is_water_adjacent_to_tile(x, y) &&
            count_ocean_near_tile(x, y) < 4 &&
             count_special_near_tile(x, y, S_RIVER) < 3) {

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#6947) [Bug] is_at_coast is misleading, Gregory Berkolaiko <=