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

On 1/24/07, Marko Lindqvist <[EMAIL PROTECTED]> wrote:
>  Instead of checking if is_ground_unit() or is_heli_unit(), check for
> UCF_CAN_OCCUPY. Using same flag for two different things might be bad,
> but creating separate flag just for this seemed waste.

 Reconsidered this and made it separate "CollectRansom" flag after all.


 - ML

diff -Nurd -X.diff_ignore freeciv/common/unittype.c freeciv/common/unittype.c
--- freeciv/common/unittype.c	2007-01-25 17:59:51.000000000 +0200
+++ freeciv/common/unittype.c	2007-01-25 18:06:50.000000000 +0200
@@ -41,7 +41,8 @@
 
 static const char *unit_class_flag_names[] = {
   "TerrainSpeed", "DamageSlows", "CanOccupy", "Missile",
-  "RoadNative", "BuildAnywhere", "Unreachable", "AlwaysSafe"
+  "RoadNative", "BuildAnywhere", "Unreachable", "AlwaysSafe",
+  "CollectRansom"
 };
 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-01-25 17:59:51.000000000 +0200
+++ freeciv/common/unittype.h	2007-01-25 18:06:34.000000000 +0200
@@ -28,12 +28,13 @@
 enum unit_class_flag_id {
   UCF_TERRAIN_SPEED = 0,
   UCF_DAMAGE_SLOWS,
-  UCF_CAN_OCCUPY,
+  UCF_CAN_OCCUPY,         /* Can occupy enemy cities */
   UCF_MISSILE,
   UCF_ROAD_NATIVE,
   UCF_BUILD_ANYWHERE,
   UCF_UNREACHABLE,
   UCF_ALWAYS_SAFE,
+  UCF_COLLECT_RANSOM,     /* Can collect ransom from barbarian leader */
   UCF_LAST
 };
 
diff -Nurd -X.diff_ignore freeciv/data/civ1/units.ruleset freeciv/data/civ1/units.ruleset
--- freeciv/data/civ1/units.ruleset	2007-01-25 17:59:51.000000000 +0200
+++ freeciv/data/civ1/units.ruleset	2007-01-25 18:09:30.000000000 +0200
@@ -68,13 +68,15 @@
 ; "Unreachable"   = Unit can be attacked only by units with "AttackAny" flag or on
 ;                   city or airbase
 ; "AlwaysSafe"    = Unit is safe even on unsafe terrain
+; "CollectRansom" = Unit can collect ransom when killing lone barbarian leader
 
 [unitclass_land]
 name          = _("Land")
 move_type     = "Land"
 min_speed     = 1
 hp_loss_pct   = 0
-flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere"
+flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere",
+                "CollectRansom"
 
 [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-01-25 17:59:51.000000000 +0200
+++ freeciv/data/civ2/units.ruleset	2007-01-25 18:08:59.000000000 +0200
@@ -68,6 +68,7 @@
 ; "Unreachable"   = Unit can be attacked only by units with "AttackAny" flag or on
 ;                   city or airbase
 ; "AlwaysSafe"    = Unit is safe even on unsafe terrain
+; "CollectRansom" = Unit can collect ransom when killing lone barbarian leader
 
 [unitclass_missile]
 name          = _("Missile")
@@ -81,7 +82,8 @@
 move_type     = "Land"
 min_speed     = 1
 hp_loss_pct   = 0
-flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere"
+flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere",
+                "CollectRansom"
 
 [unitclass_sea]
 name          = _("Sea")
@@ -95,7 +97,7 @@
 move_type     = "Both"
 min_speed     = 1
 hp_loss_pct   = 10
-flags         = "CanOccupy", "AlwaysSafe"
+flags         = "CanOccupy", "AlwaysSafe", "CollectRansom"
 
 [unitclass_air]
 name          = _("Air")
diff -Nurd -X.diff_ignore freeciv/data/default/units.ruleset freeciv/data/default/units.ruleset
--- freeciv/data/default/units.ruleset	2007-01-25 17:59:51.000000000 +0200
+++ freeciv/data/default/units.ruleset	2007-01-25 18:08:13.000000000 +0200
@@ -74,6 +74,7 @@
 ; "Unreachable"   = Unit can be attacked only by units with "AttackAny" flag or on
 ;                   city or airbase
 ; "AlwaysSafe"    = Unit is safe even on unsafe terrain
+; "CollectRansom" = Unit can collect ransom when killing lone barbarian leader
 
 [unitclass_missile]
 name          = _("Missile")
@@ -87,7 +88,8 @@
 move_type     = "Land"
 min_speed     = 1
 hp_loss_pct   = 0
-flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere"
+flags         = "TerrainSpeed", "DamageSlows", "CanOccupy", "BuildAnywhere",
+                "CollectRansom"
 
 [unitclass_sea]
 name          = _("Sea")
@@ -101,7 +103,7 @@
 move_type     = "Both"
 min_speed     = 1
 hp_loss_pct   = 10
-flags         = "CanOccupy", "AlwaysSafe"
+flags         = "CanOccupy", "AlwaysSafe", "CollectRansom"
 
 [unitclass_air]
 name          = _("Air")
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c	2007-01-25 17:59:51.000000000 +0200
+++ freeciv/server/unittools.c	2007-01-25 18:05:39.000000000 +0200
@@ -1619,7 +1619,9 @@
   /* barbarian leader ransom hack */
   if( is_barbarian(pplayer) && unit_has_role(punit->type, L_BARBARIAN_LEADER)
       && (unit_list_size(punit->tile->units) == 1)
-      && (is_ground_unit(pkiller) || is_heli_unit(pkiller)) ) {
+      && unit_class_flag(get_unit_class(unit_type(pkiller)),
+                         UCF_COLLECT_RANSOM)) {
+    /* Occupying units can collect ransom if leader is alone in the tile */
     ransom = (pplayer->economic.gold >= game.info.ransom_gold) 
              ? game.info.ransom_gold : pplayer->economic.gold;
     notify_player(destroyer, pkiller->tile, E_UNIT_WIN_ATT,
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to