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

[Freeciv-Dev] (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] (PR#9704) Simplify government.ruleset
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Sat, 14 Aug 2004 15:16:23 -0700
Reply-to: rt@xxxxxxxxxxx

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

This patch removes corruption_modifier, corruption_extra_distance,
waste_modifier and waste_extra_distance.

The _modifier variables were merged into the _level variable, using normal
rounding rules. So that what was once level=100 & modifier=67
(100/67=1.49) becomes 1. The downside to this is that the accuracy with
which you can set corruption and waste in the ruleset drops for low values
of _level.

However, it is much clearer this way. You now give a base corruption and
waste in a percentage value instead of two mystical ints. It is
significantly easier for modpack authors, and easier to automatically make
a sensible help entry for governments.

Also, I removed _extra_distance, simply because it had very little effect
for those values that it was used with, and I therefore found it
unnecessary.

Finally, I ensured that distance from capital never drops below 1. So if
you set _max_distance_cap to 1, _distance_factor to 0 or _fixed_distance
to 1, you can use _level to set corruption to exactly the value you want.
Eg 50%. This may have an impact on the corruption in the capital.

  - 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   14 Aug 2004 22:08:11 -0000
@@ -2515,17 +2515,13 @@
   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;
   gov->waste_max_distance_cap = p->waste_max_distance_cap;
   
   gov->flags               = p->flags;
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    14 Aug 2004 22:08:11 -0000
@@ -72,26 +72,20 @@
  
 ; _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??
 ; _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
 ; _distance_factor  = multiply distance by this factor for corruption 
 ;                    (but not bribe costs)
-; _extra_distance   = add this to distance after applying distance factor
 ; _max_distance_cap = cap to the max distance from the capital used in
 ;                     corruption calculation
 
 ; waste:
 
 ; _level             = percentage factor applied to waste;
-; _modifier          = same as corruption modifier 
 ; _fixed_distance    = used if not 0 instead of actual calculation of 
 ;                            distance from Palace;                  
 ; _distance_factor   = multiply distance by this factor for waste
-; _extra_distance    = add this to distance after applying distance factor
 ; _max_distance_cap  = cap to the max distance from the capital used in
 ;                      waste calculation
 
@@ -134,18 +128,14 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 40
+corruption_level            = 3
 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 
 waste_max_distance_cap     = 36
 
 production_trade_bonus    = 0, 0
@@ -210,18 +200,14 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 27
+corruption_level            = 4
 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 
 waste_max_distance_cap     = 36
 
 production_trade_bonus    = 0, 0
@@ -287,18 +273,14 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 67
+corruption_level            = 1
 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 
 waste_max_distance_cap     = 36
 
 production_trade_bonus    = 0, 1
@@ -363,18 +345,14 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 50
-corruption_modifier         = 80
+corruption_level            = 1
 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
 waste_max_distance_cap     = 36
 
 production_trade_bonus    = 0, 1
@@ -447,18 +425,14 @@
 unit_free_food    = 0
 unit_free_gold    = 0
 
-corruption_level            = 100
-corruption_modifier         = 67
+corruption_level            = 1
 corruption_fixed_distance   = 0
-corruption_distance_factor  = 1 
-corruption_extra_distance   = 0 
+corruption_distance_factor  = 1
 corruption_max_distance_cap = 36
 
 waste_level                = 0
-waste_modifier             = 1
 waste_fixed_distance       = 0
 waste_distance_factor      = 0 
-waste_extra_distance       = 0
 waste_max_distance_cap     = 36
 
 production_trade_bonus    = 1, 1
@@ -535,17 +509,13 @@
 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
 waste_max_distance_cap     = 36
 
 production_trade_bonus    = 1, 1
Index: common/government.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.h,v
retrieving revision 1.29
diff -u -r1.29 government.h
--- common/government.h 14 Aug 2004 21:46:28 -0000      1.29
+++ common/government.h 14 Aug 2004 22:08:11 -0000
@@ -129,18 +129,14 @@
 
   /* corruption modifiers -- SKi */
   int   corruption_level;
-  int   corruption_modifier;
   int   fixed_corruption_distance;
   int   corruption_distance_factor;
-  int   extra_corruption_distance;
   int   corruption_max_distance_cap;
   
   /* waste modifiers, see governments.ruleset for more detail */
   int   waste_level;
-  int   waste_modifier;
   int   fixed_waste_distance;
   int   waste_distance_factor;
-  int   extra_waste_distance;
   int   waste_max_distance_cap;
     
   /* other flags: bits in enum government_flag_id order,
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       14 Aug 2004 22:08:11 -0000
@@ -2468,17 +2468,16 @@
       dist = MIN(g->corruption_max_distance_cap, tmp);
     }
   }
-  dist =
-      dist * g->corruption_distance_factor + g->extra_corruption_distance;
+  dist *= g->corruption_distance_factor;
 
   /* 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;
   val = CLIP(trade_penalty, val, trade);
   return val;
 }
@@ -2507,11 +2506,10 @@
       dist = MIN(g->waste_max_distance_cap, tmp);
     }
   }
-  dist = dist * g->waste_distance_factor + g->extra_waste_distance;
+  dist *= g->waste_distance_factor;
   /* Ordered to reduce integer roundoff errors */
-  val = shields * dist;
+  val = shields * MAX(dist, 1);
   val *= g->waste_level;
-  val /= g->waste_modifier;
   val /= 100;
 
   if (city_got_building(pcity, B_COURTHOUSE)
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.184
diff -u -r1.184 ruleset.c
--- server/ruleset.c    12 Aug 2004 20:59:00 -0000      1.184
+++ server/ruleset.c    14 Aug 2004 22:08:11 -0000
@@ -1795,28 +1795,20 @@
 
     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
       = secfile_lookup_int(file, "%s.corruption_distance_factor", sec[i]);
-    g->extra_corruption_distance
-      = secfile_lookup_int(file, "%s.corruption_extra_distance", sec[i]);
     g->corruption_max_distance_cap
       = secfile_lookup_int_default(file, 36, 
         "%s.corruption_max_distance_cap", sec[i]); 
 
     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
       = secfile_lookup_int(file, "%s.waste_distance_factor", sec[i]);
-    g->extra_waste_distance
-      = secfile_lookup_int(file, "%s.waste_extra_distance", sec[i]);
     g->waste_max_distance_cap
       = secfile_lookup_int_default(file, 36, "%s.waste_max_distance_cap", 
sec[i]); 
 
@@ -1872,26 +1864,6 @@
     free(slist);
   } government_iterate_end;
 
-  /* hints: */
-  government_iterate(g) {
-    g->hints = 0;
-    slist = secfile_lookup_str_vec(file, &nval, "%s.hints", sec[g->index]);
-    for(j=0; j<nval; j++) {
-      char *sval = slist[j];
-      enum government_hint_id hint = government_hint_from_str(sval);
-      if (strcmp(sval, "-") == 0) {
-        continue;
-      }
-      if (hint == G_LAST_HINT) {
-        freelog(LOG_FATAL, "government %s has unknown hint %s", g->name, sval);
-        exit(EXIT_FAILURE);
-      } else {
-        g->hints |= (1<<hint);
-      }
-    }
-    free(slist);
-  } government_iterate_end;
-
   /* titles */
   government_iterate(g) {
     int i = g->index;
@@ -1908,24 +1880,6 @@
               secfile_lookup_str(file, "%s.ruler_female_title", sec[i]));
   } government_iterate_end;
 
-  /* subgoals: */
-  government_iterate(g) {
-    char *sval;
-    sval = secfile_lookup_str(file, "%s.subgoal", sec[g->index]);
-    if (strcmp(sval, "-")==0) {
-      g->subgoal = -1;
-    } else {
-      struct government *subgov = find_government_by_name(sval);
-      if (!subgov) {
-       freelog(LOG_ERROR, "Bad subgoal government \"%s\" for gov \"%s\" (%s)",
-               sval, g->name, filename);
-      } else {
-       g->subgoal = subgov - governments;
-      }
-    }
-    freelog(LOG_DEBUG, "%s subgoal %d", g->name, g->subgoal);
-  } government_iterate_end;
-    
   /* ai tech_hints: */
   j = -1;
   while((c = secfile_lookup_str_default(file, NULL,
@@ -3043,21 +2997,16 @@
     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;
     gov.waste_max_distance_cap = g->waste_max_distance_cap;
         
     gov.flags = g->flags;
-    gov.hints = g->hints;
     gov.num_ruler_titles = g->num_ruler_titles;
 
     sz_strlcpy(gov.name, g->name_orig);

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#9704) Simplify government.ruleset, Per I. Mathisen <=