Complete.Org: Mailing Lists: Archives: freeciv-dev: July 1999:
[Freeciv-Dev] omissions in terrain ruleset implementation (PR#75)
Home

[Freeciv-Dev] omissions in terrain ruleset implementation (PR#75)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] omissions in terrain ruleset implementation (PR#75)
From: jjm@xxxxxxxxxxxx
Date: Sun, 25 Jul 1999 09:49:06 -0700 (PDT)

Full_Name: Jeff Mallatt
Version: 1.8.1
OS: Linux
Submission from: (NULL) (199.103.194.35)


I missed a couple of things concerning Civ2 rivers when I implemented the
terrain ruleset.  Units get a movement bonus when moving along Civ2 rivers,
but not Civ1 rivers.  Also, Civ2 rivers confer a 50% defense bonus.

This patch fixes these omissions.

diff -Nru freeciv-old/ai/aiunit.c freeciv/ai/aiunit.c
--- freeciv-old/ai/aiunit.c     Wed Jul 21 07:53:53 1999
+++ freeciv/ai/aiunit.c Sun Jul 25 12:02:37 1999
@@ -568,6 +568,7 @@
       }
       if (ok) { /* accessible beachhead with zoc-ok water tile nearby */
         ok = get_tile_type(t)->defense_bonus;
+       if (map_get_special(i, j) & S_RIVER) ok *= 1.5;
         if (get_tile_type(t)->movement_cost * 3 <
             unit_types[punit->type].move_rate) ok *= 8;
         ok += (6 * THRESHOLD - warmap.seacost[i][j]);
diff -Nru freeciv-old/common/map.c freeciv/common/map.c
--- freeciv-old/common/map.c    Sat Jul 24 01:31:24 1999
+++ freeciv/common/map.c        Sun Jul 25 12:27:12 1999
@@ -689,13 +689,9 @@
     return 1;
   if( (t1->special&S_ROAD) && (t2->special&S_ROAD) )
     return 1;
-  /* To change the rules so that cannot cut corners on rivers,
-     (to match Civ2(?)) remove the "1 ||" below:
-  */
-  if( (1 || y1==y2 || map_adjust_x(x1)==map_adjust_x(x2))
-      && ( ( (t1->terrain==T_RIVER) && (t2->terrain==T_RIVER) )
-          ||
-          ( (t1->special&S_RIVER) && (t2->special&S_RIVER) ) ) )
+  /* Only S_RIVER (Civ2 style) rivers confer movement bonus. */
+  if( (y1==y2 || map_adjust_x(x1)==map_adjust_x(x2))
+      && ( (t1->special&S_RIVER) && (t2->special&S_RIVER) ) )
     return 1;
   return(get_tile_type(t2->terrain)->movement_cost*3);
 }
diff -Nru freeciv-old/server/settlers.c freeciv/server/settlers.c
--- freeciv-old/server/settlers.c       Sat Jul 24 01:32:10 1999
+++ freeciv/server/settlers.c   Sun Jul 25 12:09:40 1999
@@ -186,6 +186,7 @@
   int har, t, sh;
   struct tile_type *ptype;
   struct city *pcity;
+  int db;
 
   if (is_square_threatened(pplayer, x, y))
     return 0;
@@ -291,8 +292,9 @@
   /* val is mort times the real value */
   /* treating harbor as free to approximate advantage of
      building boats. -- Syela */
-  val += (4 * (get_tile_type(map_get_tile(x, y)->terrain)->defense_bonus)
-         - 40) * SHIELD_WEIGHTING;
+  db = get_tile_type(map_get_terrain(x, y))->defense_bonus;
+  if (map_get_special(x, y) & S_RIVER) db *= 1.5;
+  val += (4 * db - 40) * SHIELD_WEIGHTING;
   /* don't build cities in danger!! FIX! -- Syela */
   val += 8 * MORT; /* one science per city */
   
diff -Nru freeciv-old/server/unitfunc.c freeciv/server/unitfunc.c
--- freeciv-old/server/unitfunc.c       Sat Jul 24 01:32:11 1999
+++ freeciv/server/unitfunc.c   Sun Jul 25 12:12:08 1999
@@ -960,12 +960,16 @@
   int defensepower=unit_types[d_type].defense_strength;
   struct city *pcity = map_get_city(x, y);
   enum tile_terrain_type t = map_get_terrain(x, y);
+  int db;
 
   if (unit_types[d_type].move_type == LAND_MOVING && t == T_OCEAN) return 0;
 /* I had this dorky bug where transports with mech inf aboard would go next
 to enemy ships thinking the mech inf would defend them adequately. -- Syela */
 
-  defensepower *= get_tile_type(t)->defense_bonus;
+  db = get_tile_type(t)->defense_bonus;
+  if (map_get_special(x, y) & S_RIVER) db *= 1.5;
+
+  defensepower *= db;
 
   if (map_get_special(x, y)&S_FORTRESS && !pcity)
     defensepower*=2;
@@ -981,12 +985,16 @@
   int m_type = unit_types[a_type].move_type;
   struct city *pcity = map_get_city(x, y);
   enum tile_terrain_type t = map_get_terrain(x, y);
+  int db;
 
   if (unit_types[d_type].move_type == LAND_MOVING && t == T_OCEAN) return 0;
 /* I had this dorky bug where transports with mech inf aboard would go next
 to enemy ships thinking the mech inf would defend them adequately. -- Syela */
 
-  defensepower *= get_tile_type(t)->defense_bonus;
+  db = get_tile_type(t)->defense_bonus;
+  if (map_get_special(x, y) & S_RIVER) db *= 1.5;
+
+  defensepower *= db;
 
   if (unit_flag(d_type, F_PIKEMEN) && unit_flag(a_type, F_HORSE)) 
     defensepower*=2;
diff -Nru freeciv-old/server/unittools.c freeciv/server/unittools.c
--- freeciv-old/server/unittools.c      Wed Jul 21 08:00:01 1999
+++ freeciv/server/unittools.c  Sun Jul 25 12:15:04 1999
@@ -399,6 +399,8 @@
 {
   int power;
   int terra;
+  int db;
+
   if (!punit || punit->type<0 || punit->type>=U_LAST)
     abort();
   power=get_unit_type(punit->type)->defense_strength*10;
@@ -406,7 +408,9 @@
     power*=1.5;
   
   terra=map_get_terrain(punit->x, punit->y);
-  power=(power*get_tile_type(terra)->defense_bonus)/10;
+  db = get_tile_type(terra)->defense_bonus;
+  if (map_get_special(punit->x, punit->y) & S_RIVER) db *= 1.5;
+  power=(power*db)/10;
   return power;
 }
 
@@ -598,9 +602,11 @@
 int enemies_at(struct unit *punit, int x, int y)
 {
   int i, j, a = 0, d;
+  int db;
   struct player *pplayer = get_player(punit->owner);
-  d = unit_vulnerability_virtual(punit) *
-      get_tile_type(map_get_terrain(x, y))->defense_bonus;
+  db = get_tile_type(map_get_terrain(x, y))->defense_bonus;
+  if (map_get_special(x, y) & S_RIVER) db *= 1.5;
+  d = unit_vulnerability_virtual(punit) * db;
   if (is_friendly_city_tile(x, y, punit->owner)) return 0;
   for (j = y - 1; j <= y + 1; j++) {
     if (j < 0 || j >= map.ysize) continue;



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