Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2004:
[Freeciv-Dev] (PR#7336) A better solution (?) to smallpox
Home

[Freeciv-Dev] (PR#7336) A better solution (?) to smallpox

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#7336) A better solution (?) to smallpox
From: "Gregory Richards" <akaquinn@xxxxxxxxxxx>
Date: Wed, 28 Jan 2004 16:20:13 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [ue80@xxxxxxxxxxxxxxxxxxxxx - Wed Jan 28 09:35:36 2004]: 
>  
> On Tue, Jan 27, 2004 at 08:49:08PM -0800, Gregory Richards wrote: 
> > 
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7336 > 
> > 
> > By the way, I haven't actually tested this with smallpoxers vs. 
> largepoxers, so 
> > I'm not sure how dramatic the effect is. 
>  
> This gives a conquer and destroy city game ... 
>  
> Thomas 
>  
>  
 
Very good point.  Here's a new one.  It drops the realism a bit, but should fix 
that.  It's the same as the original, except that it only counts your cities 
that 
you originally owned, so you can conquest all you want.  Notable is that, if 
your country (probably due to cityfactor) goes into civil war, the other 
countries cities are originally yours, so, they could build more . . . I 
haven't yet 
thought of a clever solution to this. 
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore freeciv-cvs-Jan-27/common/game.c 
freeciv-cvs-Jan-27-noics/common/game.c
--- freeciv-cvs-Jan-27/common/game.c    2003-11-28 22:05:26.000000000 -0800
+++ freeciv-cvs-Jan-27-noics/common/game.c      2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -266,6 +266,11 @@
   game.watchtower_extra_vision=GAME_DEFAULT_WATCHTOWER_EXTRA_VISION,
   game.allowed_city_names = GAME_DEFAULT_ALLOWED_CITY_NAMES;
 
+  game.cfcivilwar = GAME_DEFAULT_SMALLPOX_CIVILWAR;
+  game.cfbarbarian = GAME_DEFAULT_SMALLPOX_BARBARIANISM;
+  game.cfchance = GAME_DEFAULT_SMALLPOX_CHANCE;
+  game.cfwhich = GAME_DEFAULT_SMALLPOX_WHICH;
+
   sz_strlcpy(game.rulesetdir, GAME_DEFAULT_RULESETDIR);
 
   game.num_unit_types = 0;
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore freeciv-cvs-Jan-27/common/game.h 
freeciv-cvs-Jan-27-noics/common/game.h
--- freeciv-cvs-Jan-27/common/game.h    2004-01-11 22:16:19.000000000 -0800
+++ freeciv-cvs-Jan-27-noics/common/game.h      2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -227,6 +227,11 @@
   int trireme_loss_chance[MAX_VET_LEVELS];
   int work_veteran_chance[MAX_VET_LEVELS];
   int veteran_chance[MAX_VET_LEVELS];
+
+  bool cfcivilwar;
+  bool cfbarbarian;
+  int cfchance;
+  int cfwhich;
 };
 
 /* Unused? */
@@ -479,4 +484,9 @@
 
 #define GAME_START_YEAR -4000
 
+#define GAME_DEFAULT_SMALLPOX_CIVILWAR 0
+#define GAME_DEFAULT_SMALLPOX_BARBARIANISM 0
+#define GAME_DEFAULT_SMALLPOX_CHANCE 25
+#define GAME_DEFAULT_SMALLPOX_WHICH 100
+
 #endif  /* FC__GAME_H */
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore freeciv-cvs-Jan-27/common/player.c 
freeciv-cvs-Jan-27-noics/common/player.c
--- freeciv-cvs-Jan-27/common/player.c  2003-11-28 22:05:26.000000000 -0800
+++ freeciv-cvs-Jan-27-noics/common/player.c    2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -149,6 +149,7 @@
   plr->attribute_block.data = NULL;
   plr->attribute_block.length = 0;
   plr->debug = FALSE;
+  plr->cityfactor_turns = 0;
 }
 
 /***************************************************************
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore freeciv-cvs-Jan-27/common/player.h 
freeciv-cvs-Jan-27-noics/common/player.h
--- freeciv-cvs-Jan-27/common/player.h  2003-11-28 22:05:26.000000000 -0800
+++ freeciv-cvs-Jan-27-noics/common/player.h    2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -213,6 +213,8 @@
     void *data;
   } attribute_block;
   bool debug;
+
+  int cityfactor_turns;
 };
 
 void player_init(struct player *plr);
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore 
freeciv-cvs-Jan-27/server/barbarian.c 
freeciv-cvs-Jan-27-noics/server/barbarian.c
--- freeciv-cvs-Jan-27/server/barbarian.c       2004-01-11 22:16:29.000000000 
-0800
+++ freeciv-cvs-Jan-27-noics/server/barbarian.c 2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 2003 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -81,7 +81,7 @@
 
   Dead barbarians forget the map and lose the money.
 **************************************************************************/
-static struct player *create_barbarian_player(bool land)
+struct player *create_barbarian_player(bool land)
 {
   int newplayer = game.nplayers;
   struct player *barbarians;
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore 
freeciv-cvs-Jan-27/server/barbarian.h 
freeciv-cvs-Jan-27-noics/server/barbarian.h
--- freeciv-cvs-Jan-27/server/barbarian.h       2003-05-05 05:41:39.000000000 
-0700
+++ freeciv-cvs-Jan-27-noics/server/barbarian.h 2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -27,6 +27,7 @@
 
 #define MAP_FACTOR     2000  /* adjust this to get a good uprising frequency */
 
+struct player *create_barbarian_player(bool land);
 bool unleash_barbarians(int x, int y);
 void summon_barbarians(void);
 bool is_land_barbarian(struct player *pplayer);
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore 
freeciv-cvs-Jan-27/server/savegame.c freeciv-cvs-Jan-27-noics/server/savegame.c
--- freeciv-cvs-Jan-27/server/savegame.c        2004-01-20 22:16:42.000000000 
-0800
+++ freeciv-cvs-Jan-27-noics/server/savegame.c  2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -200,7 +200,7 @@
   char *pch;
 
   if (ch == ' ') {
-    /* 
+    /*
      * Sane value. It is unknow if there are savegames out there which
      * need this fix. Savegame.c doesn't write such savegames
      * (anymore) since the inclusion into CVS (2000-08-25).
@@ -739,6 +739,8 @@
   plr->capital=secfile_lookup_bool(file, "player%d.capital", plrno);
   plr->revolution=secfile_lookup_int_default(file, 0, "player%d.revolution",
                                              plrno);
+  plr->cityfactor_turns=secfile_lookup_int_default(file, 0, 
"player%d.cityfactor_turns",
+                                             plrno);
 
   tech_type_iterate(i) {
     if (p[i] == '1') {
@@ -1425,6 +1427,7 @@
 
   secfile_insert_bool(file, plr->capital, "player%d.capital", plrno);
   secfile_insert_int(file, plr->revolution, "player%d.revolution", plrno);
+  secfile_insert_int(file, plr->cityfactor_turns, "player%d.cityfactor_turns", 
plrno);
 
   tech_type_iterate(tech_id) {
     invs[tech_id] = (get_invention(plr, tech_id) == TECH_KNOWN) ? '1' : '0';
@@ -2033,7 +2036,16 @@
                                               "game.randseed");
     game.allowed_city_names =
        secfile_lookup_int_default(file, game.allowed_city_names,
-                                  "game.allowed_city_names"); 
+                                  "game.allowed_city_names");
+
+    game.cfcivilwar = secfile_lookup_int_default(file, game.cfcivilwar,
+                                  "game.cfcivilwar");
+    game.cfbarbarian = secfile_lookup_int_default(file, game.cfbarbarian,
+                                  "game.cfbarbarian");
+    game.cfchance = secfile_lookup_int_default(file, game.cfchance,
+                                  "game.cfchance");
+    game.cfwhich = secfile_lookup_int_default(file, game.cfwhich,
+                                  "game.cfwhich");
 
     if(game.civstyle == 1) {
       string = "civ1";
@@ -2387,6 +2399,10 @@
   secfile_insert_int(file, game.watchtower_vision, "game.watchtower_vision");
   secfile_insert_int(file, game.watchtower_extra_vision, 
"game.watchtower_extra_vision");
   secfile_insert_int(file, game.allowed_city_names, "game.allowed_city_names");
+  secfile_insert_int(file, game.cfcivilwar, "game.cfcivilwar");
+  secfile_insert_int(file, game.cfbarbarian, "game.cfbarbarian");
+  secfile_insert_int(file, game.cfchance, "game.cfchance");
+  secfile_insert_int(file, game.cfwhich, "game.cfwhich");
 
   if (TRUE) {
     /* Now always save these, so the server options reflect the
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore 
freeciv-cvs-Jan-27/server/srv_main.c freeciv-cvs-Jan-27-noics/server/srv_main.c
--- freeciv-cvs-Jan-27/server/srv_main.c        2004-01-22 22:15:31.000000000 
-0800
+++ freeciv-cvs-Jan-27-noics/server/srv_main.c  2004-01-28 16:12:14.000000000 
-0800
@@ -51,6 +51,7 @@
 #include "events.h"
 #include "fcintl.h"
 #include "game.h"
+#include "government.h"
 #include "log.h"
 #include "map.h"
 #include "mem.h"
@@ -337,6 +338,112 @@
 }
 
 /**************************************************************************
+Main function to prevent people from using ics as an effective strategy
+**************************************************************************/
+static void cityfactor_handler(void)
+{
+  /* Only handle it if the settings are set to */
+  if ((game.cfcivilwar || game.cfbarbarian) && game.cfchance > 0) {
+    struct player *pplayer, *barb;
+    struct city *pcity, *ccity;
+    int cities, basis, tocivwar, tobarb;
+    int civwars[MAX_NUM_PLAYERS];
+    int barbs[MAX_NUM_PLAYERS];
+    int i, j, k;
+    barb = NULL;
+    tocivwar = 0;
+    tobarb = 0;
+    ccity = NULL;
+    pcity = NULL;
+
+    players_iterate(pplayer) {
+      basis = game.cityfactor + get_gov_pplayer(pplayer)->empire_size_mod;
+      //cities = city_list_size(&pplayer->cities);
+      /* counts only cities that were originally yours */
+      i = 0;
+      city_list_iterate(pplayer->cities, pcity) {
+        if (pcity->original == pplayer->player_no)
+          i++;
+      } city_list_iterate_end;
+      if (cities > basis) {
+        /* Too many cities, time to take rash measures */
+        pplayer->cityfactor_turns++;
+        if (pplayer->cityfactor_turns > 5) { // too late!
+          pplayer->cityfactor_turns = 0;
+          if (myrand(101) <= game.cfchance) { // We get to do some killin'
+            if (game.cfcivilwar && game.cfbarbarian) { // Both are set, take a 
chance
+              if (myrand(101) <= game.cfwhich) { // Barbarians
+                barbs[tobarb] = pplayer->player_no;
+                tobarb++;
+              } else { // Civil war
+                civwars[tocivwar] = pplayer->player_no;
+                tocivwar++;
+              }
+            } else if (game.cfcivilwar) {
+              civwars[tocivwar] = pplayer->player_no;
+              tocivwar++;
+            } else if (game.cfbarbarian) {
+              barbs[tobarb] = pplayer->player_no;
+              tobarb++;
+            }
+          }
+        } else { // Warn them
+          notify_player_ex(pplayer, -1, -1, E_CIVIL_WAR,
+                  _("Game: Your civilization has become too large for you to 
control!  "
+                         "Either disband cities, or change your government to 
a more "
+                         "suitable one."));
+        }
+      } else {
+        if (pplayer->cityfactor_turns > 0) { // They fixed it in time
+          pplayer->cityfactor_turns = 0;
+        }
+      }
+    } players_iterate_end;
+
+    if (tobarb > 0) { // we've got somebody to have cities given to barbarians!
+      for (i = 0; i < tobarb; i++) {
+        players_iterate(pplayer) { // Find a barbarian
+          if (is_barbarian(pplayer)) {
+            barb = pplayer;
+          }
+        } players_iterate_end;
+        if (barb == NULL) { // No available barbarians!
+          barb = create_barbarian_player(TRUE);
+        }
+
+        pplayer = get_player(barbs[tobarb]);
+
+        basis = game.cityfactor + get_gov_pplayer(pplayer)->empire_size_mod;
+        while (city_list_size(&pplayer->cities) > basis) {
+          /* OK, we've got a barbarian, now let's give 'em the city */
+          /* FIXME: this is the only way I know how to get a random city.
+          There's probably a better way */
+          j = myrand(city_list_size(&pplayer->cities));
+          k = 0;
+          city_list_iterate(pplayer->cities, pcity) {
+            if (k == j || k == 0) {
+             ccity = pcity;
+            }
+            k++;
+          } city_list_iterate_end;
+
+          /* What we've all been waiting for */
+          transfer_city(barb, ccity, 1, FALSE, FALSE, FALSE);
+        }
+      }
+    }
+
+    if (tocivwar > 0) { // we've got somebody to incite a civil war!
+      for (i = 0; i < tocivwar; i++) {
+        pplayer = get_player(civwars[i]);
+        civil_war(pplayer);
+      }
+    }
+  }
+}
+
+
+/**************************************************************************
 ...
 **************************************************************************/
 static void update_environmental_upset(enum tile_special_type cause,
@@ -529,6 +636,7 @@
   update_diplomatics();
   do_apollo_program();
   marco_polo_make_contact();
+  cityfactor_handler();
   make_history_report();
   send_player_turn_notifications(NULL);
 
diff -ruN -X freeciv-cvs-Jan-27/diff_ignore 
freeciv-cvs-Jan-27/server/stdinhand.c 
freeciv-cvs-Jan-27-noics/server/stdinhand.c
--- freeciv-cvs-Jan-27/server/stdinhand.c       2004-01-08 22:16:07.000000000 
-0800
+++ freeciv-cvs-Jan-27-noics/server/stdinhand.c 2004-01-28 16:03:01.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -488,7 +488,7 @@
             "cityfactor, one extra citizen is unhappy before other "
             "adjustments; see also unhappysize.  This assumes a "
             "Democracy; for other governments the effect occurs at "
-            "smaller numbers of cities."), NULL, 
+            "smaller numbers of cities."), NULL,
          GAME_MIN_CITYFACTOR, GAME_MAX_CITYFACTOR, GAME_DEFAULT_CITYFACTOR)
 
   GEN_INT("citymindist", game.citymindist, SSET_RULES, SSET_TO_CLIENT,
@@ -873,6 +873,37 @@
             "40=debuging logging."), NULL, 
          0, 40, 20)
 
