Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2000:
[Freeciv-Dev] Sailing on Rivers
Home

[Freeciv-Dev] Sailing on Rivers

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Sailing on Rivers
From: Jerzy Klek <qpkjeek@xxxxxxxxxxxxxxxxxx>
Date: Tue, 22 Aug 2000 18:46:23 +0200 (MET DST)

Hello!

This is a patch that introduces a new unit flag "SailRiver" that enables
a naval unit to sail on the rivers. Building such units in cities on/near
rivers is also possible. I added this flag to Trireme, but kust as
example, this flag may be just introduced for use in some modpacks.

/Jerzy

diff -Nur -Xfreeciv/diff_ignore freeciv-old/common/city.c freeciv/common/city.c
--- freeciv-old/common/city.c   Tue Aug 15 13:29:17 2000
+++ freeciv/common/city.c       Tue Aug 22 17:27:56 2000
@@ -346,8 +346,18 @@
     return 0;
   if (get_invention(p,unit_types[id].tech_requirement)!=TECH_KNOWN)
     return 0;
-  if (!is_terrain_near_tile(pcity->x, pcity->y, T_OCEAN) && is_water_unit(id))
+  if (!is_terrain_near_tile(pcity->x, pcity->y, T_OCEAN) && is_water_unit(id)
+      && !unit_flag(id, F_SAILRIVER))
     return 0;
+  /* river sailing units can be built on coast and near/on rivers */
+  if ( !is_terrain_near_tile(pcity->x, pcity->y, T_OCEAN)
+      && !(map_get_terrain(pcity->x, pcity->y) == T_RIVER)
+      && !(map_get_special(pcity->x, pcity->y) & S_RIVER)
+      && !is_terrain_near_tile(pcity->x, pcity->y, T_RIVER)
+      && !is_special_near_tile(pcity->x, pcity->y, S_RIVER)
+      && unit_flag(id, F_SAILRIVER))
+    return 0;
+
   return 1;
 }
 
diff -Nur -Xfreeciv/diff_ignore freeciv-old/common/unittype.c 
freeciv/common/unittype.c
--- freeciv-old/common/unittype.c       Mon Aug 14 14:48:28 2000
+++ freeciv/common/unittype.c   Tue Aug 22 13:59:25 2000
@@ -43,7 +43,8 @@
   "OneAttack", "Pikemen", "Horse", "IgWall", "FieldUnit", "AEGIS",
   "Fighter", "Marines", "Partial_Invis", "Settlers", "Diplomat",
   "Trireme", "Nuclear", "Spy", "Transform", "Paratroopers",
-  "Airbase", "Cities", "IgTired", "Missile_Carrier", "No_Land_Attack"
+  "Airbase", "Cities", "IgTired", "Missile_Carrier", "No_Land_Attack",
+  "SailRiver"
 };
 static char *role_names[] = {
   "FirstBuild", "Explorer", "Hut", "HutTech", "Partisan",
diff -Nur -Xfreeciv/diff_ignore freeciv-old/common/unittype.h 
freeciv/common/unittype.h
--- freeciv-old/common/unittype.h       Mon Aug 14 14:48:28 2000
+++ freeciv/common/unittype.h   Tue Aug 22 13:57:34 2000
@@ -103,6 +103,7 @@
   F_IGTIRED,          /* Ignore tired negative bonus when attacking */
   F_MISSILE_CARRIER,  /* Like F_CARRIER, but missiles only (Submarine) */
   F_NO_LAND_ATTACK,   /* Cannot attack vs land squares (Submarine) */
+  F_SAILRIVER,        /* Can sail on rivers */
   F_LAST
 };
 
diff -Nur -Xfreeciv/diff_ignore freeciv-old/data/default/units.ruleset 
freeciv/data/default/units.ruleset
--- freeciv-old/data/default/units.ruleset      Tue Aug 22 17:20:03 2000
+++ freeciv/data/default/units.ruleset  Tue Aug 22 18:03:27 2000
@@ -886,7 +886,7 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = "Trireme"
+flags         = "Trireme", "SailRiver"
 roles         = "Ferryboat"
 
 [unit_caravel]
diff -Nur -Xfreeciv/diff_ignore freeciv-old/server/unittools.c 
freeciv/server/unittools.c
--- freeciv-old/server/unittools.c      Thu Aug 17 13:28:44 2000
+++ freeciv/server/unittools.c  Tue Aug 22 17:59:49 2000
@@ -54,6 +54,7 @@
      is a transporter with free capacity
   6) marines are the only units that can attack from a ocean square
   7) naval units can only be moved to ocean squares or city squares
+     or rivers if they can sail them
   8) there are no peaceful but un-allied units on the target tile
   9) there is not a peaceful but un-allied city on the target tile
   10) there is no non-allied unit blocking (zoc) [or igzoc is true]
@@ -115,6 +116,8 @@
     /* 7) */
     if (ptotile->terrain!=T_OCEAN
        && ptotile->terrain!=T_UNKNOWN
+        && !( unit_flag(punit->type, F_SAILRIVER) && 
+              (ptotile->terrain == T_RIVER || ptotile->special & S_RIVER) )
        && !is_allied_city_tile(ptotile, punit->owner))
       return 0;
   } 




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