Author: cazfi
Date: Fri Aug 19 20:15:15 2016
New Revision: 33646

URL: http://svn.gna.org/viewcvs/freeciv?rev=33646&view=rev
Log:
Added ruleset option to control whether trade route goods are selected when 
caravan
is built, or when it arrives to the destination.

See patch #7622

Modified:
    trunk/common/fc_types.h
    trunk/common/networking/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/sandbox/game.ruleset
    trunk/data/stub/game.ruleset
    trunk/fc_version
    trunk/server/ruleset.c
    trunk/server/unithand.c
    trunk/server/unittools.c

Modified: trunk/common/fc_types.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/fc_types.h?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/common/fc_types.h     (original)
+++ trunk/common/fc_types.h     Fri Aug 19 20:15:15 2016
@@ -811,6 +811,14 @@
  */
 #define MAX_TRADE_ROUTES        5
 
+/* Used in the network protocol. */
+#define SPECENUM_NAME goods_selection_method
+#define SPECENUM_VALUE0 GSM_LEAVING
+#define SPECENUM_VALUE0NAME "Leaving"
+#define SPECENUM_VALUE1 GSM_ARRIVAL
+#define SPECENUM_VALUE1NAME "Arrival"
+#include "specenum_gen.h"
+
 enum victory_condition_type
 {
   VC_SPACERACE = 0,

Modified: trunk/common/networking/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/networking/packets.def?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/common/networking/packets.def (original)
+++ trunk/common/networking/packets.def Fri Aug 19 20:15:15 2016
@@ -258,6 +258,7 @@
 type TECH_LEAKAGE_STYLE = uint8(enum tech_leakage_style)
 type GOLD_UPKEEP_STYLE  = uint8(enum gold_upkeep_style)
 type TR_BONUS_TYPE      = uint8(enum traderoute_bonus_type)
+type GOODS_SELECTION    = uint8(enum goods_selection_method)
 
 # typedefs for bit vectors
 type BV_ACTIONS         = bitvector(bv_actions)
@@ -484,6 +485,7 @@
   UINT8 forced_science;
   UINT8 fulltradesize;
   UINT8 trade_world_rel_pct;
+  GOODS_SELECTION goods_selection;
   /* True if at least one civilization has researched a tech */
   UINT16 global_advance_count;
   BOOL global_advances[A_LAST]; diff

Modified: trunk/data/alien/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/alien/game.ruleset       (original)
+++ trunk/data/alien/game.ruleset       Fri Aug 19 20:15:15 2016
@@ -743,6 +743,11 @@
     "Team",       300,   "Cancel",     "Both"
     "TeamIC",     300,   "Cancel",     "Both"
   }
