[Freeciv-Dev] (PR#7336) Patch: limit ICS through civil war/barbs
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: |
undisclosed-recipients: ; |
Subject: |
[Freeciv-Dev] (PR#7336) Patch: limit ICS through civil war/barbs |
From: |
"Gregory Richards" <akaquinn@xxxxxxxxxxx> |
Date: |
Sun, 18 Jul 2004 19:13:28 -0700 |
Reply-to: |
rt@xxxxxxxxxxx |
<URL: http://rt.freeciv.org/Ticket/Display.html?id=7336 >
> [jing - Fri Jul 16 06:12:22 2004]:
>
> I don't think this is the right way to cure smallpox/ICS, and we
have
> too many server options already. I suggest the patch be rejected.
>
> Mike Jing
>
>
I don't think there's really such thing as too many options . . . it'd
be nice if they were in alphabetical order though, and maybe only some
of them showed up unless you requested. Such as a "show" and "show
all," show only showing the most commonly used options, show all
showing, of course, all.
Anyway, I updated this NoICS patch to work with the latest CVS, so
here's a new patch. Not that anybody thinks this is good :P
diff -ruN -X freeciv-cvs-Jul-16/diff_ignore freeciv-cvs-Jul-16/common/game.c
freeciv-cvs-Jul-16-noics/common/game.c
--- freeciv-cvs-Jul-16/common/game.c 2004-07-03 22:13:53.000000000 -0700
+++ freeciv-cvs-Jul-16-noics/common/game.c 2004-07-18 16:12:21.000000000
-0700
@@ -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
@@ -265,6 +265,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-Jul-16/diff_ignore freeciv-cvs-Jul-16/common/game.h
freeciv-cvs-Jul-16-noics/common/game.h
--- freeciv-cvs-Jul-16/common/game.h 2004-07-13 22:14:44.000000000 -0700
+++ freeciv-cvs-Jul-16-noics/common/game.h 2004-07-18 16:12:59.000000000
-0700
@@ -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
@@ -240,6 +240,11 @@
int work_veteran_chance[MAX_VET_LEVELS];
int veteran_chance[MAX_VET_LEVELS];
int revolution_length; /* 0=> random length, else the fixated length */
+
+ bool cfcivilwar;
+ bool cfbarbarian;
+ int cfchance;
+ int cfwhich;
};
/* Unused? */
@@ -511,4 +516,9 @@
} \
}
+#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-Jul-16/diff_ignore freeciv-cvs-Jul-16/common/player.c
freeciv-cvs-Jul-16-noics/common/player.c
--- freeciv-cvs-Jul-16/common/player.c 2004-07-13 22:14:44.000000000 -0700
+++ freeciv-cvs-Jul-16-noics/common/player.c 2004-07-18 16:12:21.000000000
-0700
@@ -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
@@ -147,6 +147,7 @@
plr->attribute_block.data = NULL;
plr->attribute_block.length = 0;
plr->debug = FALSE;
+ plr->cityfactor_turns = 0;
}
/***************************************************************
diff -ruN -X freeciv-cvs-Jul-16/diff_ignore freeciv-cvs-Jul-16/common/player.h
freeciv-cvs-Jul-16-noics/common/player.h
--- freeciv-cvs-Jul-16/common/player.h 2004-04-23 22:11:20.000000000 -0700
+++ freeciv-cvs-Jul-16-noics/common/player.h 2004-07-18 16:12:21.000000000
-0700
@@ -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,8 @@
void *data;
} attribute_block;
bool debug;
+
+ int cityfactor_turns;
};
void player_init(struct player *plr);
diff -ruN -X freeciv-cvs-Jul-16/diff_ignore
freeciv-cvs-Jul-16/server/barbarian.c
freeciv-cvs-Jul-16-noics/server/barbarian.c
--- freeciv-cvs-Jul-16/server/barbarian.c 2004-07-12 22:14:47.000000000
-0700
+++ freeciv-cvs-Jul-16-noics/server/barbarian.c 2004-07-18 16:12:21.000000000
-0700
@@ -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-Jul-16/diff_ignore
freeciv-cvs-Jul-16/server/barbarian.h
freeciv-cvs-Jul-16-noics/server/barbarian.h
--- freeciv-cvs-Jul-16/server/barbarian.h 2003-05-05 05:41:39.000000000
-0700
+++ freeciv-cvs-Jul-16-noics/server/barbarian.h 2004-07-18 16:12:21.000000000
-0700
@@ -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-Jul-16/diff_ignore
freeciv-cvs-Jul-16/server/savegame.c freeciv-cvs-Jul-16-noics/server/savegame.c
--- freeciv-cvs-Jul-16/server/savegame.c 2004-07-14 22:15:33.000000000
-0700
+++ freeciv-cvs-Jul-16-noics/server/savegame.c 2004-07-18 16:12:21.000000000
-0700
@@ -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
@@ -202,7 +202,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).
@@ -1239,6 +1239,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') {
@@ -1856,6 +1858,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';
@@ -2509,7 +2512,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";
@@ -2893,6 +2905,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-Jul-16/diff_ignore
freeciv-cvs-Jul-16/server/srv_main.c freeciv-cvs-Jul-16-noics/server/srv_main.c
--- freeciv-cvs-Jul-16/server/srv_main.c 2004-07-16 22:15:10.000000000
-0700
+++ freeciv-cvs-Jul-16-noics/server/srv_main.c 2004-07-18 16:13:36.000000000
-0700
@@ -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"
@@ -335,6 +336,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 */
+ cities = 0;
+ city_list_iterate(pplayer->cities, pcity) {
+ if (pcity->original == pplayer->player_no)
+ cities++;
+ } 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,
@@ -552,6 +659,7 @@
do_apollo_program();
marco_polo_make_contact();
+ cityfactor_handler();
/* Moved this to after the human turn for efficiency -- Syela */
freelog(LOG_DEBUG, "Autosettlers");
diff -ruN -X freeciv-cvs-Jul-16/diff_ignore
freeciv-cvs-Jul-16/server/stdinhand.c
freeciv-cvs-Jul-16-noics/server/stdinhand.c
--- freeciv-cvs-Jul-16/server/stdinhand.c 2004-07-12 22:14:48.000000000
-0700
+++ freeciv-cvs-Jul-16-noics/server/stdinhand.c 2004-07-18 16:19:05.000000000
-0700
@@ -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
@@ -553,7 +553,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_SOCIOLOGY,
@@ -979,6 +979,41 @@
"40=debuging logging."), NULL,
0, 40, 20)
+ GEN_BOOL("cfcivilwar", game.cfcivilwar, SSET_META, SSET_INTERNAL,
+ 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_META, SSET_INTERNAL,
+ 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_META, SSET_INTERNAL,
+ 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_META, SSET_INTERNAL,
+ 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] |
- [Freeciv-Dev] (PR#7336) Patch: limit ICS through civil war/barbs,
Gregory Richards <=
|
|