Author: cazfi
Date: Wed Dec  9 21:59:02 2015
New Revision: 30918

URL: http://svn.gna.org/viewcvs/freeciv?rev=30918&view=rev
Log:
Category "Bonus" extras get entered as huts, not those extras that were created 
for the
cause Hut.

See patch #6613

Modified:
    branches/S2_6/client/packhand.c
    branches/S2_6/common/extras.c
    branches/S2_6/common/extras.h
    branches/S2_6/common/fc_types.h
    branches/S2_6/server/ruleset.c
    branches/S2_6/server/unittools.c

Modified: branches/S2_6/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/packhand.c?rev=30918&r1=30917&r2=30918&view=diff
==============================================================================
--- branches/S2_6/client/packhand.c     (original)
+++ branches/S2_6/client/packhand.c     Wed Dec  9 21:59:02 2015
@@ -3474,6 +3474,8 @@
   pextra->causes = p->causes;
   pextra->rmcauses = p->rmcauses;
 
+  extra_to_category_list(pextra, pextra->category);
+
   if (pextra->causes == 0) {
     extra_to_caused_by_list(pextra, EC_NONE);
   } else {

Modified: branches/S2_6/common/extras.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/extras.c?rev=30918&r1=30917&r2=30918&view=diff
==============================================================================
--- branches/S2_6/common/extras.c       (original)
+++ branches/S2_6/common/extras.c       Wed Dec  9 21:59:02 2015
@@ -29,6 +29,7 @@
 
 static struct extra_type extras[MAX_EXTRA_TYPES];
 
+static struct extra_type_list *category_extra[ECAT_COUNT];
 static struct extra_type_list *caused_by[EC_LAST];
 static struct extra_type_list *removed_by[ERM_COUNT];
 
@@ -44,6 +45,9 @@
   }
   for (i = 0; i < ERM_COUNT; i++) {
     removed_by[i] = extra_type_list_new();
+  }
+  for (i = 0; i < ECAT_COUNT; i++) {
+    category_extra[i] = extra_type_list_new();
   }
 
   for (i = 0; i < MAX_EXTRA_TYPES; i++) {
@@ -91,6 +95,11 @@
     removed_by[i] = NULL;
   }
 
+  for (i = 0; i < ECAT_COUNT; i++) {
+    extra_type_list_destroy(category_extra[i]);
+    category_extra[i] = NULL;
+  }
+
   for (i = 0; i < MAX_EXTRA_TYPES; i++) {
     requirement_vector_free(&(extras[i].reqs));
     requirement_vector_free(&(extras[i].rmreqs));
@@ -230,6 +239,16 @@
 }
 
 /**************************************************************************
+  Returns extra types of the category.
+**************************************************************************/
+struct extra_type_list *extra_type_list_for_category(enum extra_category cat)
+{
+  fc_assert(cat < ECAT_LAST);
+
+  return category_extra[cat];
+}
+
+/**************************************************************************
   Return random extra type for given cause that is native to the tile.
 **************************************************************************/
 struct extra_type *rand_extra_for_tile(struct tile *ptile, enum extra_cause 
cause)
@@ -264,6 +283,16 @@
   fc_assert(cause < EC_LAST);
 
   extra_type_list_append(caused_by[cause], pextra);
+}
+
+/**************************************************************************
+  Add extra type to list of extras of a category
+**************************************************************************/
+void extra_to_category_list(struct extra_type *pextra, enum extra_category cat)
+{
+  fc_assert(cat < ECAT_LAST);
+
+  extra_type_list_append(category_extra[cat], pextra);
 }
 
 /**************************************************************************

Modified: branches/S2_6/common/extras.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/extras.h?rev=30918&r1=30917&r2=30918&view=diff
==============================================================================
--- branches/S2_6/common/extras.h       (original)
+++ branches/S2_6/common/extras.h       Wed Dec  9 21:59:02 2015
@@ -152,6 +152,9 @@
 struct extra_type_list *extra_type_list_by_cause(enum extra_cause cause);
 struct extra_type *rand_extra_for_tile(struct tile *ptile, enum extra_cause 
cause);
 
+void extra_to_category_list(struct extra_type *pextra, enum extra_category 
cat);
+struct extra_type_list *extra_type_list_for_category(enum extra_category cat);
+
 bool is_extra_caused_by(const struct extra_type *pextra, enum extra_cause 
cause);
 bool is_extra_caused_by_worker_action(const struct extra_type *pextra);
 bool is_extra_caused_by_action(const struct extra_type *pextra,
@@ -249,6 +252,17 @@
   } extra_type_list_iterate_rev_end                      \
 }
 
+#define extra_type_by_category_iterate(_cat, _extra)                \
+{                                                                   \
+  struct extra_type_list *_etl_##_extra = extra_type_list_for_category(_cat); \
+  if (_etl_##_extra != NULL) {                                              \
+    extra_type_list_iterate(_etl_##_extra, _extra) {
+
+#define extra_type_by_category_iterate_end                 \
+    } extra_type_list_iterate_end                          \
+  }                                                        \
+}
+
 #define extra_deps_iterate(_reqs, _dep)                 \
 {                                                       \
   requirement_vector_iterate(_reqs, preq) {             \

Modified: branches/S2_6/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/common/fc_types.h?rev=30918&r1=30917&r2=30918&view=diff
==============================================================================
--- branches/S2_6/common/fc_types.h     (original)
+++ branches/S2_6/common/fc_types.h     Wed Dec  9 21:59:02 2015
@@ -594,6 +594,7 @@
 #define SPECENUM_COUNT ECAT_COUNT
 #include "specenum_gen.h"
 #define ECAT_NONE ECAT_COUNT
+#define ECAT_LAST ECAT_COUNT
 
 /* Used in the network protocol. */
 #define SPECENUM_NAME extra_cause

Modified: branches/S2_6/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/ruleset.c?rev=30918&r1=30917&r2=30918&view=diff
==============================================================================
--- branches/S2_6/server/ruleset.c      (original)
+++ branches/S2_6/server/ruleset.c      Wed Dec  9 21:59:02 2015
@@ -2822,6 +2822,8 @@
           extra_to_caused_by_list(pextra, cause);
         }
       }
+
+      extra_to_category_list(pextra, pextra->category);
 
       if (pextra->causes == 0) {
         /* Extras that do not have any causes added to EC_NONE list */

Modified: branches/S2_6/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/server/unittools.c?rev=30918&r1=30917&r2=30918&view=diff
==============================================================================
--- branches/S2_6/server/unittools.c    (original)
+++ branches/S2_6/server/unittools.c    Wed Dec  9 21:59:02 2015
@@ -2825,7 +2825,7 @@
     return;
   }
 
-  extra_type_by_cause_iterate(EC_HUT, pextra) {
+  extra_type_by_category_iterate(ECAT_BONUS, pextra) {
     if (tile_has_extra(ptile, pextra)) {
       pplayer->server.huts++;
 
@@ -2849,7 +2849,7 @@
       script_server_signal_emit("hut_enter", 1,
                                 API_TYPE_UNIT, punit);
     }
-  } extra_type_by_cause_iterate_end;
+  } extra_type_by_category_iterate_end;
 
   send_player_info_c(pplayer, pplayer->connections); /* eg, gold */
   return;


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

Reply via email to