Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11554) put tile penalty values into an array
Home

[Freeciv-Dev] (PR#11554) put tile penalty values into an array

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11554) put tile penalty values into an array
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 16 Dec 2004 10:50:58 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=11554 >

This patch puts pollution_xxx_penalty and fallout_xxx_penalty into 
arrays, pollution_tile_penalty[] and fallout_tile_penalty[], indexed by 
output type.

It's pretty straightforward.

-jason

Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.285
diff -u -r1.285 city.c
--- common/city.c       15 Dec 2004 04:30:52 -0000      1.285
+++ common/city.c       15 Dec 2004 04:43:10 -0000
@@ -617,11 +617,11 @@
 
   if (contains_special(spec_t, S_POLLUTION)) {
     /* The shields here are icky */
-    s -= (s * terrain_control.pollution_shield_penalty) / 100;
+    s -= (s * terrain_control.pollution_tile_penalty[O_SHIELD]) / 100;
   }
 
   if (contains_special(spec_t, S_FALLOUT)) {
-    s -= (s * terrain_control.fallout_shield_penalty) / 100;
+    s -= (s * terrain_control.fallout_tile_penalty[O_SHIELD]) / 100;
   }
 
   if (pcity && is_city_center(city_x, city_y)) {
@@ -722,11 +722,11 @@
 
   if (contains_special(spec_t, S_POLLUTION)) {
     /* The trade here is dirty */
-    t -= (t * terrain_control.pollution_trade_penalty) / 100;
+    t -= (t * terrain_control.pollution_tile_penalty[O_TRADE]) / 100;
   }
 
   if (contains_special(spec_t, S_FALLOUT)) {
-    t -= (t * terrain_control.fallout_trade_penalty) / 100;
+    t -= (t * terrain_control.fallout_tile_penalty[O_TRADE]) / 100;
   }
 
   if (pcity && is_city_center(city_x, city_y)) {
@@ -836,10 +836,10 @@
 
   if (contains_special(tile.special, S_POLLUTION)) {
     /* The food here is yucky */
-    f -= (f * terrain_control.pollution_food_penalty) / 100;
+    f -= (f * terrain_control.pollution_tile_penalty[O_FOOD]) / 100;
   }
   if (contains_special(tile.special, S_FALLOUT)) {
-    f -= (f * terrain_control.fallout_food_penalty) / 100;
+    f -= (f * terrain_control.fallout_tile_penalty[O_FOOD]) / 100;
   }
 
   if (pcity && is_city_center(city_x, city_y)) {
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.76
diff -u -r1.76 packets.def
--- common/packets.def  15 Dec 2004 04:30:52 -0000      1.76
+++ common/packets.def  15 Dec 2004 04:43:10 -0000
@@ -1073,12 +1073,8 @@
   UINT16 road_superhighway_trade_bonus;  # % added to trade if road/s-highway
   UINT16 rail_tile_bonus[O_MAX];        /* % added to output if railroad */
   UINT16 farmland_supermarket_food_bonus;# % added to food if farm/s-market
-  UINT16 pollution_food_penalty;        /* % subtr. from food if polluted */
-  UINT16 pollution_shield_penalty;      /* % subtr. from shield if polluted */
-  UINT16 pollution_trade_penalty;       /* % subtr. from trade if polluted */
-  UINT16 fallout_food_penalty;          /* % subtr. from food if fallout */
-  UINT16 fallout_shield_penalty;        /* % subtr. from shield if fallout */
-  UINT16 fallout_trade_penalty;         /* % subtr. from trade if fallout */
+  UINT8 pollution_tile_penalty[O_MAX]; /* % taken from output if polluted */
+  UINT8 fallout_tile_penalty[O_MAX]; /* % taken from output if polluted */
 end
 
 PACKET_RULESET_NATION=102;sc,lsend
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.216
diff -u -r1.216 ruleset.c
--- server/ruleset.c    15 Dec 2004 04:30:52 -0000      1.216
+++ server/ruleset.c    15 Dec 2004 04:43:10 -0000
@@ -1584,21 +1584,17 @@
     terrain_control.rail_tile_bonus[o] =
       secfile_lookup_int_default(file, 0, "parameters.rail_%s_bonus",
                                 get_output_identifier(o));
+    terrain_control.pollution_tile_penalty[o]
+      = secfile_lookup_int_default(file, 50,
+                                  "parameters.pollution_%s_penalty",
+                                  get_output_identifier(o));
+    terrain_control.fallout_tile_penalty[o]
+      = secfile_lookup_int_default(file, 50,
+                                  "parameters.fallout_%s_penalty",
+                                  get_output_identifier(o));
   } output_type_iterate_end;
   terrain_control.farmland_supermarket_food_bonus =
     secfile_lookup_int_default(file, 50, 
"parameters.farmland_supermarket_food_bonus");
-  terrain_control.pollution_food_penalty =
-    secfile_lookup_int_default(file, 50, "parameters.pollution_food_penalty");
-  terrain_control.pollution_shield_penalty =
-    secfile_lookup_int_default(file, 50, 
"parameters.pollution_shield_penalty");
-  terrain_control.pollution_trade_penalty =
-    secfile_lookup_int_default(file, 50, "parameters.pollution_trade_penalty");
-  terrain_control.fallout_food_penalty =
-    secfile_lookup_int_default(file, 50, "parameters.fallout_food_penalty");
-  terrain_control.fallout_shield_penalty =
-    secfile_lookup_int_default(file, 50, "parameters.fallout_shield_penalty");
-  terrain_control.fallout_trade_penalty =
-    secfile_lookup_int_default(file, 50, "parameters.fallout_trade_penalty");
 
   sec = secfile_get_secnames_prefix(file, "terrain_", &nval);
 

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#11554) put tile penalty values into an array, Jason Short <=