Author: cazfi Date: Fri Sep 9 18:11:03 2016 New Revision: 33770 URL: http://svn.gna.org/viewcvs/freeciv?rev=33770&view=rev Log: Added support for goods flag "Depletes"
See patch #7645 Modified: trunk/common/traderoutes.h 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/ruledit/comments.txt trunk/data/sandbox/game.ruleset trunk/data/stub/game.ruleset trunk/fc_version trunk/server/cityturn.c Modified: trunk/common/traderoutes.h URL: http://svn.gna.org/viewcvs/freeciv/trunk/common/traderoutes.h?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/common/traderoutes.h (original) +++ trunk/common/traderoutes.h Fri Sep 9 18:11:03 2016 @@ -156,6 +156,8 @@ #define SPECENUM_NAME goods_flag_id #define SPECENUM_VALUE0 GF_BIDIRECTIONAL #define SPECENUM_VALUE0NAME "Bidirectional" +#define SPECENUM_VALUE1 GF_DEPLETES +#define SPECENUM_VALUE1NAME "Depletes" #define SPECENUM_COUNT GF_COUNT #define SPECENUM_BITVECTOR bv_goods_flags #include "specenum_gen.h" Modified: trunk/data/alien/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/alien/game.ruleset (original) +++ trunk/data/alien/game.ruleset Fri Sep 9 18:11:03 2016 @@ -765,8 +765,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/civ1/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/civ1/game.ruleset (original) +++ trunk/data/civ1/game.ruleset Fri Sep 9 18:11:03 2016 @@ -759,8 +759,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/civ2/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/civ2/game.ruleset (original) +++ trunk/data/civ2/game.ruleset Fri Sep 9 18:11:03 2016 @@ -793,8 +793,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/civ2civ3/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/civ2civ3/game.ruleset (original) +++ trunk/data/civ2civ3/game.ruleset Fri Sep 9 18:11:03 2016 @@ -946,8 +946,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/classic/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/classic/game.ruleset (original) +++ trunk/data/classic/game.ruleset Fri Sep 9 18:11:03 2016 @@ -827,8 +827,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/experimental/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/experimental/game.ruleset (original) +++ trunk/data/experimental/game.ruleset Fri Sep 9 18:11:03 2016 @@ -856,8 +856,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/multiplayer/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/multiplayer/game.ruleset (original) +++ trunk/data/multiplayer/game.ruleset Fri Sep 9 18:11:03 2016 @@ -773,6 +773,12 @@ ; an good after a ruleset has been released. ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) +; flags +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" +; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/ruledit/comments.txt URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/ruledit/comments.txt?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/ruledit/comments.txt (original) +++ trunk/data/ruledit/comments.txt Fri Sep 9 18:11:03 2016 @@ -973,8 +973,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset\n\ ; and README.effects for help on requirements)\n\ ; flags\n\ -; - \"Bidirectional\" = Traderoute carrying the goods does not have \"from\" and \"to\"\n\ +; - \"Bidirectional\" = Trade route carrying the goods does not have \"from\" and \"to\"\n\ ; ends, but both ends are considered the same.\n\ +; - \"Depletes\" = Trade route gets cancelled when the source city cannot provide\n\ +; goods any more. Bidirectional routes gets cancelled if either\n\ +; one of the involved cities cannot provide goods.\n\ ;\n\ ; */ <-- avoid gettext warnings\n\ " Modified: trunk/data/sandbox/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/sandbox/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/sandbox/game.ruleset (original) +++ trunk/data/sandbox/game.ruleset Fri Sep 9 18:11:03 2016 @@ -1033,8 +1033,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/data/stub/game.ruleset URL: http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/game.ruleset?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/data/stub/game.ruleset (original) +++ trunk/data/stub/game.ruleset Fri Sep 9 18:11:03 2016 @@ -453,8 +453,11 @@ ; reqs = requirements for a city to provide goods (see effects.ruleset ; and README.effects for help on requirements) ; flags -; - "Bidirectional" = Traderoute carrying the goods does not have "from" and "to" +; - "Bidirectional" = Trade route carrying the goods does not have "from" and "to" ; ends, but both ends are considered the same. +; - "Depletes" = Trade route gets cancelled when the source city cannot provide +; goods any more. Bidirectional routes gets cancelled if either +; one of the involved cities cannot provide goods. ; ; */ <-- avoid gettext warnings Modified: trunk/fc_version URL: http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/fc_version (original) +++ trunk/fc_version Fri Sep 9 18:11:03 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.21" +NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Sep.09" NETWORK_CAPSTRING_OPTIONAL="" FREECIV_DISTRIBUTOR="" Modified: trunk/server/cityturn.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.c?rev=33770&r1=33769&r2=33770&view=diff ============================================================================== --- trunk/server/cityturn.c (original) +++ trunk/server/cityturn.c Fri Sep 9 18:11:03 2016 @@ -566,11 +566,23 @@ trade_routes_iterate_safe(pcity, proute) { struct city *tcity = game_city_by_number(proute->partner); - if (tcity != NULL && !can_cities_trade(pcity, tcity)) { - enum trade_route_type type = cities_trade_route_type(pcity, tcity); - struct trade_route_settings *settings = trade_route_settings_by_type(type); - - if (settings->cancelling == TRI_CANCEL) { + if (tcity != NULL) { + bool cancel = FALSE; + + if (proute->dir != RDIR_FROM && goods_has_flag(proute->goods, GF_DEPLETES) + && !goods_can_be_provided(tcity, proute->goods, NULL)) { + cancel = TRUE; + } + if (!cancel && !can_cities_trade(pcity, tcity)) { + enum trade_route_type type = cities_trade_route_type(pcity, tcity); + struct trade_route_settings *settings = trade_route_settings_by_type(type); + + if (settings->cancelling == TRI_CANCEL) { + cancel = TRUE; + } + } + + if (cancel) { struct trade_route *back; back = remove_trade_route(pcity, proute, TRUE, FALSE); _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits