Author: cazfi
Date: Sun Jan 11 16:30:12 2015
New Revision: 27620

URL: http://svn.gna.org/viewcvs/freeciv?rev=27620&view=rev
Log:
Cache extras providing defense bonus to a list of their own.

See patch #5664

Modified:
    trunk/client/packhand.c
    trunk/common/fc_types.h
    trunk/common/tile.c
    trunk/server/ruleset.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=27620&r1=27619&r2=27620&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Sun Jan 11 16:30:12 2015
@@ -3419,6 +3419,10 @@
   pextra->removal_time_factor = p->removal_time_factor;
   pextra->defense_bonus = p->defense_bonus;
 
+  if (pextra->defense_bonus != 0) {
+    extra_to_caused_by_list(pextra, EC_DEFENSIVE);
+  }
+
   pextra->native_to = p->native_to;
 
   pextra->flags = p->flags;

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=27620&r1=27619&r2=27620&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Sun Jan 11 16:30:12 2015
@@ -575,7 +575,8 @@
 #include "specenum_gen.h"
 #define EC_NONE EC_COUNT
 #define EC_SPECIAL (EC_NONE + 1)
-#define EC_LAST (EC_NONE + 2)
+#define EC_DEFENSIVE (EC_NONE + 2)
+#define EC_LAST (EC_NONE + 3)
 
 /* 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=27620&r1=27619&r2=27620&view=diff
==============================================================================
--- trunk/common/tile.c (original)
+++ trunk/common/tile.c Sun Jan 11 16:30:12 2015
@@ -244,12 +244,12 @@
 {
   int bonus = 0;
 
-  extra_type_iterate(pextra) {
+  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;
     }
-  } extra_type_iterate_end;
+  } extra_type_by_cause_iterate_end;
 
   return bonus;
 }

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=27620&r1=27619&r2=27620&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Sun Jan 11 16:30:12 2015
@@ -2862,6 +2862,9 @@
       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);
+      }
 
       slist = secfile_lookup_str_vec(file, &nval, "%s.native_to", section);
       BV_CLR_ALL(pextra->native_to);


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

Reply via email to