+
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Arrival"
 
 ; /* <-- avoid gettext warnings
 ;

Modified: trunk/data/civ1/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/civ1/game.ruleset        (original)
+++ trunk/data/civ1/game.ruleset        Fri Aug 19 20:15:15 2016
@@ -737,6 +737,11 @@
     "Team",       200,   "Cancel",     "Both"
     "TeamIC",     400,   "Cancel",     "Both"
   }
+
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Arrival"
 
 ; /* <-- avoid gettext warnings
 ;

Modified: trunk/data/civ2/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/civ2/game.ruleset        (original)
+++ trunk/data/civ2/game.ruleset        Fri Aug 19 20:15:15 2016
@@ -771,6 +771,11 @@
     "Team",       200,   "Cancel",     "Both"
     "TeamIC",     400,   "Cancel",     "Both"
   }
+
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Arrival"
 
 ; /* <-- avoid gettext warnings
 ;

Modified: trunk/data/civ2civ3/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/civ2civ3/game.ruleset    (original)
+++ trunk/data/civ2civ3/game.ruleset    Fri Aug 19 20:15:15 2016
@@ -924,6 +924,11 @@
     "Team",       100,   "Cancel",     "None"
     "TeamIC",     200,   "Cancel",     "None"
   }
+
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Leaving"
 
 ; /* <-- avoid gettext warnings
 ;

Modified: trunk/data/classic/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/classic/game.ruleset     (original)
+++ trunk/data/classic/game.ruleset     Fri Aug 19 20:15:15 2016
@@ -805,6 +805,11 @@
     "Team",       200,   "Cancel",     "Both"
     "TeamIC",     400,   "Cancel",     "Both"
   }
+
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Arrival"
 
 ; /* <-- avoid gettext warnings
 ;

Modified: trunk/data/experimental/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/experimental/game.ruleset        (original)
+++ trunk/data/experimental/game.ruleset        Fri Aug 19 20:15:15 2016
@@ -834,6 +834,11 @@
     "Team",       200,   "Cancel",     "Both"
     "TeamIC",     400,   "Cancel",     "Both"
   }
+
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Leaving"
 
 ; /* <-- avoid gettext warnings
 ;

Modified: trunk/data/sandbox/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/sandbox/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/sandbox/game.ruleset     (original)
+++ trunk/data/sandbox/game.ruleset     Fri Aug 19 20:15:15 2016
@@ -1011,6 +1011,11 @@
     "Team",       100,   "Cancel",     "Both"
     "TeamIC",     200,   "Cancel",     "Both"
   }
+
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Leaving"
 
 ; /* <-- avoid gettext warnings
 ;

Modified: trunk/data/stub/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/game.ruleset?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/data/stub/game.ruleset        (original)
+++ trunk/data/stub/game.ruleset        Fri Aug 19 20:15:15 2016
@@ -432,6 +432,11 @@
     "TeamIC",     0, "Cancel", "None"
   }
 
+; When are goods for the trade route chosen.
+; "Leaving" - Goods to carry are assigned to unit when it's built, or it 
changes homecity
+; "Arrival" - Goods are chosen when trade route is established, when unit 
arrives to destination
+goods_selection = "Leaving"
+
 ; /* <-- avoid gettext warnings
 ;
 ; Goods types:

Modified: trunk/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Fri Aug 19 20:15:15 2016
@@ -56,7 +56,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-2016.Aug.17b"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Aug.19"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Fri Aug 19 20:15:15 2016
@@ -6524,6 +6524,19 @@
           ok = FALSE;
         }
       }
+    }
+  }
+
+  if (ok) {
+    const char *str = secfile_lookup_str_default(file, "Leaving", 
"trade.goods_selection");
+
+    game.info.goods_selection = goods_selection_method_by_name(str, 
fc_strcasecmp);
+
+    if (!goods_selection_method_is_valid(game.info.goods_selection)) {
+      ruleset_error(LOG_ERROR,
+                    "\"%s\" goods selection method \"%s\" unknown.",
+                    filename, str);
+      ok = FALSE;
     }
   }
 

Modified: trunk/server/unithand.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unithand.c?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/server/unithand.c     (original)
+++ trunk/server/unithand.c     Fri Aug 19 20:15:15 2016
@@ -3696,7 +3696,11 @@
     return FALSE;
   }
 
-  goods = punit->carrying;
+  if (game.info.goods_selection == GSM_ARRIVAL) {
+    goods =  goods_from_city_to_unit(pcity_homecity, punit);
+  } else {
+    goods = punit->carrying;
+  }
   if (goods == NULL) {
     notify_player(pplayer, unit_tile(punit), E_BAD_COMMAND, ftc_server,
                   _("Sorry, your %s cannot establish"

Modified: trunk/server/unittools.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/unittools.c?rev=33646&r1=33645&r2=33646&view=diff
==============================================================================
--- trunk/server/unittools.c    (original)
+++ trunk/server/unittools.c    Fri Aug 19 20:15:15 2016
@@ -1544,7 +1544,7 @@
   if (punit->homecity != 0) {
     struct city *home = game_city_by_number(punit->homecity);
 
-    if (home != NULL) {
+    if (home != NULL && game.info.goods_selection == GSM_LEAVING) {
       punit->carrying = goods_from_city_to_unit(home, punit);
     }
   }


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

Reply via email to