+  GEN_BOOL("cfcivilwar", game.cfcivilwar, SSET_RULES, SSET_TO_CLIENT,
+         N_("Civil war due to number of cities"),
+         N_("When the number of cities a player owns is greater than "
+            "cityfactor, if this is set, there is also a chance that your "
+            "civilization will erupt into civil war.  "
+            "See cfbarbarian, cfchance and cfwhich"), NULL,
+         GAME_DEFAULT_SMALLPOX_CIVILWAR)
+
+  GEN_BOOL("cfbarbarian", game.cfbarbarian, SSET_RULES, SSET_TO_CLIENT,
+         N_("Barbarians due to number of cities"),
+         N_("When the number of cities a player owns is greater than "
+            "cityfactor, if this is set, there is also a chance that random "
+            "cities will be overtaken by barbarians.  "
+            "See cfcivilwar, cfchance and cfwhich"), NULL,
+         GAME_DEFAULT_SMALLPOX_BARBARIANISM)
+
+  GEN_INT("cfchance", game.cfchance, SSET_RULES, SSET_TO_CLIENT,
+         N_("Chance of civil war or barbarians"),
+         N_("If cfcivilwar or cfbarbarian is set, this is the chance that "
+              "one of the actions will be taken.  "
+              "See cfcivilwar, cfbarbarian and cfwhich"), NULL,
+         0, 100, GAME_DEFAULT_SMALLPOX_CHANCE)
+
+  GEN_INT("cfwhich", game.cfchance, SSET_RULES, SSET_TO_CLIENT,
+         N_("Chance of civil war VS chance of barbarians"),
+         N_("If both cfcivilwar and cfbarbarian is set, this is the 
comparative "
+              "chance of the actions.  A lower number will increase the chance 
"
+              "of a civil war, a higher number will increase the chance of 
barbarians.  "
+              "See cfcivilwar, cfbarbarian and cfchance"), NULL,
+         0, 100, GAME_DEFAULT_CITYFACTOR)
+
   GEN_END
 };
 
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/common/game.c 
freeciv-1.14.1-noics/common/game.c
--- freeciv-1.14.1/common/game.c        2003-12-02 10:56:58.000000000 -0800
+++ freeciv-1.14.1-noics/common/game.c  2004-01-28 16:16:29.000000000 -0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -715,6 +715,11 @@
   game.watchtower_extra_vision=GAME_DEFAULT_WATCHTOWER_EXTRA_VISION,
   game.allowed_city_names = GAME_DEFAULT_ALLOWED_CITY_NAMES;
 
