Author: cazfi
Date: Sun Aug 30 13:37:09 2015
New Revision: 29732

URL: http://svn.gna.org/viewcvs/freeciv?rev=29732&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:
    trunk/client/packhand.c
    trunk/common/extras.h
    trunk/common/fc_types.h
    trunk/common/tile.c
    trunk/data/alien/terrain.ruleset
    trunk/data/civ1/terrain.ruleset
    trunk/data/civ2/terrain.ruleset
    trunk/data/civ2civ3/terrain.ruleset
    trunk/data/classic/terrain.ruleset
    trunk/data/experimental/terrain.ruleset
    trunk/data/multiplayer/terrain.ruleset
    trunk/data/stub/terrain.ruleset
    trunk/fc_version
    trunk/server/ruleset.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Sun Aug 30 13:37:09 2015
@@ -3509,7 +3509,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: trunk/common/extras.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/extras.h?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/common/extras.h       (original)
+++ trunk/common/extras.h       Sun Aug 30 13:37:09 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: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Sun Aug 30 13:37:09 2015
@@ -612,7 +612,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: trunk/common/tile.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/tile.c?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/common/tile.c (original)
+++ trunk/common/tile.c Sun Aug 30 13:37:09 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: trunk/data/alien/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/alien/terrain.ruleset    (original)
+++ trunk/data/alien/terrain.ruleset    Sun Aug 30 13:37:09 2015
@@ -650,6 +650,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: trunk/data/civ1/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/civ1/terrain.ruleset     (original)
+++ trunk/data/civ1/terrain.ruleset     Sun Aug 30 13:37:09 2015
@@ -807,6 +807,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
 ;
@@ -993,6 +1000,7 @@
 rmact_gfx_alt  = "-"
 buildable      = FALSE
 native_to      = "Land"
+flags          = "NaturalDefense"
 helptext       = _("\
 Any land terrain type may have a River on it.\
 "), _("\

Modified: trunk/data/civ2/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/civ2/terrain.ruleset     (original)
+++ trunk/data/civ2/terrain.ruleset     Sun Aug 30 13:37:09 2015
@@ -913,6 +913,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
 ;
@@ -1151,6 +1158,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: trunk/data/civ2civ3/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/civ2civ3/terrain.ruleset (original)
+++ trunk/data/civ2civ3/terrain.ruleset Sun Aug 30 13:37:09 2015
@@ -1102,6 +1102,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: trunk/data/classic/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/classic/terrain.ruleset  (original)
+++ trunk/data/classic/terrain.ruleset  Sun Aug 30 13:37:09 2015
@@ -1092,6 +1092,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: trunk/data/experimental/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/experimental/terrain.ruleset     (original)
+++ trunk/data/experimental/terrain.ruleset     Sun Aug 30 13:37:09 2015
@@ -1068,6 +1068,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: trunk/data/multiplayer/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/multiplayer/terrain.ruleset      (original)
+++ trunk/data/multiplayer/terrain.ruleset      Sun Aug 30 13:37:09 2015
@@ -1066,6 +1066,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: trunk/data/stub/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/terrain.ruleset?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/data/stub/terrain.ruleset     (original)
+++ trunk/data/stub/terrain.ruleset     Sun Aug 30 13:37:09 2015
@@ -363,6 +363,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: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Sun Aug 30 13:37:09 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-3.0-2015.Aug.30"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Aug.30b"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=29732&r1=29731&r2=29732&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Sun Aug 30 13:37:09 2015
@@ -2914,7 +2914,11 @@
                                                           "%s.defense_bonus",
                                                           section);
       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->appearance_chance = secfile_lookup_int_default(file, 
RS_DEFAULT_EXTRA_APPEARANCE,


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

Reply via email to