Author: cazfi
Date: Sun Aug 30 13:37:27 2015
New Revision: 29733

URL: http://svn.gna.org/viewcvs/freeciv?rev=29733&view=rev
Log:
Added support for "NaturalDefense" flag for extras to select between two 
defense layers
for which the defense bonus of the extra counts.
This is used in civ/2 rulesets to restore the multiplicative nature of the 
defense bonuses
between River and Fortress.

civ/2 regression reported by Jacob Nevins <jtn>

See bug #23143

Modified:
    branches/S2_6/client/packhand.c
    branches/S2_6/common/extras.h
    branches/S2_6/common/fc_types.h
    branches/S2_6/common/tile.c
    branches/S2_6/data/alien/terrain.ruleset
    branches/S2_6/data/civ1/terrain.ruleset
    branches/S2_6/data/civ2/terrain.ruleset
    branches/S2_6/data/civ2civ3/terrain.ruleset
    branches/S2_6/data/classic/terrain.ruleset
    branches/S2_6/data/experimental/terrain.ruleset
    branches/S2_6/data/multiplayer/terrain.ruleset
    branches/S2_6/data/stub/terrain.ruleset
    branches/S2_6/fc_version
    branches/S2_6/server/ruleset.c

Modified: branches/S2_6/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/packhand.c?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/client/packhand.c     (original)
+++ branches/S2_6/client/packhand.c     Sun Aug 30 13:37:27 2015
@@ -3455,7 +3455,11 @@
   pextra->defense_bonus = p->defense_bonus;
 
   if (pextra->defense_bonus != 0) {
-    extra_to_caused_by_list(pextra, EC_DEFENSIVE);
+    if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
+      extra_to_caused_by_list(pextra, EC_NATURAL_DEFENSIVE);
+    } else {
+      extra_to_caused_by_list(pextra, EC_DEFENSIVE);
+    }
   }
 
   pextra->native_to = p->native_to;

Modified: branches/S2_6/common/extras.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/extras.h?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/common/extras.h       (original)
+++ branches/S2_6/common/extras.h       Sun Aug 30 13:37:27 2015
@@ -51,6 +51,10 @@
 /* Owner's flag will be shown on the tile */
 #define SPECENUM_VALUE8 EF_SHOW_FLAG
 #define SPECENUM_VALUE8NAME "ShowFlag"
+/* Extra's defense bonus will be counted to
+ * separate "Natural" defense layer. */
+#define SPECENUM_VALUE9 EF_NATURAL_DEFENSE
+#define SPECENUM_VALUE9NAME "NaturalDefense"
 #define SPECENUM_COUNT EF_COUNT
 #define SPECENUM_BITVECTOR bv_extra_flags
 #include "specenum_gen.h"

Modified: branches/S2_6/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/fc_types.h?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/common/fc_types.h     (original)
+++ branches/S2_6/common/fc_types.h     Sun Aug 30 13:37:27 2015
@@ -604,7 +604,8 @@
 #define EC_NONE EC_COUNT
 #define EC_SPECIAL (EC_NONE + 1)
 #define EC_DEFENSIVE (EC_NONE + 2)
-#define EC_LAST (EC_NONE + 3)
+#define EC_NATURAL_DEFENSIVE (EC_NONE + 3)
+#define EC_LAST (EC_NONE + 4)
 
 /* Used in the network protocol. */
 #define SPECENUM_NAME extra_rmcause

