Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] Re: (PR#9704) Simplify government.ruleset
Home

[Freeciv-Dev] Re: (PR#9704) Simplify government.ruleset

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#9704) Simplify government.ruleset
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 16 Aug 2004 10:16:31 -0700
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=9704 >

New patch. I kept _extra_distance and made _level multiplied by 100, as
suggested by Jason. We can fine tune corruption and waste just as well as
in the current code now, but without the unreadable mess.

Thanks for your comments. Please check my changes in city.c and see they
are sane.

  - Per

Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.395
diff -u -r1.395 packhand.c
--- client/packhand.c   14 Aug 2004 21:46:27 -0000      1.395
+++ client/packhand.c   16 Aug 2004 17:12:52 -0000
@@ -2515,14 +2515,12 @@
   gov->celeb_food_bonus    = p->celeb_food_bonus;
 
   gov->corruption_level    = p->corruption_level;
-  gov->corruption_modifier = p->corruption_modifier;
   gov->fixed_corruption_distance = p->fixed_corruption_distance;
   gov->corruption_distance_factor = p->corruption_distance_factor;
   gov->extra_corruption_distance = p->extra_corruption_distance;
   gov->corruption_max_distance_cap = p->corruption_max_distance_cap;
   
   gov->waste_level           = p->waste_level;
-  gov->waste_modifier        = p->waste_modifier;
   gov->fixed_waste_distance  = p->fixed_waste_distance;
   gov->waste_distance_factor = p->waste_distance_factor;
   gov->extra_waste_distance  = p->extra_waste_distance;
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.39
diff -u -r1.39 packets.def
--- common/packets.def  14 Aug 2004 21:46:28 -0000      1.39
+++ common/packets.def  16 Aug 2004 17:12:52 -0000
@@ -1053,16 +1053,14 @@
   UINT8 celeb_trade_bonus;
   UINT8 celeb_shield_bonus;
   UINT8 celeb_food_bonus;
-      
-  UINT8 corruption_level;
-  UINT8 corruption_modifier;
+
+  UINT16 corruption_level;
   UINT8 fixed_corruption_distance;
   UINT8 corruption_distance_factor;
   UINT8 extra_corruption_distance;
   UINT8 corruption_max_distance_cap;
 
-  UINT8 waste_level;
-  UINT8 waste_modifier;
+  UINT16 waste_level;
   UINT8 fixed_waste_distance;
   UINT8 waste_distance_factor;
   UINT8 extra_waste_distance;
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.177
diff -u -r1.177 capstr.c
--- common/capstr.c     13 Aug 2004 15:59:12 -0000      1.177
+++ common/capstr.c     16 Aug 2004 17:12:52 -0000
@@ -78,7 +78,7 @@
                    "+change_production +tilespec1 +no_earth +trans " \
                    "+want_hack invasions bombard +killstack2 spec +spec2 " \
                    "+city_map startunits +turn_last_built +happyborders " \
-                   "+connid +love2 +ocean_num"
+                   "+connid +love2 +ocean_num +govclean"
 
 /* "+1.14.delta" is the new delta protocol for 1.14.0-dev.
  *
@@ -140,6 +140,8 @@
  *
  * "ocean_num" means that the oceans are numbered by negative numbers
  * which are stored in ptile->continent and sent to client.
+ * 
+ * "govclean" removes corruption|waste_modifier
  */
 
 void init_our_capability(void)
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.235
diff -u -r1.235 city.c
--- common/city.c       5 Aug 2004 11:34:18 -0000       1.235
+++ common/city.c       16 Aug 2004 17:12:52 -0000
@@ -2442,7 +2442,8 @@
   struct government *g = get_gov_pcity(pcity);
   struct city *capital;
   int dist;
-  int val, trade_penalty;
+  unsigned int val;
+  int trade_penalty;
 
   assert(game.notradesize < game.fulltradesize);
   if (pcity->size <= game.notradesize) {
@@ -2473,12 +2474,12 @@
 
   /* Now calculate the final corruption.  Ordered to reduce integer
    * roundoff errors. */
-  val = (trade * dist) * g->corruption_level;
+  val = trade * MAX(dist, 1) * g->corruption_level;
   if (city_got_building(pcity, B_COURTHOUSE) ||
       city_got_building(pcity, B_PALACE)) {
     val /= 2;
   }
-  val /= 100 * g->corruption_modifier;
+  val /= 100 * 100; /* Level is a % multiplied by 100 */
   val = CLIP(trade_penalty, val, trade);
   return val;
 }
@@ -2491,7 +2492,8 @@
   struct government *g = get_gov_pcity(pcity);
   struct city *capital;
   int dist;
-  int val, shield_penalty = 0;
+  int shield_penalty = 0;
+  unsigned int val;
 
   if (g->waste_level == 0) {
     return shield_penalty;
@@ -2509,10 +2511,8 @@
   }
   dist = dist * g->waste_distance_factor + g->extra_waste_distance;
   /* Ordered to reduce integer roundoff errors */
-  val = shields * dist;
-  val *= g->waste_level;
-  val /= g->waste_modifier;
-  val /= 100;
+  val = shields * MAX(dist, 1) * g->waste_level;
+  val /= 100 * 100; /* Level is a % multiplied by 100 */
 
   if (city_got_building(pcity, B_COURTHOUSE)
       || city_got_building(pcity, B_PALACE)) {
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.185
diff -u -r1.185 ruleset.c
--- server/ruleset.c    14 Aug 2004 22:40:17 -0000      1.185
+++ server/ruleset.c    16 Aug 2004 17:12:53 -0000
@@ -1795,8 +1795,6 @@
 
     g->corruption_level
       = secfile_lookup_int(file, "%s.corruption_level", sec[i]);
-    g->corruption_modifier
-      = secfile_lookup_int(file, "%s.corruption_modifier", sec[i]);
     g->fixed_corruption_distance
       = secfile_lookup_int(file, "%s.corruption_fixed_distance", sec[i]);
     g->corruption_distance_factor
@@ -1809,8 +1807,6 @@
 
     g->waste_level
       = secfile_lookup_int(file, "%s.waste_level", sec[i]);
-    g->waste_modifier
-      = secfile_lookup_int(file, "%s.waste_modifier", sec[i]);
     g->fixed_waste_distance
       = secfile_lookup_int(file, "%s.waste_fixed_distance", sec[i]);
     g->waste_distance_factor
@@ -3005,14 +3001,12 @@
     gov.celeb_food_bonus = g->celeb_food_bonus;
 
     gov.corruption_level = g->corruption_level;
-    gov.corruption_modifier = g->corruption_modifier;
     gov.fixed_corruption_distance = g->fixed_corruption_distance;
     gov.corruption_distance_factor = g->corruption_distance_factor;
     gov.extra_corruption_distance = g->extra_corruption_distance;
     gov.corruption_max_distance_cap = g->corruption_max_distance_cap;
     
     gov.waste_level = g->waste_level;
-    gov.waste_modifier = g->waste_modifier;
     gov.fixed_waste_distance = g->fixed_waste_distance;
     gov.waste_distance_factor = g->waste_distance_factor;
     gov.extra_waste_distance = g->extra_waste_distance;
Index: data/default/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/governments.ruleset,v
retrieving revision 1.23
diff -u -r1.23 governments.ruleset
--- data/default/governments.ruleset    14 Aug 2004 21:46:28 -0000      1.23
+++ data/default/governments.ruleset    16 Aug 2004 17:12:53 -0000
@@ -70,11 +70,8 @@
 
 ; corruption:
  
-; _level            = percentage factor applied to corruption; 
-;                    if 0, Courthouse effect changes
-; _modifier         = non-zero divisor to corruption; higher value 
-;                    means less corruption 
-;                    TODO: why have both level and modifier??
+; _level            = percentage factor applied to corruption multiplied 
+;                    by 100; if 0, Courthouse effect changes
 ; _fixed_distance   = if non-zero, used instead of actual calculation of 
 ;                    distance from Palace; also used for distances in 
 ;                    unit and city bribe cost calculations
@@ -86,8 +83,7 @@
 
 ; waste:
 
-; _level             = percentage factor applied to waste;
-; _modifier          = same as corruption modifier 
+; _level             = percentage factor applied to waste multiplied by 100
 ; _fixed_distance    = used if not 0 instead of actual calculation of 
 ;                            distance from Palace;                  
 ; _distance_factor   = multiply distance by this factor for waste
@@ -134,15 +130,13 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 40
+corruption_level            = 250
 corruption_fixed_distance   = 0
 corruption_distance_factor  = 1 
 corruption_extra_distance   = 0 
 corruption_max_distance_cap = 36
 
 waste_level                = 0
-waste_modifier             = 1
 waste_fixed_distance       = 0
 waste_distance_factor      = 0 
 waste_extra_distance       = 0 
@@ -210,15 +204,13 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 27
+corruption_level            = 370
 corruption_fixed_distance   = 0
 corruption_distance_factor  = 2 
 corruption_extra_distance   = 3 
 corruption_max_distance_cap = 36
 
 waste_level                = 0
-waste_modifier             = 1
 waste_fixed_distance       = 0
 waste_distance_factor      = 0 
 waste_extra_distance       = 0 
@@ -287,15 +279,13 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 67
+corruption_level            = 149
 corruption_fixed_distance   = 0
 corruption_distance_factor  = 1 
 corruption_extra_distance   = 0 
 corruption_max_distance_cap = 36
 
 waste_level                = 0
-waste_modifier             = 1
 waste_fixed_distance       = 0
 waste_distance_factor      = 0 
 waste_extra_distance       = 0 
@@ -363,15 +353,13 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 50
-corruption_modifier         = 80
+corruption_level            = 62
 corruption_fixed_distance   = 10
 corruption_distance_factor  = 1 
 corruption_extra_distance   = 0 
 corruption_max_distance_cap = 36
 
 waste_level                = 0
-waste_modifier             = 1
 waste_fixed_distance       = 0
 waste_distance_factor      = 0 
 waste_extra_distance       = 0
@@ -447,15 +435,13 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 67
+corruption_level            = 149
 corruption_fixed_distance   = 0
 corruption_distance_factor  = 1 
 corruption_extra_distance   = 0 
 corruption_max_distance_cap = 36
 
 waste_level                = 0
-waste_modifier             = 1
 waste_fixed_distance       = 0
 waste_distance_factor      = 0 
 waste_extra_distance       = 0
@@ -535,14 +521,12 @@
 unit_free_gold    = 0
 
 corruption_level            = 0
-corruption_modifier         = 1
 corruption_fixed_distance   = 0
 corruption_distance_factor  = 0 
 corruption_extra_distance   = 0 
 corruption_max_distance_cap = 36
 
 waste_level                = 0
-waste_modifier             = 1
 waste_fixed_distance       = 0
 waste_distance_factor      = 0 
 waste_extra_distance       = 0

[Prev in Thread] Current Thread [Next in Thread]