Author: sveinung
Date: Tue May 19 14:47:34 2015
New Revision: 29109

URL: http://svn.gna.org/viewcvs/freeciv?rev=29109&view=rev
Log:
Let rulesets force establish trade route

Allow a ruleset to forbid units from entering the marketplace when a
trade route can be established in stead. That was the behavior before
Enter Marketplace was split from Establish Trade Route.

Should probably be generalized in the future. Had to be done like this so it
could be ready in time for 2.6.

This change doesn't make any bundled ruleset use the support.

See patch #6091

Modified:
    trunk/common/actions.c
    trunk/common/game.h
    trunk/common/packets.def
    trunk/data/alien/game.ruleset
    trunk/data/civ1/game.ruleset
    trunk/data/civ2/game.ruleset
    trunk/data/civ2civ3/game.ruleset
    trunk/data/classic/game.ruleset
    trunk/data/experimental/game.ruleset
    trunk/data/multiplayer/game.ruleset
    trunk/data/stub/game.ruleset
    trunk/doc/README.actions
    trunk/fc_version
    trunk/server/ruleset.c
    trunk/tools/ruledit/rulesave.c

Modified: trunk/common/actions.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/actions.c?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/common/actions.c      (original)
+++ trunk/common/actions.c      Tue May 19 14:47:34 2015
@@ -543,6 +543,15 @@
       return FALSE;
     }
 
+    /* Allow a ruleset to forbid units from entering the marketplace if a
+     * trade route can be established in stead. */
+    if (wanted_action == ACTION_MARKETPLACE
+        && game.info.force_trade_route
+        && is_action_enabled_unit_on_city(ACTION_TRADE_ROUTE,
+                                          actor_unit, target_city)) {
+      return FALSE;
+    }
+
     /* There are more restrictions on establishing a trade route than on
      * entering the market place. */
     if (wanted_action == ACTION_TRADE_ROUTE &&

Modified: trunk/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/game.h?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/common/game.h (original)
+++ trunk/common/game.h Tue May 19 14:47:34 2015
@@ -748,6 +748,8 @@
 #define RS_MIN_BASE_TECH_COST                    0
 #define RS_MAX_BASE_TECH_COST                    200
 
+#define RS_DEFAULT_FORCE_TRADE_ROUTE             FALSE
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Tue May 19 14:47:34 2015
@@ -521,6 +521,7 @@
   UINT32 timeout;
   BOOL tired_attack;
   UINT16 trademindist;
+  BOOL force_trade_route;
   BOOL trading_city;
   BOOL trading_gold;
   BOOL trading_tech;

Modified: trunk/data/alien/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/alien/game.ruleset       (original)
+++ trunk/data/alien/game.ruleset       Tue May 19 14:47:34 2015
@@ -168,6 +168,11 @@
 tired_attack = TRUE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/data/civ1/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/civ1/game.ruleset        (original)
+++ trunk/data/civ1/game.ruleset        Tue May 19 14:47:34 2015
@@ -154,6 +154,11 @@
 tired_attack = TRUE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/data/civ2/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/civ2/game.ruleset        (original)
+++ trunk/data/civ2/game.ruleset        Tue May 19 14:47:34 2015
@@ -148,6 +148,11 @@
 tired_attack = TRUE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/data/civ2civ3/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/civ2civ3/game.ruleset    (original)
+++ trunk/data/civ2civ3/game.ruleset    Tue May 19 14:47:34 2015
@@ -181,6 +181,11 @@
 tired_attack = FALSE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/data/classic/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/classic/game.ruleset     (original)
+++ trunk/data/classic/game.ruleset     Tue May 19 14:47:34 2015
@@ -173,6 +173,11 @@
 tired_attack = FALSE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/data/experimental/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/experimental/game.ruleset        (original)
+++ trunk/data/experimental/game.ruleset        Tue May 19 14:47:34 2015
@@ -179,6 +179,11 @@
 tired_attack = FALSE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/data/multiplayer/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/multiplayer/game.ruleset (original)
+++ trunk/data/multiplayer/game.ruleset Tue May 19 14:47:34 2015
@@ -177,6 +177,11 @@
 tired_attack = TRUE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/data/stub/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/game.ruleset?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/data/stub/game.ruleset        (original)
+++ trunk/data/stub/game.ruleset        Tue May 19 14:47:34 2015
@@ -166,6 +166,11 @@
 tired_attack = FALSE
 
 [actions]
+; If force_trade_route is set to TRUE it is illegal for an actor unit to
+; enter the marketplace of a city if it can establish a trade route to it
+; in stead.
+force_trade_route = FALSE
+
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.
 ; The second %s marks were extra details should be insterted.

Modified: trunk/doc/README.actions
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/doc/README.actions?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/doc/README.actions    (original)
+++ trunk/doc/README.actions    Tue May 19 14:47:34 2015
@@ -187,6 +187,7 @@
 
 "Enter Marketplace" - Get a one time bounus without creating a trade route.
  * UI name can be set using ui_name_enter_marketplace
+ * if force_trade_route is true "Establish Trade Route" must be impossible
  * actor must be on the same tile as the target or on the tile next to it.
  * actor must have a home city.
  * target must be foreign or trademindist tiles away from that home city.

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Tue May 19 14:47:34 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.May.13b"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2015.May.19"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Tue May 19 14:47:34 2015
@@ -5179,6 +5179,12 @@
     /* section: actions */
     if (ok) {
       const char *text;
+
+      /* Forbid entering the marketplace when a trade route can be
+       * established. */
+      game.info.force_trade_route
+        = secfile_lookup_bool_default(file, RS_DEFAULT_FORCE_TRADE_ROUTE,
+                                      "actions.force_trade_route");
 
       text = secfile_lookup_str_default(file,
           /* TRANS: _Poison City (3% chance of success). */

Modified: trunk/tools/ruledit/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruledit/rulesave.c?rev=29109&r1=29108&r2=29109&view=diff
==============================================================================
--- trunk/tools/ruledit/rulesave.c      (original)
+++ trunk/tools/ruledit/rulesave.c      Tue May 19 14:47:34 2015
@@ -787,6 +787,10 @@
   save_default_bool(sfile, game.info.slow_invasions,
                     RS_DEFAULT_SLOW_INVASIONS,
                     "global_unit_options.slow_invasions", NULL);
+
+  save_default_bool(sfile, game.info.force_trade_route,
+                    RS_DEFAULT_FORCE_TRADE_ROUTE,
+                    "actions.force_trade_route", NULL);
 
   secfile_insert_str(sfile,
                      action_by_number(ACTION_SPY_POISON)->ui_name,


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

Reply via email to