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

 Currently bases have only "ClaimTerritory" flag indicating if they
should claim territory or not. Hardcoded border radius of 5 is used
for all bases that do.

 Attached patch replaces ClaimTerritory flag with border radius
property for each base. In the process civ1 & civ2 rulesets are fixed
so that their fortress has no territory claiming properties.

 Applies on top of #40631


 - ML

diff -Nurd -X.diff_ignore freeciv/client/packhand.c freeciv/client/packhand.c
--- freeciv/client/packhand.c   2009-01-07 15:45:57.000000000 +0200
+++ freeciv/client/packhand.c   2009-01-07 15:54:17.000000000 +0200
@@ -2909,6 +2909,7 @@
   pbase->gui_type = p->gui_type;
 
   pbase->build_time = p->build_time;
+  pbase->border_sq  = p->border_sq;
 
   pbase->flags = p->flags;
 
diff -Nurd -X.diff_ignore freeciv/common/base.c freeciv/common/base.c
--- freeciv/common/base.c       2008-10-27 04:13:30.000000000 +0200
+++ freeciv/common/base.c       2009-01-07 16:03:16.000000000 +0200
@@ -32,7 +32,7 @@
 
 static const char *base_type_flag_names[] = {
   "NoAggressive", "DefenseBonus", "NoStackDeath",
-  "ClaimTerritory", "DiplomatDefense", "ParadropFrom"
+  "DiplomatDefense", "ParadropFrom"
 };
 
 /* This must correspond to enum base_gui_type in base.h */
@@ -302,3 +302,11 @@
 
   return !BV_ISSET(base1->conflicts, base_index(base2));
 }
+
+/**************************************************************************
+  Does this base type claim territory?
+**************************************************************************/
+bool territory_claiming_base(const struct base_type *pbase)
+{
+  return pbase->border_sq > 0;
+}
diff -Nurd -X.diff_ignore freeciv/common/base.h freeciv/common/base.h
--- freeciv/common/base.h       2008-10-27 04:13:30.000000000 +0200
+++ freeciv/common/base.h       2009-01-07 16:03:31.000000000 +0200
@@ -29,7 +29,6 @@
                           * if base is close to city */
   BF_DEFENSE_BONUS,      /* Base provides defense bonus for units inside */
   BF_NO_STACK_DEATH,     /* Units inside will not die all at once */
-  BF_CLAIM_TERRITORY,    /* Base claims tile ownership */
   BF_DIPLOMAT_DEFENSE,   /* Base provides bonus for defending diplomat */
   BF_PARADROP_FROM,      /* Paratroopers can use base for paradrop */
   BF_LAST                /* This has to be last */
@@ -47,6 +46,7 @@
   struct requirement_vector reqs;
   enum base_gui_type gui_type;
   int build_time;
+  int border_sq;
 
   bv_unit_classes native_to;
   bv_base_flags flags;
@@ -91,6 +91,8 @@
 
 bool can_bases_coexist(const struct base_type *base1, const struct base_type 
*base2);
 
+bool territory_claiming_base(const struct base_type *pbase);
+
 /* Initialization and iteration */
 void base_types_init(void);
 void base_types_free(void);