Modified: branches/S2_6/common/tile.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/tile.c?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/common/tile.c (original)
+++ branches/S2_6/common/tile.c Sun Aug 30 13:37:27 2015
@@ -238,21 +238,32 @@
 }
 
 /****************************************************************************
-  Calculate defense bonus given for unit class by bases and roads
+  Calculate defense bonus given for unit class by extras.
 ****************************************************************************/
 int tile_extras_class_defense_bonus(const struct tile *ptile,
                                     const struct unit_class *pclass)
 {
-  int bonus = 0;
+  int natural_bonus = 0;
+  int fortification_bonus = 0;
+  int total_bonus;
+
+  extra_type_by_cause_iterate(EC_NATURAL_DEFENSIVE, pextra) {
+    if (tile_has_extra(ptile, pextra)
+        && is_native_extra_to_uclass(pextra, pclass)) {
+      natural_bonus += pextra->defense_bonus;
+    }
+  } extra_type_by_cause_iterate_end;
 
   extra_type_by_cause_iterate(EC_DEFENSIVE, pextra) {
     if (tile_has_extra(ptile, pextra)
         && is_native_extra_to_uclass(pextra, pclass)) {
-      bonus += pextra->defense_bonus;
+      fortification_bonus += pextra->defense_bonus;
     }
   } extra_type_by_cause_iterate_end;
 
-  return bonus;
+  total_bonus = (100 + natural_bonus) * (100 + fortification_bonus) / 100 - 
100;
+
+  return total_bonus;
 }
 
 /****************************************************************************

Modified: branches/S2_6/data/alien/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/alien/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/alien/terrain.ruleset    (original)
+++ branches/S2_6/data/alien/terrain.ruleset    Sun Aug 30 13:37:27 2015
@@ -638,6 +638,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;

Modified: branches/S2_6/data/civ1/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ1/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/civ1/terrain.ruleset     (original)
+++ branches/S2_6/data/civ1/terrain.ruleset     Sun Aug 30 13:37:27 2015
@@ -795,6 +795,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;
@@ -981,6 +988,7 @@
 rmact_gfx_alt  = "-"
 buildable      = FALSE
 native_to      = "Land"
+flags          = "NaturalDefense"
 helptext       = _("\
 Any land terrain type may have a River on it.\
 "), _("\

Modified: branches/S2_6/data/civ2/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/civ2/terrain.ruleset     (original)
+++ branches/S2_6/data/civ2/terrain.ruleset     Sun Aug 30 13:37:27 2015
@@ -901,6 +901,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;
@@ -1139,6 +1146,7 @@
 buildable      = FALSE
 defense_bonus  = 50
 native_to      = "Land"
+flags          = "NaturalDefense"
 ; /* xgettext:no-c-format */
 helptext       = _("\
 Any land terrain type may have a River on it.  A River adds 1\

Modified: branches/S2_6/data/civ2civ3/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/civ2civ3/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/civ2civ3/terrain.ruleset (original)
+++ branches/S2_6/data/civ2civ3/terrain.ruleset Sun Aug 30 13:37:27 2015
@@ -1090,6 +1090,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;

Modified: branches/S2_6/data/classic/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/classic/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/classic/terrain.ruleset  (original)
+++ branches/S2_6/data/classic/terrain.ruleset  Sun Aug 30 13:37:27 2015
@@ -1080,6 +1080,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;

Modified: branches/S2_6/data/experimental/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/experimental/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/experimental/terrain.ruleset     (original)
+++ branches/S2_6/data/experimental/terrain.ruleset     Sun Aug 30 13:37:27 2015
@@ -1056,6 +1056,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;

Modified: branches/S2_6/data/multiplayer/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/multiplayer/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/multiplayer/terrain.ruleset      (original)
+++ branches/S2_6/data/multiplayer/terrain.ruleset      Sun Aug 30 13:37:27 2015
@@ -1054,6 +1054,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;

Modified: branches/S2_6/data/stub/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/data/stub/terrain.ruleset?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/data/stub/terrain.ruleset     (original)
+++ branches/S2_6/data/stub/terrain.ruleset     Sun Aug 30 13:37:27 2015
@@ -351,6 +351,13 @@
 ;   - "NuclearWinter"     = Instances of this extra on map count towards
 ;                           Nuclear Winter
 ;   - "ShowFlag"          = Draw owner's flag
+;   - "NaturalDefense"    = Extra's defense bonus will be counted to "Natural"
+;                           defense layer. The defense bonus of all the extras
+;                           located at the tile, native to defending unit,
+;                           is calculated as a 1 + sum of bonuses from the 
extras
+;                           on the default "Fortification" defense layer 
multiplied
+;                           by the 1 + sum of bonuses from the extras on the
+;                           "Natural" layer.
 ; helptext                = optional help text string; should escape all raw
 ;                           newlines so that xgettext parsing works
 ;

Modified: branches/S2_6/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/fc_version?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/fc_version    (original)
+++ branches/S2_6/fc_version    Sun Aug 30 13:37:27 2015
@@ -54,7 +54,7 @@
 #   - 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-2.6-2015.Aug.23"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-2.6-2015.Aug.30"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: branches/S2_6/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/ruleset.c?rev=29733&r1=29732&r2=29733&view=diff
==============================================================================
--- branches/S2_6/server/ruleset.c      (original)
+++ branches/S2_6/server/ruleset.c      Sun Aug 30 13:37:27 2015
@@ -2884,8 +2884,12 @@
       pextra->defense_bonus  = secfile_lookup_int_default(file, 0,
                                                           "%s.defense_bonus",
                                                           section);
-      if (pextra->defense_bonus != 0) { 
-        extra_to_caused_by_list(pextra, EC_DEFENSIVE);
+      if (pextra->defense_bonus != 0) {
+        if (extra_has_flag(pextra, EF_NATURAL_DEFENSE)) {
+          extra_to_caused_by_list(pextra, EC_NATURAL_DEFENSIVE);
+        } else {
+          extra_to_caused_by_list(pextra, EC_DEFENSIVE);
+        }
       }
 
       slist = secfile_lookup_str_vec(file, &nval, "%s.native_to", section);


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to