+  game.cfcivilwar = GAME_DEFAULT_SMALLPOX_CIVILWAR;
+  game.cfbarbarian = GAME_DEFAULT_SMALLPOX_BARBARIANISM;
+  game.cfchance = GAME_DEFAULT_SMALLPOX_CHANCE;
+  game.cfwhich = GAME_DEFAULT_SMALLPOX_WHICH;
+
   sz_strlcpy(game.rulesetdir, GAME_DEFAULT_RULESETDIR);
 
   game.firepower_factor = 1;
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/common/game.h 
freeciv-1.14.1-noics/common/game.h
--- freeciv-1.14.1/common/game.h        2003-12-02 10:56:58.000000000 -0800
+++ freeciv-1.14.1-noics/common/game.h  2004-01-28 16:16:29.000000000 -0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -217,6 +217,11 @@
     bool load_private_map; /* Only makes sense if the players are loaded. */
     bool load_settings;
   } load_options;
+
+  bool cfcivilwar;
+  bool cfbarbarian;
+  int cfchance;
+  int cfwhich;
 };
 
 /* Unused? */
@@ -455,4 +460,9 @@
 
 #define GAME_START_YEAR -4000
 
+#define GAME_DEFAULT_SMALLPOX_CIVILWAR 0
+#define GAME_DEFAULT_SMALLPOX_BARBARIANISM 0
+#define GAME_DEFAULT_SMALLPOX_CHANCE 25
+#define GAME_DEFAULT_SMALLPOX_WHICH 100
+
 #endif  /* FC__GAME_H */
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/common/player.c 
freeciv-1.14.1-noics/common/player.c
--- freeciv-1.14.1/common/player.c      2003-12-02 10:56:58.000000000 -0800
+++ freeciv-1.14.1-noics/common/player.c        2004-01-27 20:28:30.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -116,6 +116,7 @@
 
   plr->attribute_block.data = NULL;
   plr->attribute_block.length = 0;