diff -Nurd -X.diff_ignore freeciv/common/borders.c freeciv/common/borders.c
--- freeciv/common/borders.c    2009-01-07 15:59:31.000000000 +0200
+++ freeciv/common/borders.c    2009-01-07 16:04:50.000000000 +0200
@@ -47,8 +47,8 @@
     radius_sq += pcity->size * game.info.border_size_effect;
   } else {
     base_type_iterate(pbase) {
-      if (tile_has_base(ptile, pbase) && base_has_flag(pbase, 
BF_CLAIM_TERRITORY)) {
-        radius_sq = 5;
+      if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) {
+        radius_sq = pbase->border_sq;
         break;
       }
     } base_type_iterate_end;
@@ -68,7 +68,7 @@
 
   if (tile_owner(ptile) != NULL) {
     base_type_iterate(pbase) {
-      if (tile_has_base(ptile, pbase) && base_has_flag(pbase, 
BF_CLAIM_TERRITORY)) {
+      if (tile_has_base(ptile, pbase) && territory_claiming_base(pbase)) {
         return TRUE;
       }
     } base_type_iterate_end;
diff -Nurd -X.diff_ignore freeciv/common/packets.def freeciv/common/packets.def
--- freeciv/common/packets.def  2009-01-07 15:59:31.000000000 +0200
+++ freeciv/common/packets.def  2009-01-07 15:53:54.000000000 +0200
@@ -1318,6 +1318,7 @@
   BASE_GUI gui_type;
   BV_UNIT_CLASSES native_to;
   UINT8 build_time;
+  UINT8 border_sq;
   BV_BASE_FLAGS flags;
 end
 
diff -Nurd -X.diff_ignore freeciv/common/tile.c freeciv/common/tile.c
--- freeciv/common/tile.c       2009-01-07 15:45:57.000000000 +0200
+++ freeciv/common/tile.c       2009-01-07 16:09:56.000000000 +0200
@@ -230,6 +230,23 @@
 }
 
 /****************************************************************************
+  Check if tile contains base providing effect for unit
+****************************************************************************/
+bool tile_has_claimable_base(const struct tile *ptile,
+                             const struct unit_type *punittype)
+{
+  base_type_iterate(pbase) {
+    if (tile_has_base(ptile, pbase)
+        && territory_claiming_base(pbase)
+        && is_native_base_to_uclass(pbase, utype_class(punittype))) {
+      return TRUE;
+    }
+  } base_type_iterate_end;
+
+  return FALSE;
+}
+
+/****************************************************************************
   Check if tile contains base native for unit
 ****************************************************************************/
 bool tile_has_native_base(const struct tile *ptile,
diff -Nurd -X.diff_ignore freeciv/common/tile.h freeciv/common/tile.h
--- freeciv/common/tile.h       2009-01-07 15:45:57.000000000 +0200
+++ freeciv/common/tile.h       2009-01-07 16:11:57.000000000 +0200
@@ -108,6 +108,8 @@
                                  enum base_flag_id flag);
 bool tile_has_native_base(const struct tile *ptile,
                           const struct unit_type *punittype);
+bool tile_has_claimable_base(const struct tile *ptile,
+                             const struct unit_type *punittype);
 
 /* Vision related */
 enum known_type tile_get_known(const struct tile *ptile,
diff -Nurd -X.diff_ignore freeciv/data/civ1/terrain.ruleset 
freeciv/data/civ1/terrain.ruleset
--- freeciv/data/civ1/terrain.ruleset   2008-10-27 04:13:56.000000000 +0200
+++ freeciv/data/civ1/terrain.ruleset   2009-01-07 15:58:24.000000000 +0200
@@ -663,7 +663,10 @@
 ;                           and README.effects for help on requirements)
 ; gui_type                = How gui should handle this base. 
Fortress/Airbase/Other
 ; build_time              = How long it takes for a unit to build this base
-; conflicts               = List of bases that cannot be on the same tile
+; border_sq               = Base will claim land ownership up to this radius
+; conflicts               = List of bases that cannot be on the same tile.
+;                           Bases with non-zero border_sq automatically 
conflict
+;                           with each other.
 ; flags
 ;   - "NoAggressive"      = Units inside are not considered aggressive
 ;   - "DefenseBonus"      = Units inside gain defense bonus
@@ -686,5 +689,5 @@
 gui_type     = "Fortress"
 build_time   = 3
 native_to    = "Land"
-flags        = "NoAggressive", "DefenseBonus", "ClaimTerritory",
+flags        = "NoAggressive", "DefenseBonus",
                "NoStackDeath", "DiplomatDefense"
diff -Nurd -X.diff_ignore freeciv/data/civ2/terrain.ruleset 
freeciv/data/civ2/terrain.ruleset
--- freeciv/data/civ2/terrain.ruleset   2008-10-27 04:13:56.000000000 +0200
+++ freeciv/data/civ2/terrain.ruleset   2009-01-07 15:57:56.000000000 +0200
@@ -778,12 +778,14 @@
 ;                           and README.effects for help on requirements)
 ; gui_type                = How gui should handle this base. 
Fortress/Airbase/Other
 ; build_time              = How long it takes for a unit to build this base
-; conflicts               = List of bases that cannot be on the same tile
+; border_sq               = Base will claim land ownership up to this radius
+; conflicts               = List of bases that cannot be on the same tile.
+;                           Bases with non-zero border_sq automatically 
conflict
+;                           with each other.
 ; flags
 ;   - "NoAggressive"      = Units inside are not considered aggressive
 ;   - "DefenseBonus"      = Units inside gain defense bonus
 ;   - "NoStackDeath"      = Units inside do not die all at once when attacked
-;   - "ClaimTerritory"    = Base will claim land ownership
 ;   - "DiplomatDefense"   = Diplomats inside get bonus to diplomatic defense
 ;   - "ParadropFrom"      = Paradrop can be initiated from base
 
@@ -801,7 +803,7 @@
 gui_type     = "Fortress"
 build_time   = 3
 native_to    = "Land"
-flags        = "NoAggressive", "DefenseBonus", "ClaimTerritory",
+flags        = "NoAggressive", "DefenseBonus",
                "NoStackDeath", "DiplomatDefense"
 
 [base_airbase]
diff -Nurd -X.diff_ignore freeciv/data/default/terrain.ruleset 
freeciv/data/default/terrain.ruleset
--- freeciv/data/default/terrain.ruleset        2008-10-27 04:13:56.000000000 
+0200
+++ freeciv/data/default/terrain.ruleset        2009-01-07 15:51:16.000000000 
+0200
@@ -898,12 +898,14 @@
 ;                           and README.effects for help on requirements)
 ; gui_type                = How gui should handle this base. 
