Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2004:
[Freeciv-Dev] (PR#8779) Configurable specialists
Home

[Freeciv-Dev] (PR#8779) Configurable specialists

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8779) Configurable specialists
From: "Per Inge Mathisen" <per@xxxxxxxxxxx>
Date: Wed, 19 May 2004 12:50:22 -0700
Reply-to: rt@xxxxxxxxxxx

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

This patch makes specialists configurable. We can change their
multipliers, their minimum city size requirements, and we can disable a
player's ability to adjust the tax settings in favour of fixed settings.

(Yes, this should be made completely generalized one day. But not today!)

A demonstration of the interesting rulesets this can lead to is in
test1.diff - here all trade goes into luxury by default, and scientists
and taxmen is the only way to produce research and gold income. Smallpox
this! ;)

  - Per

Index: data/default/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/governments.ruleset,v
retrieving revision 1.22
diff -u -r1.22 governments.ruleset
--- data/default/governments.ruleset    14 Aug 2003 21:17:58 -0000      1.22
+++ data/default/governments.ruleset    19 May 2004 19:31:08 -0000
@@ -201,7 +201,7 @@
 
 martial_law_max  = 100  ; unlimited
 martial_law_per  = 1
-max_single_rate  = 60
+max_single_rate  = 100
 civil_war_chance = 80
 empire_size_mod  = -4
 empire_size_inc  = 0
@@ -280,7 +280,7 @@
 
 martial_law_max  = 3
 martial_law_per  = 1
-max_single_rate  = 70
+max_single_rate  = 100
 civil_war_chance = 70
 empire_size_mod  = -3
 empire_size_inc  = 0
@@ -358,7 +358,7 @@
 
 martial_law_max  = 3
 martial_law_per  = 2
-max_single_rate  = 80
+max_single_rate  = 100
 civil_war_chance = 50
 empire_size_mod  = -2
 empire_size_inc  = 0
@@ -444,7 +444,7 @@
 
 martial_law_max  = 0
 martial_law_per  = 0
-max_single_rate  = 80
+max_single_rate  = 100
 civil_war_chance = 40
 empire_size_mod  = -1
 empire_size_inc  = 0
Index: data/default/cities.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/cities.ruleset,v
retrieving revision 1.9
diff -u -r1.9 cities.ruleset
--- data/default/cities.ruleset 8 May 2003 03:06:58 -0000       1.9
+++ data/default/cities.ruleset 19 May 2004 19:31:08 -0000
@@ -11,6 +11,28 @@
 description="Cities data for Freeciv"
 options="1.9"
 
