Author: sveinung
Date: Fri Jun  3 04:28:48 2016
New Revision: 32791

URL: http://svn.gna.org/viewcvs/freeciv?rev=32791&view=rev
Log:
Let a rs make "Poison City" empty the food stock.

A ruleset where the "Poison City" action is narrated as the food stock being
poisoned should be able to empty it on a successful "Poison City". A ruleset
with a story where "Poison City" is done by detonating a bomb in a crowded
area far away from the granary shouldn't have to have its food stock
emptied.

Leave the question to the ruleset authors. Add poison_empties_food_stock. It
is currently set for the whole game. When actions are generalized the empty
food stock action effect flag should be separated from the reduce the
population action effect flag. That will allow one "Poison City" action that
empties the food stock and one that doesn't in the same ruleset.

Requested by fomalhaut on the forums.

See patch #7241

Modified:
    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/sandbox/game.ruleset
    trunk/data/stub/game.ruleset
    trunk/fc_version
    trunk/server/cityturn.c
    trunk/server/cityturn.h
    trunk/server/diplomats.c
    trunk/server/ruleset.c
    trunk/tools/ruleutil/rulesave.c

Modified: trunk/common/game.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/game.h?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/common/game.h (original)
+++ trunk/common/game.h Fri Jun  3 04:28:48 2016
@@ -782,6 +782,8 @@
 #define RS_DEFAULT_FORCE_BOMBARD                 FALSE
 #define RS_DEFAULT_FORCE_EXPLODE_NUCLEAR         FALSE
 
+#define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK     FALSE
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */

Modified: trunk/common/packets.def
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/common/packets.def?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/common/packets.def    (original)
+++ trunk/common/packets.def    Fri Jun  3 04:28:48 2016
@@ -518,6 +518,7 @@
   PHASE phase;
   PHASE_MODE phase_mode;
   BOOL pillage_select;
+  BOOL poison_empties_food_stock;
   BOOL tech_steal_allow_holes;
   BOOL tech_trade_allow_holes;
   BOOL tech_trade_loss_allow_holes;

Modified: trunk/data/alien/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/alien/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/alien/game.ruleset       (original)
+++ trunk/data/alien/game.ruleset       Fri Jun  3 04:28:48 2016
@@ -210,6 +210,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = FALSE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/civ1/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ1/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/civ1/game.ruleset        (original)
+++ trunk/data/civ1/game.ruleset        Fri Jun  3 04:28:48 2016
@@ -185,6 +185,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = TRUE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/civ2/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/civ2/game.ruleset        (original)
+++ trunk/data/civ2/game.ruleset        Fri Jun  3 04:28:48 2016
@@ -202,6 +202,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = TRUE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/civ2civ3/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/civ2civ3/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/civ2civ3/game.ruleset    (original)
+++ trunk/data/civ2civ3/game.ruleset    Fri Jun  3 04:28:48 2016
@@ -211,6 +211,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = TRUE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/classic/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/classic/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/classic/game.ruleset     (original)
+++ trunk/data/classic/game.ruleset     Fri Jun  3 04:28:48 2016
@@ -206,6 +206,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = TRUE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/experimental/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/experimental/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/experimental/game.ruleset        (original)
+++ trunk/data/experimental/game.ruleset        Fri Jun  3 04:28:48 2016
@@ -209,6 +209,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = TRUE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/multiplayer/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/multiplayer/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/multiplayer/game.ruleset (original)
+++ trunk/data/multiplayer/game.ruleset Fri Jun  3 04:28:48 2016
@@ -209,6 +209,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = TRUE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/sandbox/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/sandbox/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/sandbox/game.ruleset     (original)
+++ trunk/data/sandbox/game.ruleset     Fri Jun  3 04:28:48 2016
@@ -208,6 +208,10 @@
 ; to perform a regular attack against a tile if it can do explode nuclear
 ; in stead.
 force_explode_nuclear = TRUE
+
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+poison_empties_food_stock = FALSE
 
 ; What each action should be called when showing them to the player.
 ; The first %s should be before the mnemonic of the action.

Modified: trunk/data/stub/game.ruleset
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/data/stub/game.ruleset?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/data/stub/game.ruleset        (original)
+++ trunk/data/stub/game.ruleset        Fri Jun  3 04:28:48 2016
@@ -198,6 +198,10 @@
 ; in stead.
 force_explode_nuclear = FALSE
 
+; If poison_empties_food_stock is set to TRUE a successful "Poison City"
+; will empty the food stock.
+;poison_empties_food_stock = 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/fc_version
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/fc_version?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/fc_version    (original)
+++ trunk/fc_version    Fri Jun  3 04:28:48 2016
@@ -55,7 +55,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.May.13"
+NETWORK_CAPSTRING_MANDATORY="+Freeciv.Devel-3.0-2016.Jun.03"
 NETWORK_CAPSTRING_OPTIONAL=""
 
 FREECIV_DISTRIBUTOR=""

