Complete.Org: Mailing Lists: Archives: freeciv-dev: September 2001:
[Freeciv-Dev] Re: Fundamentalism form of government (PR#931)
Home

[Freeciv-Dev] Re: Fundamentalism form of government (PR#931)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Fundamentalism form of government (PR#931)
From: Davide Pagnin <nightmare@xxxxxxxxxx>
Date: Sat, 1 Sep 2001 11:54:40 -0700 (PDT)

        Hi All!
Content-Type: multipart/mixed; boundary="------------73F22BD7BF932EAEC421E15F"

This is a multi-part message in MIME format.
--------------73F22BD7BF932EAEC421E15F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

        Hi All!

This is the patch that tries to introduce fundamentalism.

Try it and comment!

        Ciao, Davide
--------------73F22BD7BF932EAEC421E15F
Content-Type: text/plain; charset=us-ascii;
 name="fundamentalism-added-capstr.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="fundamentalism-added-capstr.diff"

diff -urN -Xfreeciv/diff_ignore freeciv.orig/common/capstr.c 
freeciv/common/capstr.c
--- freeciv.orig/common/capstr.c        Sat Sep  1 18:09:28 2001
+++ freeciv/common/capstr.c     Sat Sep  1 18:11:54 2001
@@ -70,7 +70,7 @@
  * are not directly related to the capability strings discussed here.)
  */
 
-#define CAPABILITY "+1.11.6 conn_info pop_cost turn"
+#define CAPABILITY "+1.11.6 conn_info pop_cost turn fund_added"
   
 /* "+1.11.6" is protocol for 1.11.6 beta release.
   
@@ -82,6 +82,8 @@
    cities.
 
    "turn" additionally transfers game.turn to the client.
+
+   "fund_added" introduces support for fundamentalism form of government.
 */
 
 void init_our_capability(void)

--------------73F22BD7BF932EAEC421E15F
Content-Type: text/plain; charset=us-ascii;
 name="fundamentalism-added.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="fundamentalism-added.diff"

diff -urN -Xfreeciv/diff_ignore freeciv.orig/common/city.c freeciv/common/city.c
--- freeciv.orig/common/city.c  Sat Sep  1 18:02:45 2001
+++ freeciv/common/city.c       Sat Sep  1 18:00:07 2001
@@ -372,14 +372,9 @@
 ignoring whether unit is obsolete.
 **************************************************************************/
 int can_build_unit_direct(struct city *pcity, Unit_Type_id id)
-{  
-  struct player *p=city_owner(pcity);
-  if (!unit_type_exists(id))
-    return 0;
-  if (unit_flag(id, F_NUCLEAR) && !game.global_wonders[B_MANHATTEN])
-    return 0;
-  if (get_invention(p,unit_types[id].tech_requirement)!=TECH_KNOWN)
-    return 0;
+{
+  if (!can_player_build_unit_direct(city_owner(pcity), id))
+       return 0;
   if (!is_terrain_near_tile(pcity->x, pcity->y, T_OCEAN) && is_water_unit(id))
     return 0;
   return 1;
@@ -449,6 +444,8 @@
 **************************************************************************/
 int improvement_upkeep(struct city *pcity, int i) 
 {
+  struct government *g = get_gov_pcity(pcity);
+  
   if (!improvement_exists(i))
     return 0;
   if (is_wonder(i))
@@ -456,6 +453,15 @@
   if (improvement_types[i].upkeep == 1 &&
       city_affected_by_wonder(pcity, B_ASMITHS)) 
     return 0;
+  if (government_has_flag(g, G_CONVERT_TITHES_TO_MONEY)) {
+    if (i == B_TEMPLE) 
+      return 0;
+    if (i == B_COLOSSEUM)
+      return 0;
+    if (i == B_CATHEDRAL)
+      return 0;
+  }
+  
   return (improvement_types[i].upkeep);
 }
 
@@ -464,12 +470,22 @@
 **************************************************************************/
 static int improvement_upkeep_asmiths(struct city *pcity, int i, int asmiths) 
 {
+  struct government *g = get_gov_pcity(pcity);
+
   if (!improvement_exists(i))
     return 0;
   if (is_wonder(i))
     return 0;
   if (asmiths && improvement_types[i].upkeep == 1) 
     return 0;
+  if (government_has_flag(g, G_CONVERT_TITHES_TO_MONEY)) {
+    if (i == B_TEMPLE) 
+      return 0;
+    if (i == B_COLOSSEUM)
+      return 0;
+    if (i == B_CATHEDRAL)
+      return 0;
+  }
   return (improvement_types[i].upkeep);
 }
 
@@ -1331,6 +1347,28 @@
 /**************************************************************************
 ...
 **************************************************************************/
+int get_city_tithes_bonus(struct city *pcity)
+{
+  struct government *g = get_gov_pcity(pcity);
+  int tithes_bonus = 0;
+  if (government_has_flag(g, G_CONVERT_TITHES_TO_MONEY)) {
+    if (city_got_building(pcity, B_TEMPLE))
+      tithes_bonus += get_temple_power(pcity);
+    if (city_got_building(pcity, B_COLOSSEUM))
+      tithes_bonus += get_colosseum_power(pcity);
+    if (city_got_effect(pcity, B_CATHEDRAL))
+      tithes_bonus += get_cathedral_power(pcity);
+    if (city_affected_by_wonder(pcity, B_BACH))
+      tithes_bonus += 2;
+    if (city_affected_by_wonder(pcity, B_CURE))
+      tithes_bonus += 1;
+  }
+  return tithes_bonus;
+}
+
+/**************************************************************************
+...
+**************************************************************************/
 static int set_city_science_bonus(struct city *pcity)
 {
   int science_bonus = 100;
@@ -1355,18 +1393,26 @@
 **************************************************************************/
 static void set_tax_income(struct city *pcity)
 {
+  struct government *g = get_gov_pcity(pcity);
   int sci = 0, tax = 0, lux = 0, rate;
+  int sci_rate = city_owner(pcity)->economic.science;
+  int lux_rate = city_owner(pcity)->economic.luxury;
+  int tax_rate = 100 - sci_rate - lux_rate;
   pcity->science_total = 0;
   pcity->luxury_total = 0;
   pcity->tax_total = 0;
   rate = pcity->trade_prod;
+  if (government_has_flag(g, G_REDUCED_RESEARCH)) {
+    if (sci_rate > 50) {
+      tax_rate = 50 - lux_rate;
+      sci_rate = 50;
+    }
+  }
   while (rate) {
     if (get_gov_pcity(pcity)->index != game.government_when_anarchy) {
-      tax +=
-         (100 - city_owner(pcity)->economic.science -
-          city_owner(pcity)->economic.luxury);
-      sci += city_owner(pcity)->economic.science;
-      lux += city_owner(pcity)->economic.luxury;
+      tax += tax_rate;
+      sci += sci_rate;
+      lux += lux_rate;
     } else {                   /* ANARCHY */
       lux += 100;
     }
@@ -1388,7 +1434,7 @@
   }
   pcity->luxury_total += (pcity->ppl_elvis * 2);
   pcity->science_total += (pcity->ppl_scientist * 3);
-  pcity->tax_total += (pcity->ppl_taxman * 3);
+  pcity->tax_total += (pcity->ppl_taxman * 3) + get_city_tithes_bonus(pcity);
 }
 
 /**************************************************************************
@@ -1398,12 +1444,16 @@
 {
   int tax_bonus, science_bonus;
   int shield_bonus;
+  struct government *g = get_gov_pcity(pcity);
 
   /* this is the place to set them */
   tax_bonus = set_city_tax_bonus(pcity);       
   science_bonus = set_city_science_bonus(pcity);
   shield_bonus = set_city_shield_bonus(pcity);
 
+  if (government_has_flag(g, G_REDUCED_RESEARCH))
+    science_bonus = science_bonus / 2;
+
   pcity->shield_prod = (pcity->shield_prod * shield_bonus) / 100;
   pcity->luxury_total = (pcity->luxury_total * tax_bonus) / 100;
   pcity->tax_total = (pcity->tax_total * tax_bonus) / 100;
@@ -1532,6 +1582,7 @@
 **************************************************************************/
 static void citizen_happy_wonders(struct city *pcity)
 {
+  struct government *g = get_gov_pcity(pcity);
   int bonus = 0;
   happy_copy(pcity, 3);
   bonus = 0;
@@ -1560,6 +1611,11 @@
     pcity->ppl_content[4] += pcity->ppl_unhappy[4];
     pcity->ppl_unhappy[4] = 0;
   }
+  if (government_has_flag(g, G_NO_UNHAPPY_CITIZENS)) {
+    pcity->ppl_content[4] += pcity->ppl_unhappy[4];
+    pcity->ppl_unhappy[4] = 0;
+    pcity->ppl_residue[4] = 0;
+  }
 }
 
 /**************************************************************************
@@ -1779,7 +1835,7 @@
   citizen_happy_luxury(pcity); /* with our new found luxuries */
   citizen_happy_buildings(pcity);      /* temple cathedral colosseum */
   city_support(pcity);         /* manage settlers, and units */
-  citizen_happy_wonders(pcity);        /* happy wonders */
+  citizen_happy_wonders(pcity);        /* happy wonders & fundamentalism */
   unhappy_city_check(pcity);
 }
 
diff -urN -Xfreeciv/diff_ignore freeciv.orig/common/government.c 
freeciv/common/government.c
--- freeciv.orig/common/government.c    Sat Sep  1 18:02:45 2001
+++ freeciv/common/government.c Sat Sep  1 18:00:07 2001
@@ -39,20 +39,15 @@
  * o Test the new government evaluation code (AI).
  *   [ It seems fine to me, although it favours Democracy very early
  *   on. This is because of the huge trade bonus. -SKi ]
- */
-
-/*
- * WISHLIST:
  * o Implement the features needed for fundamentalism:
- *   - Units that require a government to be built, and have special
- *     upkeep values under that government. (Fanatics).
- *   - NO_UNHAPPY_CITIZENS flag for governments.
- *   - CONVERT_TITHES_TO_MONEY flag for governments (surplus only?).
- *   - A research penalty that is applied after all other modifiers.
  *   - A diplomatic penalty modifier when international incidents occur.
  *     (Spy places nuke in city, goes to war, etc).
  *     [ Is this one of those Civ II "features" best be ignored?  I am
  *     inclined to think so -SKi ]
+ */
+
+/*
+ * WISHLIST:
  * o Features needed for CTP-style rules, just more trade, science and
  *   production modifiers.  (Just counting CTP governments, only
  *   basics).
@@ -64,7 +59,9 @@
 
 static const char *flag_names[] = {
   "Build_Veteran_Diplomats", "Revolution_When_Unhappy", "Has_Senate",
-  "Unbribable", "Inspires_Partisans", "Rapture_City_Growth"
+  "Unbribable", "Inspires_Partisans", "Rapture_City_Growth",
+  "Fanatic_Troops", "No_Unhappy_Citizens", "Convert_Tithes_To_Money",
+  "Reduced_Research"
 };
 static const char *hint_names[] = {
   "Is_Nice", "Favors_Growth"
diff -urN -Xfreeciv/diff_ignore freeciv.orig/common/government.h 
freeciv/common/government.h
--- freeciv.orig/common/government.h    Sat Sep  1 18:02:45 2001
+++ freeciv/common/government.h Sat Sep  1 18:00:07 2001
@@ -31,6 +31,10 @@
   G_UNBRIBABLE,
   G_INSPIRES_PARTISANS,
   G_RAPTURE_CITY_GROWTH,        /* allows city to grow by celebrating */
+  G_FANATIC_TROOPS, /* for building troops with F_FANATIC flag */
+  G_NO_UNHAPPY_CITIZENS,   /* no unhappy citizen, needed by fundamentism */
+  G_CONVERT_TITHES_TO_MONEY, /* tithes to money, needed by fundamentalism */
+  G_REDUCED_RESEARCH, /* penalty for research, needed by fundamentalism */
   G_LAST_FLAG
 };
 #define G_FIRST_FLAG G_BUILD_VETERAN_DIPLOMAT
diff -urN -Xfreeciv/diff_ignore freeciv.orig/common/packets.c 
freeciv/common/packets.c
--- freeciv.orig/common/packets.c       Sat Sep  1 18:02:37 2001
+++ freeciv/common/packets.c    Sat Sep  1 18:00:24 2001
@@ -3308,7 +3308,9 @@
   cptr=put_uint8(cptr, packet->corruption_distance_factor);
   cptr=put_uint8(cptr, packet->extra_corruption_distance);
 
-  cptr=put_uint8(cptr, packet->flags);
+  if (pc && has_capability("fund_added", pc->capability))
+    cptr=put_uint16(cptr, packet->flags);
+  else cptr=put_uint8(cptr, packet->flags);
   cptr=put_uint8(cptr, packet->hints);
 
   cptr=put_uint8(cptr, packet->num_ruler_titles);
@@ -3402,7 +3404,9 @@
   iget_uint8(&iter, &packet->corruption_distance_factor);
   iget_uint8(&iter, &packet->extra_corruption_distance);
 
-  iget_uint8(&iter, &packet->flags);
+  if (pc && has_capability("fund_added", pc->capability))
+    iget_uint16(&iter, &packet->flags);
+  else iget_uint8(&iter, &packet->flags);
   iget_uint8(&iter, &packet->hints);
 
   iget_uint8(&iter, &packet->num_ruler_titles);
diff -urN -Xfreeciv/diff_ignore freeciv.orig/common/unittype.c 
freeciv/common/unittype.c
--- freeciv.orig/common/unittype.c      Sat Sep  1 18:02:45 2001
+++ freeciv/common/unittype.c   Sat Sep  1 18:00:07 2001
@@ -44,7 +44,7 @@
   "Fighter", "Marines", "Partial_Invis", "Settlers", "Diplomat",
   "Trireme", "Nuclear", "Spy", "Transform", "Paratroopers",
   "Airbase", "Cities", "IgTired", "Missile_Carrier", "No_Land_Attack",
-  "AddToCity"
+  "AddToCity", "Fanatic"
 };
 static const char *role_names[] = {
   "FirstBuild", "Explorer", "Hut", "HutTech", "Partisan",
@@ -122,6 +122,9 @@
 **************************************************************************/
 int utype_shield_cost(struct unit_type *ut, struct government *g)
 {
+  if (government_has_flag(g, G_FANATIC_TROOPS) &&
+    unit_has_flag(ut, F_FANATIC))
+    return 0;
   return ut->shield_cost * g->unit_shield_cost_factor;
 }
 
@@ -161,6 +164,15 @@
 /**************************************************************************
 ...
 **************************************************************************/
+int unit_has_flag(struct unit_type *ut, int flag)
+{
+  assert(flag>=0 && flag<F_LAST);
+  return BOOL_VAL(ut->flags & (1<<flag));
+}
+
+/**************************************************************************
+...
+**************************************************************************/
 int unit_has_role(Unit_Type_id id, int role)
 {
   assert(role>=L_FIRST && role<L_LAST);
@@ -396,10 +408,14 @@
 player has a coastal city.
 **************************************************************************/
 int can_player_build_unit_direct(struct player *p, Unit_Type_id id)
-{  
+{
+  struct government *g = get_gov_pplayer(p);
+
   if (!unit_type_exists(id))
     return 0;
   if (unit_flag(id, F_NUCLEAR) && !game.global_wonders[B_MANHATTEN])
+    return 0;
+  if (unit_flag(id, F_FANATIC) && !government_has_flag(g, G_FANATIC_TROOPS))
     return 0;
   if (get_invention(p,unit_types[id].tech_requirement)!=TECH_KNOWN)
     return 0;
diff -urN -Xfreeciv/diff_ignore freeciv.orig/common/unittype.h 
freeciv/common/unittype.h
--- freeciv.orig/common/unittype.h      Sat Sep  1 18:02:45 2001
+++ freeciv/common/unittype.h   Sat Sep  1 18:00:07 2001
@@ -104,6 +104,7 @@
   F_MISSILE_CARRIER,  /* Like F_CARRIER, but missiles only (Submarine) */
   F_NO_LAND_ATTACK,   /* Cannot attack vs land squares (Submarine) */
   F_ADD_TO_CITY,      /* unit can add to city population */
+  F_FANATIC,          /* Only Fundamentalist govern can build */
   F_LAST
 };
 
@@ -183,6 +184,8 @@
 
 int unit_flag(Unit_Type_id id, int flag);
 int unit_has_role(Unit_Type_id id, int role);
+
+int unit_has_flag(struct unit_type *ut, int flag);
 
 int is_water_unit(Unit_Type_id id);
 int is_air_unittype(Unit_Type_id id);
diff -urN -Xfreeciv/diff_ignore freeciv.orig/data/civ2/governments.ruleset 
freeciv/data/civ2/governments.ruleset
--- freeciv.orig/data/civ2/governments.ruleset  Sat Sep  1 18:02:45 2001
+++ freeciv/data/civ2/governments.ruleset       Sat Sep  1 18:00:07 2001
@@ -388,10 +388,11 @@
 [government_fundamentalism]
 
 name        = _("Fundamentalism")
-tech_req    = "Never"          ; "Fundamentalism"
+tech_req    = "Fundamentalism"
 graphic     = "gov.fundamentalism"
 graphic_alt = "-"
-flags       = "-"              ; others TODO
+flags       = "No_Unhappy_Citizens", "Convert_Tithes_To_Money", 
+              "Reduced_Research", "Fanatic_Troops"
 hints       = "Favors_Growth"
 subgoal            = "Communism"   ; ??
 
@@ -405,7 +406,7 @@
 
 unit_unhappy_factor = 0
 unit_shield_factor  = 1
-unit_food_factor    = 1
+unit_food_factor    = 2
 unit_gold_factor    = 1 
 
 unit_free_unhappy = 0
@@ -430,9 +431,37 @@
 ruler_male_title = _("High Priest")
 ruler_female_title = _("High Priestess")
 
-; FIXME
 helptext = _("\
-(Sorry, no helptext available.)\
+Fundamentalism is a form of government organized around a central\
+ set of beliefs. The beliefs, usually religious in nature, form\
+ a rigid guideline for actions and reactions of both the rulers\
+ and the people.\
+\n\n\
+In a fundamentalist society, the people and the rulers are entirely\
+ devoted to their beliefs, and are usually willing to die to\
+ preserve them.\
+\n\n\
+Under Fundamentalism, your cities can support up to 10 military\
+ units without paying shields for upkeep. (Additional units\
+ require 1 production shield each. Fanatics units need no upkeep.\
+\n\n\
+Settlers consume 2 food per turn under Fundamentalism.\
+\n\n\
+If a city governed by Fundamentalism is celebrating, it will receive\
+ a bonus of 1 trade in each square which already produces at least 1\
+ trade.  See Happiness for details.\
+\n\n\
+The maximum rate you can set for science, tax or luxuries is 80%.\
+\n\n\
+The maximum effective rate for science is 50%, the surplus is used\
+ for collecting tax, and furthermore the science production is
+ halved.\
+\n\n\
+Cities under Fundamentalism suffer a small amount of corruption.\
+\n\n\
+Improvement that normally convert unhappy citizens to content\
+ citizens, produces `tithes' (gold) equivalent to the number\
+ of people they would convert, and require no maintenance.
 ")
 
 ;------------------------------------------------------------------------
diff -urN -Xfreeciv/diff_ignore freeciv.orig/data/civ2/units.ruleset 
freeciv/data/civ2/units.ruleset
--- freeciv.orig/data/civ2/units.ruleset        Sat Sep  1 18:02:45 2001
+++ freeciv/data/civ2/units.ruleset     Sat Sep  1 18:00:07 2001
@@ -307,8 +307,14 @@
 uk_shield     = 1
 uk_food       = 0
 uk_gold       = 0
-flags         = ""
+flags         = "Fanatic"
 roles         = "DefendGood"
+helptext      = _("\
+Only Fundamentalist nations can build Fanatic units.\
+\n\n\
+Fundamentalist nations can maintain Fanatic units without\
+ having to pay any shields for upkeep.\ 
+")
 
 [unit_partisan]
 name          = _("Partisan")
diff -urN -Xfreeciv/diff_ignore freeciv.orig/server/cityturn.c 
freeciv/server/cityturn.c
--- freeciv.orig/server/cityturn.c      Sat Sep  1 18:02:45 2001
+++ freeciv/server/cityturn.c   Sat Sep  1 18:00:08 2001
@@ -256,7 +256,7 @@
 }
 
 /**************************************************************************
-You need to call sync_cities for teh affected cities to be synced with the
+You need to call sync_cities for the affected cities to be synced with the
 client.
 **************************************************************************/
 void auto_arrange_workers(struct city *pcity)

--------------73F22BD7BF932EAEC421E15F--




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