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

 This adds unit class flag "CanFortify". This used to be hardcoded
property of LAND_MOVING. Now fortifying amphibious units are possible.
Fortifying is still possible only at land squares (should probably be
terrain flag)


 - ML

diff -Nurd -X.diff_ignore freeciv/common/unit.c freeciv/common/unit.c
--- freeciv/common/unit.c	2007-03-08 17:18:27.000000000 +0200
+++ freeciv/common/unit.c	2007-03-09 00:39:39.000000000 +0200
@@ -743,6 +743,7 @@
   struct player *pplayer = unit_owner(punit);
   struct terrain *pterrain = ptile->terrain;
   struct base_type *pbase;
+  struct unit_class *pclass = get_unit_class(unit_type(punit));
 
   switch(activity) {
   case ACTIVITY_IDLE:
@@ -823,7 +824,7 @@
     }
 
   case ACTIVITY_FORTIFYING:
-    return (is_ground_unit(punit)
+    return (unit_class_flag(pclass, UCF_CAN_FORTIFY)
 	    && punit->activity != ACTIVITY_FORTIFIED
 	    && !unit_flag(punit, F_SETTLERS)
 	    && !is_ocean(ptile->terrain));
diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c	2007-03-05 21:11:49.000000000 +0200
+++ freeciv/common/unittype.c	2007-03-09 00:38:06.000000000 +0200
@@ -42,7 +42,7 @@
 static const char *unit_class_flag_names[] = {
   "TerrainSpeed", "DamageSlows", "CanOccupy", "Missile",
   "RoadNative", "BuildAnywhere", "Unreachable",
-  "CollectRansom", "ZOC"
+  "CollectRansom", "ZOC", "CanFortify"
 };
 static const char *flag_names[] = {
   "TradeRoute" ,"HelpWonder", "IgZOC", "NonMil", "IgTer", 
diff -Nurd -X.diff_ignore freeciv/common/unittype.h freeciv/common/unittype.h
--- freeciv/common/unittype.h	2007-03-06 05:46:13.000000000 +0200
+++ freeciv/common/unittype.h	2007-03-09 00:37:52.000000000 +0200
@@ -35,6 +35,7 @@
   UCF_UNREACHABLE,
   UCF_COLLECT_RANSOM,     /* Can collect ransom from barbarian leader */
   UCF_ZOC,                /* Is subject to ZOC */
+  UCF_CAN_FORTIFY,        /* Can fortify on land squares */
   UCF_LAST
 };
 
diff -Nurd -X.diff_ignore freeciv/data/civ1/units.ruleset freeciv/data/civ1/units.ruleset
--- freeciv/data/civ1/units.ruleset	2007-03-05 21:10:00.000000000 +0200
+++ freeciv/data/civ1/units.ruleset	2007-03-09 00:42:03.000000000 +0200
@@ -66,6 +66,7 @@
 ; "CollectRansom" = Unit can collect ransom when killing lone barbarian leader
 ; "ZOC"           = Unit is subject to ZOC rules. Unit type flag "IgZOC" can
 ;                   override this
+; "CanFortify"    = Unit can fortify at land squares
 
 [unitclass_land]
 name          = _("Land")
@@ -73,7 +74,7 @@
 min_speed     = 1
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere",
-                "CollectRansom", "ZOC"
+                "CollectRansom", "ZOC", "CanFortify"
 
 [unitclass_sea]
 name          = _("Sea")
diff -Nurd -X.diff_ignore freeciv/data/civ2/units.ruleset freeciv/data/civ2/units.ruleset
--- freeciv/data/civ2/units.ruleset	2007-03-05 21:10:01.000000000 +0200
+++ freeciv/data/civ2/units.ruleset	2007-03-09 00:41:49.000000000 +0200
@@ -66,6 +66,7 @@
 ; "CollectRansom" = Unit can collect ransom when killing lone barbarian leader
 ; "ZOC"           = Unit is subject to ZOC rules. Unit type flag "IgZOC" can
 ;                   override this
+; "CanFortify"    = Unit can fortify at land squares
 
 [unitclass_missile]
 name          = _("Missile")
@@ -80,7 +81,7 @@
 min_speed     = 1
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere",
-                "CollectRansom", "ZOC"
+                "CollectRansom", "ZOC", "CanFortify"
 
 [unitclass_sea]
 name          = _("Sea")
diff -Nurd -X.diff_ignore freeciv/data/default/units.ruleset freeciv/data/default/units.ruleset
--- freeciv/data/default/units.ruleset	2007-03-05 21:10:03.000000000 +0200
+++ freeciv/data/default/units.ruleset	2007-03-09 00:45:24.000000000 +0200
@@ -72,6 +72,7 @@
 ; "CollectRansom" = Unit can collect ransom when killing lone barbarian leader
 ; "ZOC"           = Unit is subject to ZOC rules. Unit type flag "IgZOC" can
 ;                   override this
+; "CanFortify"    = Unit can fortify at land squares
 
 [unitclass_missile]
 name          = _("Missile")
@@ -86,7 +87,7 @@
 min_speed     = 1
 hp_loss_pct   = 0
 flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere",
-                "CollectRansom", "ZOC"
+                "CollectRansom", "ZOC", "CanFortify"
 
 [unitclass_sea]
 name          = _("Sea")
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to