+; Configure the effect of specialists. Each specialist contributes
+; the given amount of its special kind of value (luxury for elvis,
+; research for scientist and gold for taxman). You can set
+; changable_tax to zero to disallow players setting the taxrate
+; for themselves. In this case, the values in the forced_ fields
+; apply instead, modified by government restrictions. The min_size
+; fields restrict setting specialists to this type before the
+; the city is of a certain size.
+[specialist]
+;base_elvis = 2
+base_elvis = 3
+base_scientist = 3
+base_taxman = 3
+;changable_tax = 1
+changable_tax = 0
+forced_science = 0
+forced_luxury = 100
+forced_gold = 0
+min_size_elvis = 0
+min_size_taxman = 0
+min_size_scientist = 0
+
 [parameters]
 add_to_size_limit  = 8         ; cities >= this cannot be added to.
 
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.365
diff -u -r1.365 packhand.c
--- client/packhand.c   15 May 2004 16:33:42 -0000      1.365
+++ client/packhand.c   19 May 2004 19:40:34 -0000
@@ -2676,6 +2676,16 @@
 {
   int i;
 
+  game.rgame.min_size_elvis = packet->min_size_elvis;
+  game.rgame.min_size_taxman = packet->min_size_taxman;
+  game.rgame.min_size_scientist = packet->min_size_scientist;
+  game.rgame.base_elvis = packet->base_elvis;
+  game.rgame.base_scientist = packet->base_scientist;
+  game.rgame.base_taxman = packet->base_taxman;
+  game.rgame.changable_tax = packet->changable_tax;
+  game.rgame.forced_science = packet->forced_science;
+  game.rgame.forced_luxury = packet->forced_luxury;
+  game.rgame.forced_gold = packet->forced_gold;
   game.rgame.min_city_center_food = packet->min_city_center_food;
   game.rgame.min_city_center_shield = packet->min_city_center_shield;
   game.rgame.min_city_center_trade = packet->min_city_center_trade;
Index: client/gui-gtk-2.0/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/menu.c,v
retrieving revision 1.31
diff -u -r1.31 menu.c
--- client/gui-gtk-2.0/menu.c   17 May 2004 01:29:47 -0000      1.31
+++ client/gui-gtk-2.0/menu.c   19 May 2004 19:40:35 -0000
@@ -1153,7 +1153,8 @@
     menus_set_sensitive("<main>/_Orders", can_client_issue_orders());
 
     menus_set_sensitive("<main>/_Kingdom/_Tax Rates",
-                       can_client_issue_orders());
+                       game.rgame.changable_tax
+                        && can_client_issue_orders());
     menus_set_sensitive("<main>/_Kingdom/_Worklists",
                        can_client_issue_orders());
     menus_set_sensitive("<main>/_Kingdom/_Government",
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.165
diff -u -r1.165 capstr.c
--- common/capstr.c     11 May 2004 17:18:19 -0000      1.165
+++ common/capstr.c     19 May 2004 19:40:35 -0000
@@ -77,7 +77,7 @@
 #define CAPABILITY "+1.14.delta +last_turns_shield_surplus veteran +orders " \
                    "+starter +union +iso_maps +orders2client " \
                    "+change_production +tilespec1 +no_earth +trans " \
-                   "+want_hack invasions bombard +killstack2"
+                   "+want_hack invasions bombard +killstack2 spec"
 
 /* "+1.14.delta" is the new delta protocol for 1.14.0-dev.
  *
@@ -115,6 +115,8 @@
  * it's a boolean.
  *
  * "bombard" means units support the bombard ability.
+ * 
+ * "spec" is configurable specialists
  */
 
 void init_our_capability(void)
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.209
diff -u -r1.209 city.c
--- common/city.c       17 May 2004 02:16:15 -0000      1.209
+++ common/city.c       19 May 2004 19:40:35 -0000
@@ -1706,17 +1706,19 @@
 {
   int sci, tax, lux, rate = pcity->trade_prod;
   int sci_rest, tax_rest, lux_rest;
-  int sci_rate = city_owner(pcity)->economic.science;
-  int lux_rate = city_owner(pcity)->economic.luxury;
-  int tax_rate = 100 - sci_rate - lux_rate;
-  
-  if (government_has_flag(get_gov_pcity(pcity), G_REDUCED_RESEARCH)) {
-    if (sci_rate > 50) {
-      sci_rate = 50;
-      tax_rate = 100 - sci_rate - lux_rate;
-    }
-  }
+  struct player *pplayer = city_owner(pcity);
+  int sci_rate, lux_rate, tax_rate;
 
+  if (game.rgame.changable_tax) {
+    sci_rate = pplayer->economic.science;
+    lux_rate = pplayer->economic.luxury;
+    tax_rate = 100 - sci_rate - lux_rate;
+  } else {
+    sci_rate = game.rgame.forced_science;
+    lux_rate = game.rgame.forced_luxury;
+    tax_rate = game.rgame.forced_gold;
+  }
+  
   /* ANARCHY */
   if (get_gov_pcity(pcity)->index == game.government_when_anarchy) {
     sci_rate = 0;
@@ -1724,9 +1726,6 @@
     tax_rate = 100 - sci_rate - lux_rate;
   }
 
-  freelog(LOG_DEBUG, "trade_prod=%d, rates=(sci=%d%%, tax=%d%%, lux=%d%%)",
-         pcity->trade_prod, sci_rate, tax_rate, lux_rate);
-
   /* 
    * Distribution of the trade among science, tax and luxury via a
    * modified Hare/Niemeyer algorithm (also known as "Hamilton's
@@ -1750,10 +1749,6 @@
 
   rate -= (sci + tax + lux);  
 
-  freelog(LOG_DEBUG,
-         "  int parts (%d, %d, %d), rest (%d, %d, %d), remaing trade %d",
-         sci, tax, lux, sci_rest, tax_rest, lux_rest, rate);
-  
   while (rate > 0) {
     if (sci_rest > lux_rest && sci_rest > tax_rest) {
       sci++;
@@ -1807,16 +1802,14 @@
 
   assert(sci + tax + lux == pcity->trade_prod);
 
-  freelog(LOG_DEBUG, "  result (%d, %d, %d)", sci, tax, lux);
-
   pcity->science_total = sci;
   pcity->tax_total = tax;
   pcity->luxury_total = lux;
 
-  pcity->luxury_total += (pcity->ppl_elvis * 2);
-  pcity->science_total += (pcity->ppl_scientist * 3);
-  pcity->tax_total +=
-      (pcity->ppl_taxman * 3) + get_city_tithes_bonus(pcity);
+  pcity->luxury_total += (pcity->ppl_elvis * game.rgame.base_elvis);
+  pcity->science_total += (pcity->ppl_scientist * game.rgame.base_scientist);
+  pcity->tax_total += (pcity->ppl_taxman * game.rgame.base_taxman) 
+                       + get_city_tithes_bonus(pcity);
 }
 
 /**************************************************************************
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.138
diff -u -r1.138 game.h
--- common/game.h       18 May 2004 16:29:30 -0000      1.138
+++ common/game.h       19 May 2004 19:40:35 -0000
@@ -186,6 +186,16 @@
 
   /* values from game.ruleset */
   struct {
+    int min_size_elvis;
+    int min_size_taxman;
+    int min_size_scientist;
+    int base_elvis;
+    int base_scientist;
+    int base_taxman;
+    bool changable_tax;
+    int forced_science; /* only relevant if !changable_tax */
+    int forced_luxury;
+    int forced_gold;
     int min_city_center_food;
     int min_city_center_shield;
     int min_city_center_trade;
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.22
diff -u -r1.22 packets.def
--- common/packets.def  11 May 2004 17:18:19 -0000      1.22
+++ common/packets.def  19 May 2004 19:40:35 -0000
@@ -956,6 +956,16 @@
 end
 
 PACKET_RULESET_GAME=97;sc,lsend
+  UINT8 min_size_elvis; add-cap(spec)
+  UINT8 min_size_taxman; add-cap(spec)
+  UINT8 min_size_scientist; add-cap(spec)
+  UINT8 base_elvis; add-cap(spec)
+  UINT8 base_scientist; add-cap(spec)
+  UINT8 base_taxman; add-cap(spec)
+  BOOL changable_tax; add-cap(spec)
+  UINT8 forced_science; add-cap(spec)
+  UINT8 forced_luxury; add-cap(spec)
+  UINT8 forced_gold; add-cap(spec)
   UINT8 min_city_center_food;
   UINT8 min_city_center_shield;
   UINT8 min_city_center_trade;
Index: data/default/cities.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/cities.ruleset,v
retrieving revision 1.9
diff -u -r1.9 cities.ruleset
--- data/default/cities.ruleset 8 May 2003 03:06:58 -0000       1.9
+++ data/default/cities.ruleset 19 May 2004 19:40:35 -0000
@@ -11,6 +11,26 @@
 description="Cities data for Freeciv"
 options="1.9"
 
+; Configure the effect of specialists. Each specialist contributes
+; the given amount of its special kind of value (luxury for elvis,
+; research for scientist and gold for taxman). You can set
+; changable_tax to zero to disallow players setting the taxrate
+; for themselves. In this case, the values in the forced_ fields
+; apply instead, modified by government restrictions. The min_size
+; fields restrict setting specialists to this type before the
+; the city is of a certain size.
+[specialist]
+base_elvis = 2
+base_scientist = 3
+base_taxman = 3
+changable_tax = 1
+;forced_science = 0
+;forced_luxury = 100
+;forced_gold = 0
+min_size_elvis = 0
+min_size_taxman = 5
+min_size_scientist = 5
+
 [parameters]
 add_to_size_limit  = 8         ; cities >= this cannot be added to.
 
Index: server/cityhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityhand.c,v
retrieving revision 1.127
diff -u -r1.127 cityhand.c
--- server/cityhand.c   25 Feb 2004 20:23:50 -0000      1.127
+++ server/cityhand.c   19 May 2004 19:40:35 -0000
@@ -72,23 +72,24 @@
     return;
   }
 
-  if(from==SP_ELVIS) {
-    if(pcity->size<5) 
-      return; 
+  if ((to == SP_ELVIS && pcity->size < game.rgame.min_size_elvis)
+      || (to == SP_TAXMAN && pcity->size < game.rgame.min_size_taxman)
+      || (to == SP_SCIENTIST && pcity->size < game.rgame.min_size_scientist)
+      || (from == SP_ELVIS && pcity->ppl_elvis == 0)
+      || (from == SP_TAXMAN && pcity->ppl_taxman == 0)
+      || (from == SP_SCIENTIST && pcity->ppl_scientist == 0)
+      || (to != SP_ELVIS && to != SP_TAXMAN && to != SP_SCIENTIST)
+      || (from != SP_ELVIS && from != SP_TAXMAN && from != SP_SCIENTIST)) {
+    freelog(LOG_ERROR, "Error in specialist change request from client.");
+    return;
+  }
 
-    if(pcity->ppl_elvis == 0)
-      return;
+  if (from == SP_ELVIS) {
     pcity->ppl_elvis--;
   } else if(from==SP_TAXMAN) {
-    if (pcity->ppl_taxman == 0)
-      return;
     pcity->ppl_taxman--;
   } else if (from==SP_SCIENTIST) {
-    if (pcity->ppl_scientist == 0)
-      return;
     pcity->ppl_scientist--;
-  } else {
-    return;
   }
   switch (to) {
   case SP_TAXMAN:
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.171
diff -u -r1.171 ruleset.c
--- server/ruleset.c    18 May 2004 16:14:30 -0000      1.171
+++ server/ruleset.c    19 May 2004 19:40:36 -0000
@@ -2493,6 +2493,34 @@
 
   (void) check_ruleset_capabilities(file, "+1.9", filename);
 
+  /* Specialist options */
+
+  game.rgame.min_size_elvis = 
+    secfile_lookup_int_default(file, 0, "specialist.min_size_elvis");
+  game.rgame.min_size_taxman = 
+    secfile_lookup_int_default(file, 5, "specialist.min_size_taxman");
+  game.rgame.min_size_scientist = 
+    secfile_lookup_int_default(file, 5, "specialist.min_size_scientist");
+  game.rgame.base_elvis = 
+    secfile_lookup_int_default(file, 2, "specialist.base_elvis");
+  game.rgame.base_scientist = 
+    secfile_lookup_int_default(file, 3, "specialist.base_scientist");
+  game.rgame.base_taxman = 
+    secfile_lookup_int_default(file, 3, "specialist.base_taxman");
+  game.rgame.changable_tax = 
+    secfile_lookup_bool_default(file, TRUE, "specialist.changable_tax");
+  game.rgame.forced_science = 
+    secfile_lookup_int_default(file, 0, "specialist.forced_science");
+  game.rgame.forced_luxury = 
+    secfile_lookup_int_default(file, 100, "specialist.forced_luxury");
+  game.rgame.forced_gold = 
+    secfile_lookup_int_default(file, 0, "specialist.forced_gold");
+  if (game.rgame.forced_science + game.rgame.forced_luxury
+      + game.rgame.forced_gold != 100) {
+    freelog(LOG_FATAL, "Forced taxes do not add up in ruleset!");
+    exit(EXIT_FAILURE);
+  }
+
   /* City Parameters */
 
   game.add_to_size_limit =
@@ -3061,6 +3089,16 @@
   int i;
   struct packet_ruleset_game misc_p;
 
+  misc_p.min_size_elvis = game.rgame.min_size_elvis;
+  misc_p.min_size_taxman = game.rgame.min_size_taxman;
+  misc_p.min_size_scientist = game.rgame.min_size_scientist;
+  misc_p.base_elvis = game.rgame.base_elvis;
+  misc_p.base_scientist = game.rgame.base_scientist;
+  misc_p.base_taxman = game.rgame.base_taxman;
+  misc_p.changable_tax = game.rgame.changable_tax;
+  misc_p.forced_science = game.rgame.forced_science;
+  misc_p.forced_luxury = game.rgame.forced_luxury;
+  misc_p.forced_gold = game.rgame.forced_gold;
   misc_p.min_city_center_food = game.rgame.min_city_center_food;
   misc_p.min_city_center_shield = game.rgame.min_city_center_shield;
   misc_p.min_city_center_trade = game.rgame.min_city_center_trade;

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#8779) Configurable specialists, Per Inge Mathisen <=