Fortress/Airbase/Other
 ; build_time              = How long it takes for a unit to build this base
-; conflicts               = List of bases that cannot be on the same tile
+; border_sq               = Base will claim land ownership up to this radius
+; conflicts               = List of bases that cannot be on the same tile.
+;                           Bases with non-zero border_sq automatically 
conflict
+;                           with each other.
 ; flags
 ;   - "NoAggressive"      = Units inside are not considered aggressive
 ;   - "DefenseBonus"      = Units inside gain defense bonus
 ;   - "NoStackDeath"      = Units inside do not die all at once when attacked
-;   - "ClaimTerritory"    = Base will claim land ownership
 ;   - "DiplomatDefense"   = Diplomats inside get bonus to diplomatic defense
 ;   - "ParadropFrom"      = Paradrop can be initiated from base
 
@@ -920,8 +922,9 @@
     }
 gui_type     = "Fortress"
 build_time   = 3
+border_sq    = 5
 native_to    = "Land"
-flags        = "NoAggressive", "DefenseBonus", "ClaimTerritory",
+flags        = "NoAggressive", "DefenseBonus",
                "NoStackDeath", "DiplomatDefense"
 
 [base_airbase]
diff -Nurd -X.diff_ignore freeciv/server/maphand.c freeciv/server/maphand.c
--- freeciv/server/maphand.c    2009-01-07 15:59:37.000000000 +0200
+++ freeciv/server/maphand.c    2009-01-07 16:04:52.000000000 +0200
@@ -1578,7 +1578,7 @@
 
     if (!source_tile) {
       base_type_iterate(dbase) {
-        if (tile_has_base(dtile, dbase) && base_has_flag(dbase, 
BF_CLAIM_TERRITORY)) {
+        if (tile_has_base(dtile, dbase) && territory_claiming_base(dbase)) {
           /* Cannot affect territory claiming bases */
           source_tile = TRUE;
           break;
@@ -1611,7 +1611,7 @@
 
     if (!source_tile) {
       base_type_iterate(dbase) {
-        if (tile_has_base(dtile, dbase) && base_has_flag(dbase, 
BF_CLAIM_TERRITORY)) {
+        if (tile_has_base(dtile, dbase) && territory_claiming_base(dbase)) {
           /* Cannot affect territory claiming bases */
           source_tile = TRUE;
           break;
diff -Nurd -X.diff_ignore freeciv/server/ruleset.c freeciv/server/ruleset.c
--- freeciv/server/ruleset.c    2009-01-07 15:59:31.000000000 +0200
+++ freeciv/server/ruleset.c    2009-01-07 16:05:24.000000000 +0200
@@ -2017,6 +2017,8 @@
     }
 
     pbase->build_time = secfile_lookup_int(file, "%s.build_time", section);
+    pbase->border_sq  = secfile_lookup_int_default(file, 0, "%s.border_sq",
+                                                   section);
 
     slist = secfile_lookup_str_vec(file, &nval, "%s.flags", section);
     BV_CLR_ALL(pbase->flags);
@@ -2033,7 +2035,7 @@
         BV_SET(pbase->flags, flag);
       }
     }
-    
+
     free(slist);
 
     slist = secfile_lookup_str_vec(file, &nval, "%s.conflicts", section);
@@ -2054,9 +2056,9 @@
     
     free(slist);
 
-    if (base_has_flag(pbase, BF_CLAIM_TERRITORY)) {
+    if (territory_claiming_base(pbase)) {
       base_type_iterate(pbase2) {
-        if (pbase2 > pbase && base_has_flag(pbase2, BF_CLAIM_TERRITORY)) {
+        if (pbase2 > pbase && territory_claiming_base(pbase2)) {
           BV_SET(pbase->conflicts, base_index(pbase2));
           BV_SET(pbase2->conflicts, base_index(pbase));
         }
@@ -3436,6 +3438,8 @@
     packet.native_to = b->native_to;
 
     packet.gui_type = b->gui_type;
+    packet.build_time = b->build_time;
+    packet.border_sq = b->border_sq;
 
     packet.flags = b->flags;
 
diff -Nurd -X.diff_ignore freeciv/server/savegame.c freeciv/server/savegame.c
--- freeciv/server/savegame.c   2009-01-07 15:59:31.000000000 +0200
+++ freeciv/server/savegame.c   2009-01-07 16:11:01.000000000 +0200
@@ -1900,10 +1900,9 @@
     unit_list_prepend(punit->tile->units, punit);
 
     /* Claim ownership of fortress? */
-    if (tile_has_base_flag_for_unit(punit->tile, unit_type(punit),
-                                    BF_CLAIM_TERRITORY)
-     && (!tile_owner(punit->tile)
-      || pplayers_at_war(tile_owner(punit->tile), plr))) {
+    if (tile_has_claimable_base(punit->tile, unit_type(punit))
+        && (!tile_owner(punit->tile)
+            || pplayers_at_war(tile_owner(punit->tile), plr))) {
       map_claim_ownership(punit->tile, plr, punit->tile);
       map_claim_border(punit->tile, plr);
       /* city_thaw_workers_queue() later */
diff -Nurd -X.diff_ignore freeciv/server/unittools.c freeciv/server/unittools.c
--- freeciv/server/unittools.c  2009-01-07 15:45:57.000000000 +0200
+++ freeciv/server/unittools.c  2009-01-07 16:18:36.000000000 +0200
@@ -729,7 +729,7 @@
 
        if (what != S_LAST) {
           if (what == S_PILLAGE_BASE) {
-            if (base_has_flag(first_base, BF_CLAIM_TERRITORY)) {
+            if (territory_claiming_base(first_base)) {
               map_clear_border(ptile);
               map_claim_ownership(ptile, NULL, NULL);
             }
@@ -799,7 +799,7 @@
       base_type_iterate(old_base) {
         if (tile_has_base(ptile, old_base)
             && !can_bases_coexist(old_base, new_base)) {
-          if (base_has_flag(old_base, BF_CLAIM_TERRITORY)) {
+          if (territory_claiming_base(old_base)) {
             map_clear_border(ptile);
             map_claim_ownership(ptile, NULL, NULL);
           }
@@ -814,7 +814,7 @@
       unit_list_refresh_vision(ptile->units);
 
       /* Claim base if it has "ClaimTerritory" flag */
-      if (base_has_flag(new_base, BF_CLAIM_TERRITORY)) {
+      if (territory_claiming_base(new_base)) {
         map_claim_ownership(ptile, unit_owner(punit), ptile);
         map_claim_border(ptile, unit_owner(punit));
         city_thaw_workers_queue();
@@ -2800,9 +2800,9 @@
     ASSERT_VISION(new_vision);
 
     /* Claim ownership of fortress? */
-    if (tile_has_base_flag_for_unit(pdesttile, unit_type(punit),
-                                    BF_CLAIM_TERRITORY)
-        && (!tile_owner(pdesttile) || pplayers_at_war(tile_owner(pdesttile), 
pplayer))) {
+    if (tile_has_claimable_base(pdesttile, unit_type(punit))
+        && (!tile_owner(pdesttile)
+            || pplayers_at_war(tile_owner(pdesttile), pplayer))) {
       map_claim_ownership(pdesttile, pplayer, pdesttile);
       map_claim_border(pdesttile, pplayer);
       city_thaw_workers_queue();
diff -Nurd -X.diff_ignore freeciv/version.in freeciv/version.in
--- freeciv/version.in  2009-01-07 15:59:31.000000000 +0200
+++ freeciv/version.in  2009-01-07 15:55:28.000000000 +0200
@@ -23,5 +23,5 @@
 #   - Avoid adding a new mandatory capability to the development branch for
 #     as long as possible.  We want to maintain network compatibility with
 #     the stable branch for as long as possible.
-NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel.2009.Jan.06"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel.2009.Jan.07"
 NETWORK_CAPSTRING_OPTIONAL=""
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to