Author: cazfi
Date: Wed Dec  9 21:58:56 2015
New Revision: 30917

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

See patch #6613

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

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=30917&r1=30916&r2=30917&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Wed Dec  9 21:58:56 2015
@@ -3524,6 +3524,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: trunk/common/extras.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/extras.c?rev=30917&r1=30916&r2=30917&view=diff
==============================================================================
--- trunk/common/extras.c       (original)
+++ trunk/common/extras.c       Wed Dec  9 21:58:56 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++) {
@@ -93,6 +97,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));
@@ -234,6 +243,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)
@@ -268,6 +287,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: trunk/common/extras.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/extras.h?rev=30917&r1=30916&r2=30917&view=diff
==============================================================================
--- trunk/common/extras.h       (original)
+++ trunk/common/extras.h       Wed Dec  9 21:58:56 2015
@@ -156,6 +156,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,
@@ -258,6 +261,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: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=30917&r1=30916&r2=30917&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Wed Dec  9 21:58:56 2015
@@ -621,6 +621,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: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=30917&r1=30916&r2=30917&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Wed Dec  9 21:58:56 2015
@@ -2837,6 +2837,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: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=30917&r1=30916&r2=30917&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Wed Dec  9 21:58:56 2015
@@ -2845,7 +2845,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++;
 
@@ -2869,7 +2869,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