Modified: trunk/server/cityturn.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.c?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/server/cityturn.c     (original)
+++ trunk/server/cityturn.c     Fri Jun  3 04:28:48 2016
@@ -3633,6 +3633,29 @@
 }
 
 /**************************************************************************
+  Returns TRUE iff the city's food stock was emptied. Should empty the
+  food stock unless it already is empty.
+**************************************************************************/
+bool city_empty_food_stock(struct city *pcity) {
+  struct player *pplayer = city_owner(pcity);
+  struct tile *ptile = city_tile(pcity);
+
+  fc_assert_ret_val(pcity != NULL, FALSE);
+
+  if (pcity->food_stock > 0) {
+    pcity->food_stock = 0;
+
+    notify_player(pplayer, ptile, E_DISASTER, ftc_server,
+                  /* TRANS: %s is a city name */
+                  _("All stored food destroyed in %s."), city_link(pcity));
+
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+/**************************************************************************
   Disaster has hit a city. Apply its effects.
 **************************************************************************/
 static void apply_disaster(struct city *pcity, struct disaster_type *pdis)
@@ -3712,13 +3735,7 @@
   }
 
   if (pcity && disaster_has_effect(pdis, DE_EMPTY_FOODSTOCK)) {
-    if (pcity->food_stock > 0) {
-      pcity->food_stock = 0;
-
-      notify_player(pplayer, ptile, E_DISASTER, ftc_server,
-                    /* TRANS: %s is a city name */
-                    _("All stored food destroyed in %s."), city_link(pcity));
-
+    if (city_empty_food_stock(pcity)) {
       had_internal_effect = TRUE;
     }
   }

Modified: trunk/server/cityturn.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/cityturn.h?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/server/cityturn.h     (original)
+++ trunk/server/cityturn.h     Fri Jun  3 04:28:48 2016
@@ -36,6 +36,8 @@
                       struct player *destroyer, const char *reason);
 void city_repair_size(struct city *pcity, int change);
 
+bool city_empty_food_stock(struct city *pcity);
+
 void send_city_turn_notifications(struct connection *pconn);
 void update_city_activities(struct player *pplayer);
 int city_incite_cost(struct player *pplayer, struct city *pcity);

Modified: trunk/server/diplomats.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/diplomats.c?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/server/diplomats.c    (original)
+++ trunk/server/diplomats.c    Fri Jun  3 04:28:48 2016
@@ -130,6 +130,11 @@
                   E_ENEMY_DIPLOMAT_POISON, ftc_server,
                   _("%s is suspected of poisoning the water supply of %s."),
                   player_name(pplayer), clink);
+
+    if (game.info.poison_empties_food_stock) {
+      /* The food was poisoned too. */
+      city_empty_food_stock(pcity);
+    }
 
     /* Update clients. */
     city_refresh (pcity);

Modified: trunk/server/ruleset.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/server/ruleset.c?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/server/ruleset.c      (original)
+++ trunk/server/ruleset.c      Fri Jun  3 04:28:48 2016
@@ -5721,6 +5721,14 @@
         = secfile_lookup_bool_default(file,
                                       RS_DEFAULT_FORCE_EXPLODE_NUCLEAR,
                                       "actions.force_explode_nuclear");
+
+      /* If the poison city action should empty the granary. */
+      /* TODO: empty granary and reduce population should become separate
+       * action effect flags when actions are generalized. */
+      game.info.poison_empties_food_stock
+        = secfile_lookup_bool_default(file,
+                                      RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK,
+                                      "actions.poison_empties_food_stock");
 
       text = secfile_lookup_str_default(file,
           /* TRANS: _Poison City (3% chance of success). */

Modified: trunk/tools/ruleutil/rulesave.c
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/tools/ruleutil/rulesave.c?rev=32791&r1=32790&r2=32791&view=diff
==============================================================================
--- trunk/tools/ruleutil/rulesave.c     (original)
+++ trunk/tools/ruleutil/rulesave.c     Fri Jun  3 04:28:48 2016
@@ -922,6 +922,10 @@
                     RS_DEFAULT_FORCE_EXPLODE_NUCLEAR,
                     "actions.force_explode_nuclear", NULL);
 
+  save_default_bool(sfile, game.info.poison_empties_food_stock,
+                    RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK,
+                    "actions.poison_empties_food_stock", NULL);
+
   secfile_insert_str(sfile,
                      action_by_number(ACTION_SPY_POISON)->ui_name,
                      "actions.ui_name_poison_city");


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

Reply via email to