Author: cazfi
Date: Tue Mar 24 03:31:46 2015
New Revision: 28603

URL: http://svn.gna.org/viewcvs/freeciv?rev=28603&view=rev
Log:
Added spontaneous appearance requirements for extras, replacing hardcoded 
requirement
that extra of the same type must already be in adjacent tile.

See patch #5941

Modified:
    trunk/client/packhand.c
    trunk/common/extras.c
    trunk/common/extras.h
    trunk/common/packets.def
    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
    trunk/tools/ruledit/rulesave.c

Modified: trunk/client/packhand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/packhand.c?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/client/packhand.c     (original)
+++ trunk/client/packhand.c     Tue Mar 24 03:31:46 2015
@@ -3413,6 +3413,11 @@
   }
   fc_assert(pextra->rmreqs.size == p->rmreqs_count);
 
+  for (i = 0; i < p->spontaneous_reqs_count; i++) {
+    requirement_vector_append(&pextra->spontaneous_reqs, 
p->spontaneous_reqs[i]);
+  }
+  fc_assert(pextra->spontaneous_reqs.size == p->spontaneous_reqs_count);
+
   pextra->buildable = p->buildable;
   pextra->build_time = p->build_time;
   pextra->build_time_factor = p->build_time_factor;

Modified: trunk/common/extras.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/extras.c?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/common/extras.c       (original)
+++ trunk/common/extras.c       Tue Mar 24 03:31:46 2015
@@ -48,6 +48,7 @@
   for (i = 0; i < MAX_EXTRA_TYPES; i++) {
     requirement_vector_init(&(extras[i].reqs));
     requirement_vector_init(&(extras[i].rmreqs));
+    requirement_vector_init(&(extras[i].spontaneous_reqs));
     extras[i].id = i;
     extras[i].hiders = NULL;
     extras[i].data.special_idx = -1;
@@ -93,6 +94,7 @@
   for (i = 0; i < MAX_EXTRA_TYPES; i++) {
     requirement_vector_free(&(extras[i].reqs));
     requirement_vector_free(&(extras[i].rmreqs));
+    requirement_vector_free(&(extras[i].spontaneous_reqs));
 
     if (NULL != extras[i].helptext) {
       strvec_destroy(extras[i].helptext);
@@ -799,5 +801,7 @@
   return !tile_has_extra(ptile, pextra)
     && is_native_tile_to_extra(pextra, ptile)
     && !extra_conflicting_on_tile(pextra, ptile)
-    && is_extra_near_tile(ptile, pextra);
-}
+    && are_reqs_active(NULL, tile_owner(ptile), NULL, NULL, ptile,
+                       NULL, NULL, NULL, NULL,
+                       &pextra->spontaneous_reqs, RPT_CERTAIN);
+}

Modified: trunk/common/extras.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/extras.h?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/common/extras.h       (original)
+++ trunk/common/extras.h       Tue Mar 24 03:31:46 2015
@@ -71,6 +71,7 @@
 
   struct requirement_vector reqs;
   struct requirement_vector rmreqs;
+  struct requirement_vector spontaneous_reqs;
 
   /* 'buildable' is unclean. Clean solution would be to rely solely on 
extra_cause:
    * if the extra cannot be built, it's not in the cause's list.

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Tue Mar 24 03:31:46 2015
@@ -1555,6 +1555,8 @@
   REQUIREMENT reqs[MAX_NUM_REQS:reqs_count];
   UINT8 rmreqs_count;
   REQUIREMENT rmreqs[MAX_NUM_REQS:rmreqs_count];
+  UINT8 spontaneous_reqs_count;
+  REQUIREMENT spontaneous_reqs[MAX_NUM_REQS:rmreqs_count];
   BOOL buildable;
   UINT8 build_time;
   UINT8 build_time_factor;

Modified: trunk/data/alien/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/alien/terrain.ruleset    (original)
+++ trunk/data/alien/terrain.ruleset    Tue Mar 24 03:31:46 2015
@@ -591,6 +591,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/data/civ1/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/civ1/terrain.ruleset     (original)
+++ trunk/data/civ1/terrain.ruleset     Tue Mar 24 03:31:46 2015
@@ -748,6 +748,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/data/civ2/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/civ2/terrain.ruleset     (original)
+++ trunk/data/civ2/terrain.ruleset     Tue Mar 24 03:31:46 2015
@@ -854,6 +854,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/data/civ2civ3/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/civ2civ3/terrain.ruleset (original)
+++ trunk/data/civ2civ3/terrain.ruleset Tue Mar 24 03:31:46 2015
@@ -1043,6 +1043,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/data/classic/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/classic/terrain.ruleset  (original)
+++ trunk/data/classic/terrain.ruleset  Tue Mar 24 03:31:46 2015
@@ -1033,6 +1033,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/data/experimental/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/experimental/terrain.ruleset     (original)
+++ trunk/data/experimental/terrain.ruleset     Tue Mar 24 03:31:46 2015
@@ -1009,6 +1009,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/data/multiplayer/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/multiplayer/terrain.ruleset      (original)
+++ trunk/data/multiplayer/terrain.ruleset      Tue Mar 24 03:31:46 2015
@@ -1007,6 +1007,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/data/stub/terrain.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/terrain.ruleset?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/data/stub/terrain.ruleset     (original)
+++ trunk/data/stub/terrain.ruleset     Tue Mar 24 03:31:46 2015
@@ -304,6 +304,7 @@
 ; reqs                    = requirements to build the extra (see 
effects.ruleset
 ;                           and README.effects for help on requirements)
 ; rmreqs                  = requirements to remove the extra
+; spontaneous_reqs        = spontaneous appearance requirements
 ; buildable               = Can extra be built? Defaults to TRUE
 ; build_time              = how long it takes a unit to build this extra.
 ;                           Value of 0 (default) means that terrain- and

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Tue Mar 24 03:31:46 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.Mar.21"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.Mar.24"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Tue Mar 24 03:31:46 2015
@@ -2846,6 +2846,13 @@
         break;
       }
       requirement_vector_copy(&pextra->rmreqs, reqs);
+
+      reqs = lookup_req_list(file, section, "spontaneous_reqs", 
extra_rule_name(pextra));
+      if (reqs == NULL) {
+        ok = FALSE;
+        break;
+      }
+      requirement_vector_copy(&pextra->spontaneous_reqs, reqs);
 
       pextra->buildable = secfile_lookup_bool_default(file, TRUE,
                                                       "%s.buildable", section);
@@ -6086,6 +6093,12 @@
     } requirement_vector_iterate_end;
     packet.rmreqs_count = j;
 
+    j = 0;
+    requirement_vector_iterate(&e->spontaneous_reqs, preq) {
+      packet.spontaneous_reqs[j++] = *preq;
+    } requirement_vector_iterate_end;
+    packet.spontaneous_reqs_count = j;
+
     packet.buildable = e->buildable;
     packet.build_time = e->build_time;
     packet.build_time_factor = e->build_time_factor;

Modified: trunk/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/rulesave.c?rev=28603&r1=28602&r2=28603&view=diff
==============================================================================
--- trunk/tools/ruledit/rulesave.c      (original)
+++ trunk/tools/ruledit/rulesave.c      Tue Mar 24 03:31:46 2015
@@ -1813,6 +1813,7 @@
 
     save_reqs_vector(sfile, &(pextra->reqs), path, "reqs");
     save_reqs_vector(sfile, &(pextra->rmreqs), path, "rmreqs");
+    save_reqs_vector(sfile, &(pextra->spontaneous_reqs), path, 
"spontaneous_reqs");
 
     if (!pextra->buildable) {
       secfile_insert_bool(sfile, pextra->buildable, "%s.buildable", path);


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

Reply via email to