+  plr->cityfactor_turns = 0;
 }
 
 /***************************************************************
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/common/player.h 
freeciv-1.14.1-noics/common/player.h
--- freeciv-1.14.1/common/player.h      2003-12-02 10:56:58.000000000 -0800
+++ freeciv-1.14.1-noics/common/player.h        2004-01-27 20:29:00.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -201,6 +201,7 @@
     int length;
     void *data;
   } attribute_block;
+  int cityfactor_turns;
 };
 
 void player_init(struct player *plr);
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/server/barbarian.c 
freeciv-1.14.1-noics/server/barbarian.c
--- freeciv-1.14.1/server/barbarian.c   2003-11-30 11:22:43.000000000 -0800
+++ freeciv-1.14.1-noics/server/barbarian.c     2004-01-27 20:27:11.000000000 
-0800
@@ -76,7 +76,7 @@
 If barbarians are dead, revive them with a new leader :-)
 Dead barbarians forget the map and lose the money.
 **************************************************************************/
-static struct player *create_barbarian_player(bool land)
+struct player *create_barbarian_player(bool land)
 {
   int newplayer = game.nplayers;
   struct player *barbarians;
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/server/barbarian.h 
freeciv-1.14.1-noics/server/barbarian.h
--- freeciv-1.14.1/server/barbarian.h   2003-11-30 11:22:43.000000000 -0800
+++ freeciv-1.14.1-noics/server/barbarian.h     2004-01-27 20:29:25.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -29,6 +29,7 @@
 
 #define MAP_FACTOR     2000  /* adjust this to get a good uprising frequency */
 
+struct player *create_barbarian_player(bool land);
 bool unleash_barbarians(struct player *victim, int x, int y);
 void summon_barbarians(void);
 bool is_land_barbarian(struct player *pplayer);
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/server/savegame.c 
freeciv-1.14.1-noics/server/savegame.c
--- freeciv-1.14.1/server/savegame.c    2003-11-30 11:22:48.000000000 -0800
+++ freeciv-1.14.1-noics/server/savegame.c      2004-01-28 16:16:29.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -181,7 +181,7 @@
   char *pch;
 
   if (ch == ' ') {
-    /* 
+    /*
      * Sane value. It is unknow if there are savegames out there which
      * need this fix. Savegame.c doesn't write such savegames
      * (anymore) since the inclusion into CVS (2000-08-25).
@@ -643,6 +643,8 @@
   plr->capital=secfile_lookup_bool(file, "player%d.capital", plrno);
   plr->revolution=secfile_lookup_int_default(file, 0, "player%d.revolution",
                                              plrno);
+  plr->cityfactor_turns=secfile_lookup_int_default(file, 0, 
"player%d.cityfactor_turns",
+                                             plrno);
 
   for(i=0; i<game.num_tech_types; i++)
     set_invention(plr, i, (p[i]=='1') ? TECH_KNOWN : TECH_UNKNOWN);
@@ -1284,6 +1286,7 @@
 
   secfile_insert_bool(file, plr->capital, "player%d.capital", plrno);
   secfile_insert_int(file, plr->revolution, "player%d.revolution", plrno);
+  secfile_insert_int(file, plr->cityfactor_turns, "player%d.cityfactor_turns", 
plrno);
 
   for(i=0; i<game.num_tech_types; i++)
     invs[i]=(get_invention(plr, i)==TECH_KNOWN) ? '1' : '0';
@@ -1875,7 +1878,16 @@
                                               "game.randseed");
     game.allowed_city_names =
        secfile_lookup_int_default(file, game.allowed_city_names,
-                                  "game.allowed_city_names"); 
+                                  "game.allowed_city_names");
+
+    game.cfcivilwar = secfile_lookup_int_default(file, game.cfcivilwar,
+                                  "game.cfcivilwar");
+    game.cfbarbarian = secfile_lookup_int_default(file, game.cfbarbarian,
+                                  "game.cfbarbarian");
+    game.cfchance = secfile_lookup_int_default(file, game.cfchance,
+                                  "game.cfchance");
+    game.cfwhich = secfile_lookup_int_default(file, game.cfwhich,
+                                  "game.cfwhich");
 
     if(game.civstyle == 1) {
       string = "civ1";
@@ -2199,6 +2211,10 @@
   secfile_insert_int(file, game.watchtower_vision, "game.watchtower_vision");
   secfile_insert_int(file, game.watchtower_extra_vision, 
"game.watchtower_extra_vision");
   secfile_insert_int(file, game.allowed_city_names, "game.allowed_city_names");
+  secfile_insert_int(file, game.cfcivilwar, "game.cfcivilwar");
+  secfile_insert_int(file, game.cfbarbarian, "game.cfbarbarian");
+  secfile_insert_int(file, game.cfchance, "game.cfchance");
+  secfile_insert_int(file, game.cfwhich, "game.cfwhich");
 
   if (TRUE) {
     /* Now always save these, so the server options reflect the
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/server/srv_main.c 
freeciv-1.14.1-noics/server/srv_main.c
--- freeciv-1.14.1/server/srv_main.c    2003-11-30 11:22:48.000000000 -0800
+++ freeciv-1.14.1-noics/server/srv_main.c      2004-01-28 16:16:29.000000000 
-0800
@@ -49,6 +49,7 @@
 #include "events.h"
 #include "fcintl.h"
 #include "game.h"
+#include "government.h"
 #include "log.h"
 #include "map.h"
 #include "mem.h"
@@ -336,6 +337,112 @@
 }
 
 /**************************************************************************
+Main function to prevent people from using ics as an effective strategy
+**************************************************************************/
+static void cityfactor_handler(void)
+{
+  /* Only handle it if the settings are set to */
+  if ((game.cfcivilwar || game.cfbarbarian) && game.cfchance > 0) {
+    struct player *pplayer, *barb;
+    struct city *pcity, *ccity;
+    int cities, basis, tocivwar, tobarb;
+    int civwars[MAX_NUM_PLAYERS];
+    int barbs[MAX_NUM_PLAYERS];
+    int i, j, k;
+    barb = NULL;
+    tocivwar = 0;
+    tobarb = 0;
+    ccity = NULL;
+    pcity = NULL;
+
+    players_iterate(pplayer) {
+      basis = game.cityfactor + get_gov_pplayer(pplayer)->empire_size_mod;
+      //cities = city_list_size(&pplayer->cities);
+      /* counts only cities that were originally yours */
+      i = 0;
+      city_list_iterate(pplayer->cities, pcity) {
+        if (pcity->original == pplayer->player_no)
+          i++;
+      } city_list_iterate_end;
+      if (cities > basis) {
+        /* Too many cities, time to take rash measures */
+        pplayer->cityfactor_turns++;
+        if (pplayer->cityfactor_turns > 5) { // too late!
+          pplayer->cityfactor_turns = 0;
+          if (myrand(101) <= game.cfchance) { // We get to do some killin'
+            if (game.cfcivilwar && game.cfbarbarian) { // Both are set, take a 
chance
+              if (myrand(101) <= game.cfwhich) { // Barbarians
+                barbs[tobarb] = pplayer->player_no;
+                tobarb++;
+              } else { // Civil war
+                civwars[tocivwar] = pplayer->player_no;
+                tocivwar++;
+              }
+            } else if (game.cfcivilwar) {
+              civwars[tocivwar] = pplayer->player_no;
+              tocivwar++;
+            } else if (game.cfbarbarian) {
+              barbs[tobarb] = pplayer->player_no;
+              tobarb++;
+            }
+          }
+        } else { // Warn them
+          notify_player_ex(pplayer, -1, -1, E_CIVIL_WAR,
+                  _("Game: Your civilization has become too large for you to 
control!  "
+                         "Either disband cities, or change your government to 
a more "
+                         "suitable one."));
+        }
+      } else {
+        if (pplayer->cityfactor_turns > 0) { // They fixed it in time
+          pplayer->cityfactor_turns = 0;
+        }
+      }
+    } players_iterate_end;
+
+    if (tobarb > 0) { // we've got somebody to have cities given to barbarians!
+      for (i = 0; i < tobarb; i++) {
+        players_iterate(pplayer) { // Find a barbarian
+          if (is_barbarian(pplayer)) {
+            barb = pplayer;
+          }
+        } players_iterate_end;
+        if (barb == NULL) { // No available barbarians!
+          barb = create_barbarian_player(TRUE);
+        }
+
+        pplayer = get_player(barbs[tobarb]);
+
+        basis = game.cityfactor + get_gov_pplayer(pplayer)->empire_size_mod;
+        while (city_list_size(&pplayer->cities) > basis) {
+          /* OK, we've got a barbarian, now let's give 'em the city */
+          /* FIXME: this is the only way I know how to get a random city.
+          There's probably a better way */
+          j = myrand(city_list_size(&pplayer->cities));
+          k = 0;
+          city_list_iterate(pplayer->cities, pcity) {
+            if (k == j || k == 0) {
+             ccity = pcity;
+            }
+            k++;
+          } city_list_iterate_end;
+
+          /* What we've all been waiting for */
+          transfer_city(barb, ccity, 1, FALSE, FALSE, FALSE);
+        }
+      }
+    }
+
+    if (tocivwar > 0) { // we've got somebody to incite a civil war!
+      for (i = 0; i < tocivwar; i++) {
+        pplayer = get_player(civwars[i]);
+        civil_war(pplayer);
+      }
+    }
+  }
+}
+
+
+/**************************************************************************
 ...
 **************************************************************************/
 static void update_environmental_upset(enum tile_special_type cause,
@@ -524,6 +631,7 @@
   update_diplomatics();
   do_apollo_program();
   marco_polo_make_contact();
+  cityfactor_handler();
   make_history_report();
   send_player_turn_notifications(NULL);
   freelog(LOG_DEBUG, "Turn ended.");
diff -ruN -X freeciv-1.14.1/diff_ignore freeciv-1.14.1/server/stdinhand.c 
freeciv-1.14.1-noics/server/stdinhand.c
--- freeciv-1.14.1/server/stdinhand.c   2003-11-30 11:22:48.000000000 -0800
+++ freeciv-1.14.1-noics/server/stdinhand.c     2004-01-28 16:16:29.000000000 
-0800
@@ -1,4 +1,4 @@
-/********************************************************************** 
+/**********************************************************************
  Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -466,7 +466,7 @@
             "cityfactor, one extra citizen is unhappy before other "
             "adjustments; see also unhappysize.  This assumes a "
             "Democracy; for other governments the effect occurs at "
-            "smaller numbers of cities."), NULL, 
+            "smaller numbers of cities."), NULL,
          GAME_MIN_CITYFACTOR, GAME_MAX_CITYFACTOR, GAME_DEFAULT_CITYFACTOR)
 
   GEN_INT("citymindist", game.citymindist, SSET_RULES, SSET_TO_CLIENT,
@@ -820,6 +820,37 @@
             "40=debuging logging."), NULL, 
          0, 40, 20)
 
+  GEN_BOOL("cfcivilwar", game.cfcivilwar, SSET_RULES, SSET_TO_CLIENT,
+         N_("Civil war due to number of cities"),
+         N_("When the number of cities a player owns is greater than "
+            "cityfactor, if this is set, there is also a chance that your "
+            "civilization will erupt into civil war.  "
+            "See cfbarbarian, cfchance and cfwhich"), NULL,
+         GAME_DEFAULT_SMALLPOX_CIVILWAR)
+
+  GEN_BOOL("cfbarbarian", game.cfbarbarian, SSET_RULES, SSET_TO_CLIENT,
+         N_("Barbarians due to number of cities"),
+         N_("When the number of cities a player owns is greater than "
+            "cityfactor, if this is set, there is also a chance that random "
+            "cities will be overtaken by barbarians.  "
+            "See cfcivilwar, cfchance and cfwhich"), NULL,
+         GAME_DEFAULT_SMALLPOX_BARBARIANISM)
+
+  GEN_INT("cfchance", game.cfchance, SSET_RULES, SSET_TO_CLIENT,
+         N_("Chance of civil war or barbarians"),
+         N_("If cfcivilwar or cfbarbarian is set, this is the chance that "
+              "one of the actions will be taken.  "
+              "See cfcivilwar, cfbarbarian and cfwhich"), NULL,
+         0, 100, GAME_DEFAULT_SMALLPOX_CHANCE)
+
+  GEN_INT("cfwhich", game.cfchance, SSET_RULES, SSET_TO_CLIENT,
+         N_("Chance of civil war VS chance of barbarians"),
+         N_("If both cfcivilwar and cfbarbarian is set, this is the 
comparative "
+              "chance of the actions.  A lower number will increase the chance 
"
+              "of a civil war, a higher number will increase the chance of 
barbarians.  "
+              "See cfcivilwar, cfbarbarian and cfchance"), NULL,
+         0, 100, GAME_DEFAULT_CITYFACTOR)
+
   GEN_END
 };
 

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