[Freeciv-Dev] (PR#12757) Move some govt stuff to effects
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: |
[Freeciv-Dev] (PR#12757) Move some govt stuff to effects |
From: |
"Per I. Mathisen" <per@xxxxxxxxxxx> |
Date: |
Sun, 10 Apr 2005 02:58:31 -0700 |
Reply-to: |
bugs@xxxxxxxxxxx |
<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12757 >
CHANGES:
- New effects:
"Civil_War_Chance",
"Empire_Size_Mod",
"Empire_Size_Step",
"Max_Rates",
"Martial_Law_Each",
"Martial_Law_Max",
"Rapture_Size",
"Unbribable_Units",
"Veteran_Diplomats",
"Revolution_When_Unhappy",
"Has_Senate",
"Inspire_Partisans",
"Happiness_To_Gold",
"Fanatics"
- Removes partisan hack from units.ruleset (no longer necessary)
- Effects crash if called before game load fixed
- Code is cleaner and more generalized (eg you can now have buildings
to make veteran diplomats, allowing rapture growth, implementing
senate, etc)
- Several generalizations came for free (treatment of EFT_NO_INCITE eg)
Bad stuff can happen if Max_Rates effect gets added up above 100. I am not
sure if this is worth safeguarding.
Government help texts related to above effects are gone. Ifdef'ed out.
This needs more effects/requirements code support before it can be
reimplemented.
Only gtk2 client fixed. Only default ruleset updated.
- Per
Index: ai/advdomestic.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/advdomestic.c,v
retrieving revision 1.128
diff -u -r1.128 advdomestic.c
--- ai/advdomestic.c 10 Mar 2005 20:05:22 -0000 1.128
+++ ai/advdomestic.c 10 Apr 2005 09:48:15 -0000
@@ -149,7 +149,7 @@
&& (pcity->id != ai->wonder_city
|| get_unit_type(unit_type)->pop_cost == 0)
&& pcity->surplus[O_FOOD] > utype_upkeep_cost(get_unit_type(unit_type),
- gov, O_FOOD)) {
+ pplayer, gov, O_FOOD)) {
/* settler_want calculated in settlers.c called from ai_manage_cities() */
int want = pcity->ai.settler_want;
@@ -178,7 +178,7 @@
&& (pcity->id != ai->wonder_city
|| get_unit_type(unit_type)->pop_cost == 0)
&& pcity->surplus[O_FOOD] >= utype_upkeep_cost(get_unit_type(unit_type),
- gov, O_FOOD)) {
+ pplayer, gov, O_FOOD)) {
/* founder_want calculated in settlers.c, called from ai_manage_cities().
*/
int want = pcity->ai.founder_want;
Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.209
diff -u -r1.209 aicity.c
--- ai/aicity.c 10 Apr 2005 00:50:36 -0000 1.209
+++ ai/aicity.c 10 Apr 2005 09:48:15 -0000
@@ -339,7 +339,7 @@
case EFT_MAKE_HAPPY:
v += (get_entertainers(pcity) + pcity->ppl_unhappy[4]) * 5 * amount;
if (city_list_size(pplayer->cities)
- > game.cityfactor + gov->empire_size_mod) {
+ > game.cityfactor + get_player_bonus(pplayer,
EFT_EMPIRE_SIZE_MOD)) {
v += c * amount; /* offset large empire size */
}
v += c * amount;
@@ -352,16 +352,17 @@
break;
case EFT_FORCE_CONTENT:
case EFT_MAKE_CONTENT:
- if (!government_has_flag(gov, G_NO_UNHAPPY_CITIZENS)) {
+ if (get_city_bonus(pcity, EFT_NO_UNHAPPY) <= 0) {
int factor = 2;
v += MIN(amount, pcity->ppl_unhappy[4] + get_entertainers(pcity)) *
35;
/* Try to build wonders to offset empire size unhappiness */
if (city_list_size(pplayer->cities)
- > game.cityfactor + gov->empire_size_mod) {
- if (gov->empire_size_mod > 0) {
- factor += city_list_size(pplayer->cities) /
gov->empire_size_inc;
+ > game.cityfactor + get_player_bonus(pplayer,
EFT_EMPIRE_SIZE_MOD)) {
+ if (get_player_bonus(pplayer, EFT_EMPIRE_SIZE_MOD) > 0) {
+ factor += city_list_size(pplayer->cities)
+ / get_player_bonus(pplayer, EFT_EMPIRE_SIZE_STEP);
}
factor += 2;
}
@@ -369,14 +370,14 @@
}
break;
case EFT_MAKE_CONTENT_MIL_PER:
- if (!government_has_flag(gov, G_NO_UNHAPPY_CITIZENS)) {
+ if (get_city_bonus(pcity, EFT_NO_UNHAPPY) <= 0) {
v += MIN(pcity->ppl_unhappy[4] + get_entertainers(pcity),
amount) * 25;
v += MIN(amount, 5) * c;
}
break;
case EFT_MAKE_CONTENT_MIL:
- if (!government_has_flag(gov, G_NO_UNHAPPY_CITIZENS)) {
+ if (get_city_bonus(pcity, EFT_NO_UNHAPPY) <= 0) {
v += pcity->ppl_unhappy[4] * amount
* MAX(unit_list_size(pcity->units_supported)
- gov->free_happy, 0) * 2;
@@ -557,7 +558,7 @@
v += (1 + ai->threats.invasions + !ai->threats.igwall) * c;
break;
case EFT_NO_INCITE:
- if (!government_has_flag(gov, G_UNBRIBABLE)) {
+ if (get_city_bonus(pcity, EFT_NO_INCITE) <= 0) {
v += MAX((game.diplchance * 2 - game.incite_cost.total_factor) / 2
- game.incite_cost.improvement_factor * 5
- game.incite_cost.unit_factor * 5, 0);
@@ -579,6 +580,22 @@
}
} players_iterate_end;
break;
+ /* Currently not supported for building AI - wait for modpack users */
+ case EFT_CIVIL_WAR_CHANCE:
+ case EFT_EMPIRE_SIZE_MOD:
+ case EFT_EMPIRE_SIZE_STEP:
+ case EFT_MAX_RATES:
+ case EFT_MARTIAL_LAW_EACH:
+ case EFT_MARTIAL_LAW_MAX:
+ case EFT_RAPTURE_SIZE:
+ case EFT_UNBRIBABLE_UNITS:
+ case EFT_VETERAN_DIPLOMATS:
+ case EFT_REVOLUTION_WHEN_UNHAPPY:
+ case EFT_HAS_SENATE:
+ case EFT_INSPIRE_PARTISANS:
+ case EFT_HAPPINESS_TO_GOLD:
+ case EFT_FANATICS:
+ break;
case EFT_LAST:
freelog(LOG_ERROR, "Bad effect type.");
break;
Index: ai/aidiplomat.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aidiplomat.c,v
retrieving revision 1.48
diff -u -r1.48 aidiplomat.c
--- ai/aidiplomat.c 21 Mar 2005 12:28:00 -0000 1.48
+++ ai/aidiplomat.c 10 Apr 2005 09:48:15 -0000
@@ -459,9 +459,8 @@
if (!pvictim
|| !HOSTILE_PLAYER(pplayer, ai, unit_owner(pvictim))
|| unit_list_size(ptile->units) > 1
- || map_get_city(pos.tile)
- || government_has_flag(get_gov_pplayer(unit_owner(pvictim)),
- G_UNBRIBABLE)) {
+ || !ptile->city
+ || get_city_bonus(ptile->city, EFT_NO_INCITE) <= 0) {
continue;
}
Index: ai/aihand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aihand.c,v
retrieving revision 1.110
diff -u -r1.110 aihand.c
--- ai/aihand.c 28 Mar 2005 17:14:57 -0000 1.110
+++ ai/aihand.c 10 Apr 2005 09:48:16 -0000
@@ -96,10 +96,9 @@
static void ai_manage_taxes(struct player *pplayer)
{
int maxrate = (ai_handicap(pplayer, H_RATES)
- ? get_government_max_rate(pplayer->government) : 100);
+ ? get_player_bonus(pplayer, EFT_MAX_RATES) : 100);
bool celebrate = TRUE;
int can_celebrate = 0, total_cities = 0;
- struct government *g = get_gov_pplayer(pplayer);
int trade = 0; /* total amount of trade generated */
int expenses = 0; /* total amount of gold upkeep */
@@ -169,7 +168,8 @@
/* TODO: In the future, we should check if we should
* celebrate for other reasons than growth. Currently
* this is ignored. Maybe we need ruleset AI hints. */
- if (government_has_flag(g, G_RAPTURE_CITY_GROWTH)) {
+ /* TODO: Allow celebrate individual cities? No modpacks use this yet. */
+ if (get_player_bonus(pplayer, EFT_RAPTURE_SIZE)) {
int luxrate = pplayer->economic.luxury;
int scirate = pplayer->economic.science;
struct cm_parameter cmp;
@@ -196,7 +196,7 @@
if (cmr.found_a_valid
&& pcity->surplus[O_FOOD] > 0
- && pcity->size >= g->rapture_size
+ && pcity->size >= get_city_bonus(pcity, EFT_RAPTURE_SIZE)
&& city_can_grow_to(pcity, pcity->size + 1)) {
pcity->ai.celebrate = TRUE;
can_celebrate++;
@@ -312,25 +312,14 @@
/* Bonuses for non-economic abilities. We increase val by
* a very small amount here to choose govt in cases where
* we have no cities yet. */
- if (government_has_flag(gov, G_BUILD_VETERAN_DIPLOMAT)) {
- bonus += 3; /* WAG */
- }
- if (government_has_flag(gov, G_REVOLUTION_WHEN_UNHAPPY)) {
- bonus -= 3; /* Not really a problem for us */ /* WAG */
- }
- if (government_has_flag(gov, G_UNBRIBABLE)) {
- bonus += 5; /* WAG */
- }
- if (government_has_flag(gov, G_INSPIRES_PARTISANS)) {
- bonus += 3; /* WAG */
- }
- if (government_has_flag(gov, G_RAPTURE_CITY_GROWTH)) {
- bonus += 5; /* WAG */
- val += 1;
- }
- if (government_has_flag(gov, G_FANATIC_TROOPS)) {
- bonus += 3; /* WAG */
- }
+ bonus += get_player_bonus(pplayer, EFT_VETERAN_DIPLOMATS) ? 3 : 0;
+ bonus -= get_player_bonus(pplayer, EFT_REVOLUTION_WHEN_UNHAPPY) ? 3 : 0;
+ bonus += get_player_bonus(pplayer, EFT_NO_INCITE) ? 4 : 0;
+ bonus += get_player_bonus(pplayer, EFT_UNBRIBABLE_UNITS) ? 2 : 0;
+ bonus += get_player_bonus(pplayer, EFT_INSPIRE_PARTISANS) ? 3 : 0;
+ bonus += get_player_bonus(pplayer, EFT_RAPTURE_SIZE) * 2;
+ val += get_player_bonus(pplayer, EFT_RAPTURE_SIZE);
+ bonus += get_player_bonus(pplayer, EFT_FANATICS) ? 3 : 0;
output_type_iterate(o) {
val += gov->output_inc_tile[o];
} output_type_iterate_end;
Index: client/helpdata.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/helpdata.c,v
retrieving revision 1.99
diff -u -r1.99 helpdata.c
--- client/helpdata.c 28 Mar 2005 17:14:57 -0000 1.99
+++ client/helpdata.c 10 Apr 2005 09:48:16 -0000
@@ -1227,6 +1227,7 @@
for (j = 0; j < MAX_NUM_REQS; j++) {
insert_requirement(gov->req + j, buf, bufsz);
}
+#if 0
if (gov->max_rate < 100 && game.rgame.changable_tax) {
sprintf(buf + strlen(buf),
_("The maximum rate you can set for science, "
@@ -1277,6 +1278,7 @@
gov->free_happy);
}
}
+#endif
output_type_iterate(ot) {
if (gov->free_upkeep[ot] == G_CITY_SIZE_FREE) {
sprintf(buf + strlen(buf),
@@ -1370,6 +1372,7 @@
"waste.\n"), get_output_name(ot));
}
} output_type_iterate_end;
+#if 0
if (government_has_flag(gov, G_RAPTURE_CITY_GROWTH)) {
sprintf(buf + strlen(buf),
_("* You may grow your cities by "
@@ -1432,6 +1435,7 @@
if (government_has_flag(gov, G_REDUCED_RESEARCH)) {
sprintf(buf + strlen(buf), _("* Research costs doubled.\n"));
}
+#endif
unit_type_iterate(ut) {
struct unit_type *utype = get_unit_type(ut);
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.486
diff -u -r1.486 packhand.c
--- client/packhand.c 1 Apr 2005 00:05:59 -0000 1.486
+++ client/packhand.c 10 Apr 2005 09:48:17 -0000
@@ -2089,11 +2089,6 @@
game.notradesize = packet->notradesize;
game.fulltradesize = packet->fulltradesize;
- for(i=0; i<MAX_NUM_TECH_LIST; i++) {
- game.rtech.partisan_req[i] = packet->rtech_partisan_req[i];
- freelog(LOG_DEBUG, "techl %d: %d", i, game.rtech.partisan_req[i]);
- }
-
game.government_when_anarchy = packet->government_when_anarchy;
game.default_government = packet->default_government;
@@ -2322,14 +2317,6 @@
p->req_survives[j], p->req_value[j]);
}
- gov->max_rate = p->max_rate;
- gov->civil_war = p->civil_war;
- gov->martial_law_max = p->martial_law_max;
- gov->martial_law_per = p->martial_law_per;
- gov->empire_size_mod = p->empire_size_mod;
- gov->empire_size_inc = p->empire_size_inc;
- gov->rapture_size = p->rapture_size;
-
gov->unit_happy_cost_factor = p->unit_happy_cost_factor;
gov->free_happy = p->free_happy;
@@ -2349,7 +2336,6 @@
gov->waste[o].max_distance_cap = p->waste_max_distance_cap[o];
} output_type_iterate_end;
- gov->flags = p->flags;
gov->num_ruler_titles = p->num_ruler_titles;
sz_strlcpy(gov->name_orig, p->name);
Index: client/repodlgs_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/repodlgs_common.c,v
retrieving revision 1.21
diff -u -r1.21 repodlgs_common.c
--- client/repodlgs_common.c 19 Dec 2004 16:47:08 -0000 1.21
+++ client/repodlgs_common.c 10 Apr 2005 09:48:17 -0000
@@ -99,8 +99,8 @@
unit_type_iterate(utype) {
unittype = get_unit_type(utype);
- cost = utype_upkeep_cost(unittype, get_gov_pplayer(game.player_ptr),
- O_GOLD);
+ cost = utype_upkeep_cost(unittype, game.player_ptr,
+ get_gov_pplayer(game.player_ptr), O_GOLD);
if (cost == 0) {
/* Short-circuit all of the following checks. */
Index: client/gui-gtk-2.0/gamedlgs.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/gamedlgs.c,v
retrieving revision 1.29
diff -u -r1.29 gamedlgs.c
--- client/gui-gtk-2.0/gamedlgs.c 8 Feb 2005 10:01:08 -0000 1.29
+++ client/gui-gtk-2.0/gamedlgs.c 10 Apr 2005 09:48:17 -0000
@@ -73,7 +73,7 @@
lux_lock = GTK_TOGGLE_BUTTON(rates_lux_toggle)->active;
sci_lock = GTK_TOGGLE_BUTTON(rates_sci_toggle)->active;
- maxrate=get_government_max_rate(game.player_ptr->government);
+ maxrate = get_player_bonus(game.player_ptr, EFT_MAX_RATES);
/* This's quite a simple-minded "double check".. */
tax=MIN(tax, maxrate);
lux=MIN(lux, maxrate);
@@ -335,7 +335,7 @@
my_snprintf(buf, sizeof(buf), _("%s max rate: %d%%"),
get_government_name(game.player_ptr->government),
- get_government_max_rate(game.player_ptr->government));
+ get_player_bonus(game.player_ptr, EFT_MAX_RATES));
gtk_label_set_text(GTK_LABEL(rates_gov_label), buf);
gtk_window_present(GTK_WINDOW(rates_dialog_shell));
Index: client/gui-gtk-2.0/happiness.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/happiness.c,v
retrieving revision 1.20
diff -u -r1.20 happiness.c
--- client/gui-gtk-2.0/happiness.c 28 Mar 2005 16:48:40 -0000 1.20
+++ client/gui-gtk-2.0/happiness.c 10 Apr 2005 09:48:17 -0000
@@ -221,11 +221,11 @@
struct city *pcity = pdialog->pcity;
struct player *pplayer = &game.players[pcity->owner];
- struct government *g = get_gov_pcity(pcity);
int cities = city_list_size(pplayer->cities);
int content = game.unhappysize;
- int basis = game.cityfactor + g->empire_size_mod;
- int step = g->empire_size_inc;
+ int basis = game.cityfactor
+ + get_player_bonus(game.player_ptr, EFT_EMPIRE_SIZE_MOD);
+ int step = get_player_bonus(game.player_ptr, EFT_EMPIRE_SIZE_STEP);
int excess = cities - basis;
int penalty = 0;
@@ -287,7 +287,7 @@
int nleft = sizeof(buf);
struct city *pcity = pdialog->pcity;
struct government *g = get_gov_pcity(pcity);
- int mlmax = g->martial_law_max;
+ int mlmax = get_city_bonus(pcity, EFT_MARTIAL_LAW_MAX);
int uhcfac = g->unit_happy_cost_factor;
my_snprintf(bptr, nleft, _("Units: "));
@@ -304,7 +304,8 @@
"%d units maximum, ", mlmax), mlmax);
bptr = end_of_strn(bptr, &nleft);
- my_snprintf(bptr, nleft, _("%d per unit). "), g->martial_law_per);
+ my_snprintf(bptr, nleft, _("%d per unit). "),
+ get_city_bonus(pcity, EFT_MARTIAL_LAW_EACH));
}
else if (uhcfac > 0) {
my_snprintf(bptr, nleft,
Index: common/city.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/city.c,v
retrieving revision 1.323
diff -u -r1.323 city.c
--- common/city.c 3 Apr 2005 20:19:51 -0000 1.323
+++ common/city.c 10 Apr 2005 09:48:17 -0000
@@ -1130,7 +1130,7 @@
**************************************************************************/
bool base_city_celebrating(const struct city *pcity)
{
- return (pcity->size >= get_gov_pcity(pcity)->rapture_size
+ return (pcity->size >= get_city_bonus(pcity, EFT_RAPTURE_SIZE)
&& pcity->was_happy);
}
@@ -1148,11 +1148,9 @@
**************************************************************************/
bool city_rapture_grow(const struct city *pcity)
{
- struct government *g = get_gov_pcity(pcity);
-
return (pcity->rapture > 0 && pcity->surplus[O_FOOD] > 0
&& (pcity->rapture % game.rapturedelay) == 0
- && government_has_flag(g, G_RAPTURE_CITY_GROWTH));
+ && get_city_bonus(pcity, EFT_RAPTURE_SIZE) > 0);
}
/**************************************************************************
@@ -1564,8 +1562,8 @@
{
int cities = city_list_size(pplayer->cities);
int content = game.unhappysize;
- int basis = game.cityfactor + get_gov_pplayer(pplayer)->empire_size_mod;
- int step = get_gov_pplayer(pplayer)->empire_size_inc;
+ int basis = game.cityfactor + get_player_bonus(pplayer, EFT_EMPIRE_SIZE_MOD);
+ int step = get_player_bonus(pplayer, EFT_EMPIRE_SIZE_STEP);
if (cities > basis) {
content--;
@@ -1590,11 +1588,6 @@
bonus += get_city_bonus(pcity, eft);
}
- if (otype == O_SCIENCE
- && government_has_flag(get_gov_pcity(pcity), G_REDUCED_RESEARCH)) {
- bonus /= 2;
- }
-
return bonus;
}
@@ -1606,8 +1599,7 @@
{
int tithes_bonus = 0;
- if (!government_has_flag(get_gov_pcity(pcity),
- G_CONVERT_TITHES_TO_MONEY)) {
+ if (!get_city_bonus(pcity, EFT_HAPPINESS_TO_GOLD)) {
return 0;
}
@@ -1956,8 +1948,7 @@
}
/* The rest falls through and lets unhappy people become content. */
- if (get_city_bonus(pcity, EFT_NO_UNHAPPY) > 0
- || government_has_flag(get_gov_pcity(pcity), G_NO_UNHAPPY_CITIZENS)) {
+ if (get_city_bonus(pcity, EFT_NO_UNHAPPY) > 0) {
*content += *unhappy + *angry;
*unhappy = 0;
*angry = 0;
@@ -2113,6 +2104,7 @@
void (*send_unit_info) (struct player *pplayer,
struct unit *punit))
{
+ struct player *plr = city_owner(pcity);
struct government *g = get_gov_pcity(pcity);
int free_happy = citygov_free_happy(pcity, g);
@@ -2146,15 +2138,15 @@
/* military units in this city (need _not_ be home city) can make
unhappy citizens content
*/
- if (g->martial_law_max > 0) {
+ if (get_city_bonus(pcity, EFT_MARTIAL_LAW_MAX) > 0) {
unit_list_iterate(pcity->tile->units, punit) {
- if (pcity->martial_law < g->martial_law_max
+ if (pcity->martial_law < get_city_bonus(pcity, EFT_MARTIAL_LAW_MAX)
&& is_military_unit(punit)
&& punit->owner == pcity->owner) {
pcity->martial_law++;
}
} unit_list_iterate_end;
- pcity->martial_law *= g->martial_law_per;
+ pcity->martial_law *= get_city_bonus(pcity, EFT_MARTIAL_LAW_EACH);
}
/* loop over units, subtracting appropriate amounts of food, shields,
@@ -2169,7 +2161,7 @@
int old_unhappiness = this_unit->unhappiness;
output_type_iterate(o) {
- upkeep_cost[o] = utype_upkeep_cost(ut, g, o);
+ upkeep_cost[o] = utype_upkeep_cost(ut, plr, g, o);
old_upkeep[o] = this_unit->upkeep[o];
} output_type_iterate_end;
Index: common/effects.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.c,v
retrieving revision 1.27
diff -u -r1.27 effects.c
--- common/effects.c 10 Apr 2005 00:50:37 -0000 1.27
+++ common/effects.c 10 Apr 2005 09:48:18 -0000
@@ -118,9 +118,25 @@
"No_Incite",
"Regen_Reputation",
"Gain_AI_Love",
- "Slow_Down_Timeline"
+ "Slow_Down_Timeline",
+ "Civil_War_Chance",
+ "Empire_Size_Mod",
+ "Empire_Size_Step",
+ "Max_Rates",
+ "Martial_Law_Each",
+ "Martial_Law_Max",
+ "Rapture_Size",
+ "Unbribable_Units",
+ "Veteran_Diplomats",
+ "Revolution_When_Unhappy",
+ "Has_Senate",
+ "Inspire_Partisans",
+ "Happiness_To_Gold",
+ "Fanatics"
};
+static bool initialized = FALSE;
+
/**************************************************************************
Convert effect type names to enum; case insensitive;
returns EFT_LAST if can't match.
@@ -340,6 +356,8 @@
{
int i;
+ initialized = TRUE;
+
ruleset_cache.tracker = effect_list_new();
for (i = 0; i < ARRAY_SIZE(ruleset_cache.effects); i++) {
@@ -715,6 +733,10 @@
**************************************************************************/
int get_world_bonus(enum effect_type effect_type)
{
+ if (!initialized) {
+ return 0;
+ }
+
return get_target_bonus_effects(NULL,
NULL, NULL, B_LAST, NULL, effect_type);
}
@@ -725,7 +747,10 @@
int get_player_bonus(const struct player *pplayer,
enum effect_type effect_type)
{
- assert(pplayer != NULL);
+ if (!initialized) {
+ return 0;
+ }
+
return get_target_bonus_effects(NULL,
pplayer, NULL, B_LAST, NULL,
effect_type);
@@ -736,7 +761,10 @@
**************************************************************************/
int get_city_bonus(const struct city *pcity, enum effect_type effect_type)
{
- assert(pcity != NULL);
+ if (!initialized) {
+ return 0;
+ }
+
return get_target_bonus_effects(NULL,
city_owner(pcity), pcity, B_LAST, NULL,
effect_type);
Index: common/effects.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/effects.h,v
retrieving revision 1.17
diff -u -r1.17 effects.h
--- common/effects.h 10 Apr 2005 00:50:37 -0000 1.17
+++ common/effects.h 10 Apr 2005 09:48:18 -0000
@@ -106,6 +106,20 @@
EFT_REGEN_REPUTATION,
EFT_GAIN_AI_LOVE,
EFT_SLOW_DOWN_TIMELINE,
+ EFT_CIVIL_WAR_CHANCE,
+ EFT_EMPIRE_SIZE_MOD,
+ EFT_EMPIRE_SIZE_STEP,
+ EFT_MAX_RATES,
+ EFT_MARTIAL_LAW_EACH,
+ EFT_MARTIAL_LAW_MAX,
+ EFT_RAPTURE_SIZE,
+ EFT_UNBRIBABLE_UNITS,
+ EFT_VETERAN_DIPLOMATS,
+ EFT_REVOLUTION_WHEN_UNHAPPY,
+ EFT_HAS_SENATE,
+ EFT_INSPIRE_PARTISANS,
+ EFT_HAPPINESS_TO_GOLD,
+ EFT_FANATICS, /* stupid special case, we hatess it */
EFT_LAST /* keep this last */
};
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.179
diff -u -r1.179 game.h
--- common/game.h 24 Mar 2005 16:41:41 -0000 1.179
+++ common/game.h 10 Apr 2005 09:48:18 -0000
@@ -178,17 +178,6 @@
Impr_Type_id palace_building;
Impr_Type_id land_defend_building;
- struct {
- int u_partisan; /* convenience: tech_req for first
- Partisan unit */
- /* Following tech list is A_LAST terminated if shorter than
- max len, and the techs listed are guaranteed to exist;
- this could be better implemented as a new field in the
- units.ruleset
- */
- int partisan_req[MAX_NUM_TECH_LIST]; /* all required for uprisings */
- } rtech;
-
/* values from game.ruleset */
struct {
int num_specialist_types;
Index: common/government.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.c,v
retrieving revision 1.51
diff -u -r1.51 government.c
--- common/government.c 3 Apr 2005 20:19:52 -0000 1.51
+++ common/government.c 10 Apr 2005 09:48:18 -0000
@@ -29,41 +29,6 @@
struct government *governments = NULL;
-static const char *flag_names[] = {
- "Build_Veteran_Diplomats", "Revolution_When_Unhappy", "Has_Senate",
- "Unbribable", "Inspires_Partisans", "Rapture_City_Growth",
- "Fanatic_Troops", "No_Unhappy_Citizens", "Convert_Tithes_To_Money",
- "Reduced_Research"
-};
-
-/***************************************************************
- Convert flag names to enum; case insensitive;
- returns G_LAST_FLAG if can't match.
-***************************************************************/
-enum government_flag_id government_flag_from_str(const char *s)
-{
- enum government_flag_id i;
-
- assert(ARRAY_SIZE(flag_names) == G_LAST_FLAG);
-
- for(i=G_FIRST_FLAG; i<G_LAST_FLAG; i++) {
- if (mystrcasecmp(flag_names[i], s)==0) {
- return i;
- }
- }
- return G_LAST_FLAG;
-}
-
-/****************************************************************************
- Returns TRUE iff the given government has the given flag.
-****************************************************************************/
-bool government_has_flag(const struct government *gov,
- enum government_flag_id flag)
-{
- assert(flag>=G_FIRST_FLAG && flag<G_LAST_FLAG);
- return TEST_BIT(gov->flags, flag);
-}
-
/****************************************************************************
Does a linear search of the governments to find the one that matches the
given (translated) name. Returns NULL if none match.
@@ -156,28 +121,6 @@
/***************************************************************
...
***************************************************************/
-int get_government_max_rate(int type)
-{
- if(type == G_MAGIC)
- return 100;
- if(type >= 0 && type < game.government_count)
- return governments[type].max_rate;
- return 50;
-}
-
-/***************************************************************
-Added for civil war probability computation - Kris Bubendorfer
-***************************************************************/
-int get_government_civil_war_prob(int type)
-{
- if(type >= 0 && type < game.government_count)
- return governments[type].civil_war;
- return 0;
-}
-
-/***************************************************************
-...
-***************************************************************/
const char *get_government_name(int type)
{
if(type >= 0 && type < game.government_count)
Index: common/government.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/government.h,v
retrieving revision 1.42
diff -u -r1.42 government.h
--- common/government.h 8 Apr 2005 06:32:27 -0000 1.42
+++ common/government.h 10 Apr 2005 09:48:18 -0000
@@ -18,28 +18,11 @@
#include "fc_types.h"
#include "requirements.h"
-#define G_MAGIC (127) /* magic constant, used as flag value */
+#define G_MAGIC (127) /* magic constant */
/* special values for free_* fields -- SKi */
#define G_CITY_SIZE_FREE G_MAGIC
-enum government_flag_id {
- G_BUILD_VETERAN_DIPLOMAT=0, /* and Spies (in general: all F_DIPLOMAT) */
- G_REVOLUTION_WHEN_UNHAPPY,
- G_HAS_SENATE, /* not implemented */
- 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
-
/* each government has a list of ruler titles, where at least
* one entry should have nation=DEFAULT_TITLE.
*/
@@ -73,22 +56,6 @@
struct ruler_title *ruler_titles;
int num_ruler_titles;
- int max_rate; /* max individual Tax/Lux/Sci rate */
- int civil_war; /* chance (from 100) of civil war in
- right conditions */
- int martial_law_max; /* maximum number of units which can
- enforce martial law */
- int martial_law_per; /* number of unhappy citizens made
- content by each enforcer unit */
- int empire_size_mod; /* (signed) offset to game.cityfactor to
- give city count when number of naturally
- content citizens is decreased */
- int empire_size_inc; /* if non-zero, reduce one content citizen for
- every empire_size_inc cities once #cities
- exceeds game.cityfactor + empire_size_mod */
- int rapture_size; /* minimum city size for rapture; if 255,
- rapture is (practically) impossible */
-
/* unit cost modifiers */
int unit_happy_cost_factor;
int unit_upkeep_factor[O_MAX];
@@ -117,10 +84,6 @@
int max_distance_cap;
} waste[O_MAX];
- /* other flags: bits in enum government_flag_id order,
- use government_has_flag() to access */
- int flags;
-
char *helptext;
};
@@ -133,12 +96,6 @@
struct government *find_government_by_name(const char *name);
struct government *find_government_by_name_orig(const char *name);
-enum government_flag_id government_flag_from_str(const char *s);
-bool government_has_flag(const struct government *gov,
- enum government_flag_id flag);
-
-int get_government_max_rate(int type);
-int get_government_civil_war_prob(int type);
const char *get_government_name(int type);
const char *get_ruler_title(int gov, bool male, int nation);
Index: common/packets.def
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.def,v
retrieving revision 1.103
diff -u -r1.103 packets.def
--- common/packets.def 28 Mar 2005 17:14:57 -0000 1.103
+++ common/packets.def 10 Apr 2005 09:48:18 -0000
@@ -1050,14 +1050,6 @@
UINT8 req_value[MAX_NUM_REQS];
BOOL req_survives[MAX_NUM_REQS];
- UINT8 max_rate;
- UINT8 civil_war;
- UINT8 martial_law_max;
- UINT8 martial_law_per;
- SINT8 empire_size_mod;
- UINT8 empire_size_inc;
- UINT8 rapture_size;
-
UINT8 unit_happy_cost_factor;
UINT8 unit_upkeep_factor[O_MAX];
@@ -1075,8 +1067,6 @@
UINT8 extra_waste_distance[O_MAX];
UINT8 waste_max_distance_cap[O_MAX];
- UINT16 flags;
-
UINT8 num_ruler_titles;
STRING name[MAX_LEN_NAME];
@@ -1221,7 +1211,6 @@
UINT8 num_unit_types;
UINT8 num_impr_types;
UINT8 num_tech_types;
- TECH_LIST rtech_partisan_req[MAX_NUM_TECH_LIST];
UINT8 government_when_anarchy;
UINT8 default_government;
UINT8 government_count;
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.170
diff -u -r1.170 player.c
--- common/player.c 18 Mar 2005 11:26:24 -0000 1.170
+++ common/player.c 10 Apr 2005 09:48:18 -0000
@@ -438,7 +438,10 @@
return;
}
- maxrate = get_government_max_rate(pplayer->government);
+ maxrate = get_player_bonus(pplayer, EFT_MAX_RATES);
+ if (maxrate == 0) {
+ maxrate = 100; /* effects not initialized yet */
+ }
surplus = 0;
if (pplayer->economic.luxury > maxrate) {
surplus += pplayer->economic.luxury - maxrate;
Index: common/unittype.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.c,v
retrieving revision 1.51
diff -u -r1.51 unittype.c
--- common/unittype.c 4 Apr 2005 21:45:48 -0000 1.51
+++ common/unittype.c 10 Apr 2005 09:48:18 -0000
@@ -85,11 +85,11 @@
/**************************************************************************
Returns the upkeep of a unit of this type under the given government.
**************************************************************************/
-int utype_upkeep_cost(const struct unit_type *ut,
+int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer,
const struct government *g, Output_type_id otype)
{
- if (government_has_flag(g, G_FANATIC_TROOPS) &&
- BV_ISSET(ut->flags, F_FANATIC)) {
+ if (get_player_bonus(pplayer, EFT_FANATICS)
+ && BV_ISSET(ut->flags, F_FANATIC)) {
/* Special case: fanatics have no upkeep under fanaticism. */
return 0;
}
@@ -411,10 +411,6 @@
&& unit_types[id].gov_requirement != p->government) {
return FALSE;
}
- if (unit_type_flag(id, F_FANATIC)
- && !government_has_flag(get_gov_pplayer(p), G_FANATIC_TROOPS)) {
- return FALSE;
- }
if (get_invention(p,unit_types[id].tech_requirement) != TECH_KNOWN) {
return FALSE;
}
Index: common/unittype.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/unittype.h,v
retrieving revision 1.43
diff -u -r1.43 unittype.h
--- common/unittype.h 4 Apr 2005 21:45:48 -0000 1.43
+++ common/unittype.h 10 Apr 2005 09:48:18 -0000
@@ -239,8 +239,8 @@
const char *get_unit_name(Unit_Type_id id);
const char *get_units_with_flag_string(int flag);
-int utype_upkeep_cost(const struct unit_type *ut,
- const struct government *gov, Output_type_id otype);
+int utype_upkeep_cost(const struct unit_type *ut, struct player *pplayer,
+ const struct government *g, Output_type_id otype);
int utype_happy_cost(const struct unit_type *ut, const struct government *g);
int can_upgrade_unittype(const struct player *pplayer, Unit_Type_id id);
Index: data/default/effects.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/effects.ruleset,v
retrieving revision 1.5
diff -u -r1.5 effects.ruleset
--- data/default/effects.ruleset 10 Apr 2005 00:50:37 -0000 1.5
+++ data/default/effects.ruleset 10 Apr 2005 09:48:18 -0000
@@ -16,6 +16,339 @@
; /* <-- avoid gettext warnings
; */ <-- avoid gettext warnings
+[effect_civil_war_0]
+name = "Civil_War_Chance"
+value = 90
+reqs =
+ { "type", "name", "range"
+ "Gov", "Anarchy", "Player"
+ }
+
+[effect_civil_war_1]
+name = "Civil_War_Chance"
+value = 80
+reqs =
+ { "type", "name", "range"
+ "Gov", "Despotism", "Player"
+ }
+
+[effect_civil_war_2]
+name = "Civil_War_Chance"
+value = 70
+reqs =
+ { "type", "name", "range"
+ "Gov", "Monarchy", "Player"
+ }
+
+[effect_civil_war_3]
+name = "Civil_War_Chance"
+value = 50
+reqs =
+ { "type", "name", "range"
+ "Gov", "Communism", "Player"
+ }
+
+[effect_civil_war_4]
+name = "Civil_War_Chance"
+value = 40
+reqs =
+ { "type", "name", "range"
+ "Gov", "Republic", "Player"
+ }
+
+[effect_civil_war_5]
+name = "Civil_War_Chance"
+value = 30
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_empire_size_mod_0]
+; base value
+name = "Empire_Size_Mod"
+value = -5
+reqs =
+ { "type", "name", "range"
+ "Gov", "Anarchy", "Player"
+ }
+
+[effect_empire_size_mod_0]
+name = "Empire_Size_Mod"
+value = -4
+reqs =
+ { "type", "name", "range"
+ "Gov", "Despotism", "Player"
+ }
+
+[effect_empire_size_mod_1]
+name = "Empire_Size_Mod"
+value = -3
+reqs =
+ { "type", "name", "range"
+ "Gov", "Monarchy", "Player"
+ }
+
+[effect_empire_size_mod_2]
+name = "Empire_Size_Mod"
+value = -2
+reqs =
+ { "type", "name", "range"
+ "Gov", "Communism", "Player"
+ }
+
+[effect_empire_size_mod_3]
+name = "Empire_Size_Mod"
+value = -1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Republic", "Player"
+ }
+
+[effect_empire_size_step_0]
+name = "Empire_Size_Step"
+value = 6
+reqs =
+ { "type", "name", "range"
+ "Gov", "Anarchy", "Player"
+ }
+
+[effect_empire_size_step_1]
+name = "Empire_Size_Step"
+value = 10
+reqs =
+ { "type", "name", "range"
+ "Gov", "Despotism", "Player"
+ }
+
+[effect_empire_size_step_2]
+name = "Empire_Size_Step"
+value = 12
+reqs =
+ { "type", "name", "range"
+ "Gov", "Monarchy", "Player"
+ }
+
+[effect_empire_size_step_3]
+name = "Empire_Size_Step"
+value = 14
+reqs =
+ { "type", "name", "range"
+ "Gov", "Republic", "Player"
+ }
+
+[effect_empire_size_step_4]
+name = "Empire_Size_Step"
+value = 16
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_max_rates_0]
+name = "Max_Rates"
+value = 100
+reqs =
+ { "type", "name", "range"
+ "Gov", "Anarchy", "Player"
+ }
+
+[effect_max_rates_1]
+name = "Max_Rates"
+value = 60
+reqs =
+ { "type", "name", "range"
+ "Gov", "Despotism", "Player"
+ }
+
+[effect_max_rates_2]
+name = "Max_Rates"
+value = 70
+reqs =
+ { "type", "name", "range"
+ "Gov", "Monarchy", "Player"
+ }
+
+[effect_max_rates_3]
+name = "Max_Rates"
+value = 80
+reqs =
+ { "type", "name", "range"
+ "Gov", "Communism", "Player"
+ }
+
+[effect_max_rates_4]
+name = "Max_Rates"
+value = 80
+reqs =
+ { "type", "name", "range"
+ "Gov", "Republic", "Player"
+ }
+
+[effect_max_rates_5]
+name = "Max_Rates"
+value = 100
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_martial_law_each_0]
+name = "Martial_Law_Each"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Anarchy", "Player"
+ }
+
+[effect_martial_law_each_1]
+name = "Martial_Law_Each"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Despotism", "Player"
+ }
+
+[effect_martial_law_each_2]
+name = "Martial_Law_Each"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Monarchy", "Player"
+ }
+
+[effect_martial_law_each_3]
+name = "Martial_Law_Each"
+value = 2
+reqs =
+ { "type", "name", "range"
+ "Gov", "Communism", "Player"
+ }
+
+[effect_martial_law_max_0]
+name = "Martial_Law_Max"
+value = 100
+reqs =
+ { "type", "name", "range"
+ "Gov", "Anarchy", "Player"
+ }
+
+[effect_martial_law_max_1]
+name = "Martial_Law_Max"
+value = 100
+reqs =
+ { "type", "name", "range"
+ "Gov", "Despotism", "Player"
+ }
+
+[effect_martial_law_max_2]
+name = "Martial_Law_Max"
+value = 3
+reqs =
+ { "type", "name", "range"
+ "Gov", "Monarchy", "Player"
+ }
+
+[effect_martial_law_max_3]
+name = "Martial_Law_Max"
+value = 3
+reqs =
+ { "type", "name", "range"
+ "Gov", "Communism", "Player"
+ }
+
+[effect_rapture_size_0]
+name = "Rapture_Size"
+value = 3
+reqs =
+ { "type", "name", "range"
+ "Gov", "Republic", "Player"
+ }
+
+[effect_rapture_size_1]
+name = "Rapture_Size"
+value = 3
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_democracy_0]
+name = "Unbribable_Units"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_democracy_1]
+name = "No_Incite"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_communism_0]
+name = "Veteran_Diplomats"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Communism", "Player"
+ }
+
+[effect_revolution_0]
+name = "Revolution_When_Unhappy"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Republic", "Player"
+ }
+
+[effect_revolution_1]
+name = "Revolution_When_Unhappy"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_senate_0]
+name = "Has_Senate"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Republic", "Player"
+ }
+
+[effect_senate_1]
+name = "Has_Senate"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ }
+
+[effect_partisan_0]
+name = "Inspire_Partisans"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Communism", "Player"
+ "Tech", "Communism", "Player"
+ "Tech", "Gunpowder", "Player"
+ }
+
+[effect_partisan_1]
+name = "Inspire_Partisans"
+value = 1
+reqs =
+ { "type", "name", "range"
+ "Gov", "Democracy", "Player"
+ "Tech", "Communism", "Player"
+ "Tech", "Gunpowder", "Player"
+ }
+
[effect_airport]
name = "Air_Veteran"
value = 1
Index: data/default/governments.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/governments.ruleset,v
retrieving revision 1.29
diff -u -r1.29 governments.ruleset
--- data/default/governments.ruleset 28 Mar 2005 17:14:58 -0000 1.29
+++ data/default/governments.ruleset 10 Apr 2005 09:48:18 -0000
@@ -37,26 +37,9 @@
; graphic_alt = alternate graphics tag if preferred is not found;
; should be a standard tag if preferred is not;
; otherwise may be "-"
-; flags = special effects; see government.c for strings
; ai_better = AI will not consider this government for use if the
; government listed here is available
-; martial_law_max = maximum number of units which can enforce martial law
-; in the city
-; martial_law_per = number of unhappy citizens made content by each
-; enforcer unit
-; max_single_rate = maximum which can be allocated to single one of
-; taxation/luxuries/science
-; empire_size_mod = signed modifier added to cityfactor to determine
-; empire size when base unhappiness is increased
-; empire_size_inc = if non-zero, reduce one content citizen for
-; every empire_size_inc cities once #cities
-; exceeds (cityfactor + empire_size_mod)
-; civil_war_chance = percentage change of civil war when capital is captured
-; (and player has enough cities etc)
-; rapture_size = a happy city will celebrate when its size is
-; this value or larger
-
; unit_*_factor = factor applied to individual unit upkeep for different
; upkeep forms
; unit_free_* = base unit upkeep cost which the city gets "free"; only
@@ -103,16 +86,6 @@
; No reqs
graphic = "gov.anarchy"
graphic_alt = "-"
-flags = "-"
-
-martial_law_max = 100 ; unlimited
-martial_law_per = 1
-max_single_rate = 100 ; rates are irrelevant under Anarchy; use 100
- ; to avoid unnecessary changes during revolution
-civil_war_chance = 90
-empire_size_mod = -5
-empire_size_inc = 6
-rapture_size = 3
unit_unhappy_factor = 0
unit_shield_factor = 1
@@ -164,17 +137,8 @@
; No reqs
graphic = "gov.despotism"
graphic_alt = "-"
-flags = "-"
ai_better = "Monarchy"
-martial_law_max = 100 ; unlimited
-martial_law_per = 1
-max_single_rate = 60
-civil_war_chance = 80
-empire_size_mod = -4
-empire_size_inc = 10
-rapture_size = 3
-
unit_unhappy_factor = 0
unit_shield_factor = 1
unit_food_factor = 1
@@ -225,17 +189,8 @@
}
graphic = "gov.monarchy"
graphic_alt = "-"
-flags = "-"
ai_better = "Communism"
-martial_law_max = 3
-martial_law_per = 1
-max_single_rate = 70
-civil_war_chance = 70
-empire_size_mod = -3
-empire_size_inc = 12
-rapture_size = 3
-
unit_unhappy_factor = 0
unit_shield_factor = 1
unit_food_factor = 1
@@ -286,15 +241,6 @@
}
graphic = "gov.communism"
graphic_alt = "-"
-flags = "Build_Veteran_Diplomats", "Inspires_Partisans"
-
-martial_law_max = 3
-martial_law_per = 2
-max_single_rate = 80
-civil_war_chance = 50
-empire_size_mod = -2
-empire_size_inc = 0
-rapture_size = 3
unit_unhappy_factor = 0
unit_shield_factor = 1
@@ -352,15 +298,6 @@
}
graphic = "gov.republic"
graphic_alt = "-"
-flags = "Has_Senate", "Rapture_City_Growth"
-
-martial_law_max = 0
-martial_law_per = 0
-max_single_rate = 80
-civil_war_chance = 40
-empire_size_mod = -1
-empire_size_inc = 14
-rapture_size = 3
unit_unhappy_factor = 1
unit_shield_factor = 1
@@ -415,16 +352,6 @@
}
graphic = "gov.democracy"
graphic_alt = "-"
-flags = "Has_Senate", "Revolution_When_Unhappy",
- "Inspires_Partisans", "Unbribable", "Rapture_City_Growth"
-
-martial_law_max = 0
-martial_law_per = 0
-max_single_rate = 100
-civil_war_chance = 30
-empire_size_mod = 0
-empire_size_inc = 16
-rapture_size = 3
unit_unhappy_factor = 2
unit_shield_factor = 1
Index: data/default/units.ruleset
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/default/units.ruleset,v
retrieving revision 1.67
diff -u -r1.67 units.ruleset
--- data/default/units.ruleset 4 Apr 2005 21:45:49 -0000 1.67
+++ data/default/units.ruleset 10 Apr 2005 09:48:19 -0000
@@ -1835,6 +1835,3 @@
advanced radar that can determine the location of enemy units over a \
wide area.\
")
-
-[u_specials]
-partisan_req = "Gunpowder","Communism"
Index: server/barbarian.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/barbarian.c,v
retrieving revision 1.85
diff -u -r1.85 barbarian.c
--- server/barbarian.c 29 Mar 2005 12:27:19 -0000 1.85
+++ server/barbarian.c 10 Apr 2005 09:48:19 -0000
@@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
+#include "effects.h"
#include "events.h"
#include "fcintl.h"
#include "game.h"
@@ -379,7 +380,7 @@
if ((int)myrand(UPRISE_CIV_MORE) >
(int)city_list_size(victim->cities) -
UPRISE_CIV_SIZE/(game.barbarianrate-1)
- || myrand(100) > get_gov_pcity(pc)->civil_war) {
+ || myrand(100) > get_player_bonus(victim, EFT_CIVIL_WAR_CHANCE)) {
return;
}
freelog(LOG_DEBUG, "Barbarians are willing to fight");
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.309
diff -u -r1.309 citytools.c
--- server/citytools.c 1 Apr 2005 00:42:27 -0000 1.309
+++ server/citytools.c 10 Apr 2005 09:48:20 -0000
@@ -472,11 +472,8 @@
}
if (unit_type_flag(id, F_DIPLOMAT)) {
- return (government_has_flag(get_gov_pcity(pcity),
- G_BUILD_VETERAN_DIPLOMAT) ? 1 : 0);
- }
-
- if (is_ground_unittype(id)) {
+ return (get_city_bonus(pcity, EFT_VETERAN_DIPLOMATS) ? 1 : 0);
+ } else if (is_ground_unittype(id)) {
return (get_city_bonus(pcity, EFT_LAND_VETERAN) > 0) ? 1 : 0;
} else {
if (is_sailing_unittype(id)) {
Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.300
diff -u -r1.300 cityturn.c
--- server/cityturn.c 18 Mar 2005 11:26:24 -0000 1.300
+++ server/cityturn.c 10 Apr 2005 09:48:20 -0000
@@ -867,7 +867,7 @@
if (pcity->surplus[O_SHIELD] < 0) {
unit_list_iterate_safe(pcity->units_supported, punit) {
- if (utype_upkeep_cost(unit_type(punit), g, O_SHIELD) > 0
+ if (utype_upkeep_cost(unit_type(punit), pplayer, g, O_SHIELD) > 0
&& pcity->surplus[O_SHIELD] < 0
&& !unit_flag(punit, F_UNDISBANDABLE)) {
notify_player_ex(pplayer, pcity->tile, E_UNIT_LOST,
@@ -885,7 +885,7 @@
* it! If we make it here all normal units are already disbanded, so only
* undisbandable ones remain. */
unit_list_iterate_safe(pcity->units_supported, punit) {
- int upkeep = utype_upkeep_cost(unit_type(punit), g, O_SHIELD);
+ int upkeep = utype_upkeep_cost(unit_type(punit), pplayer, g, O_SHIELD);
if (upkeep > 0 && pcity->surplus[O_SHIELD] < 0) {
assert(unit_flag(punit, F_UNDISBANDABLE));
@@ -1194,9 +1194,6 @@
struct city *capital;
int dist, size, cost;
- if (government_has_flag(get_gov_pcity(pcity), G_UNBRIBABLE)) {
- return INCITE_IMPOSSIBLE_COST;
- }
if (get_city_bonus(pcity, EFT_NO_INCITE) > 0) {
return INCITE_IMPOSSIBLE_COST;
}
@@ -1378,7 +1375,8 @@
check_pollution(pcity);
send_city_info(NULL, pcity);
- if (pcity->anarchy>2 && government_has_flag(g, G_REVOLUTION_WHEN_UNHAPPY))
{
+ if (pcity->anarchy>2
+ && get_player_bonus(pplayer, EFT_REVOLUTION_WHEN_UNHAPPY) > 0) {
notify_player_ex(pplayer, pcity->tile, E_ANARCHY,
_("The people have overthrown your %s, "
"your country is in turmoil."),
Index: server/diplomats.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplomats.c,v
retrieving revision 1.70
diff -u -r1.70 diplomats.c
--- server/diplomats.c 21 Mar 2005 12:21:28 -0000 1.70
+++ server/diplomats.c 10 Apr 2005 09:48:21 -0000
@@ -420,12 +420,10 @@
}
/* Check for unit from a bribable government. */
- if (government_has_flag(get_gov_pplayer(unit_owner(pvictim)),
- G_UNBRIBABLE)) {
+ if (get_player_bonus(uplayer, EFT_UNBRIBABLE_UNITS)) {
notify_player_ex(pplayer, pdiplomat->tile,
E_MY_DIPLOMAT_FAILED,
_("You can't bribe a unit from this nation."));
- freelog (LOG_DEBUG, "bribe-unit: unit's government is unbribable");
return;
}
@@ -743,14 +741,6 @@
freelog (LOG_DEBUG, "incite: unit: %d", pdiplomat->id);
- /* Check for city from a bribable government. */
- if (government_has_flag (get_gov_pcity (pcity), G_UNBRIBABLE)) {
- notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED,
- _("You can't subvert a city from this nation."));
- freelog (LOG_DEBUG, "incite: city's government is unbribable");
- return;
- }
-
/* See if the city is subvertable. */
if (get_city_bonus(pcity, EFT_NO_INCITE) > 0) {
notify_player_ex(pplayer, pcity->tile, E_MY_DIPLOMAT_FAILED,
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.363
diff -u -r1.363 plrhand.c
--- server/plrhand.c 28 Mar 2005 17:14:58 -0000 1.363
+++ server/plrhand.c 10 Apr 2005 09:48:21 -0000
@@ -765,7 +765,7 @@
|| science > 100) {
return;
}
- maxrate = get_government_max_rate (pplayer->government);
+ maxrate = get_player_bonus(pplayer, EFT_MAX_RATES);
if (tax > maxrate || luxury > maxrate || science > maxrate) {
const char *rtype;
@@ -868,7 +868,7 @@
if (!pplayer->ai.control) {
/* Keep luxuries if we have any. Try to max out science. -GJW */
- int max = get_government_max_rate(pplayer->government);
+ int max = get_player_bonus(pplayer, EFT_MAX_RATES);
pplayer->economic.science
= MIN(100 - pplayer->economic.luxury, max);
@@ -1084,7 +1084,7 @@
old_type = pplayer->diplstates[other_player_id].type;
pplayer2 = get_player(other_player_id);
- has_senate = government_has_flag(get_gov_pplayer(pplayer), G_HAS_SENATE);
+ has_senate = (get_player_bonus(pplayer, EFT_HAS_SENATE) > 0);
/* can't break a pact with yourself */
if (pplayer == pplayer2) {
@@ -2047,7 +2047,7 @@
/* Get base probabilities */
int dice = myrand(100); /* Throw the dice */
- int prob = get_government_civil_war_prob(pplayer->government);
+ int prob = get_player_bonus(pplayer, EFT_CIVIL_WAR_CHANCE);
/* Now compute the contribution of the cities. */
Index: server/ruleset.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v
retrieving revision 1.241
diff -u -r1.241 ruleset.c
--- server/ruleset.c 5 Apr 2005 20:40:47 -0000 1.241
+++ server/ruleset.c 10 Apr 2005 09:48:21 -0000
@@ -1121,9 +1121,6 @@
free(slist);
} unit_type_iterate_end;
- lookup_tech_list(file, "u_specials", "partisan_req",
- game.rtech.partisan_req, filename);
-
/* Some more consistency checking: */
unit_type_iterate(i) {
u = &unit_types[i];
@@ -1187,16 +1184,6 @@
exit(EXIT_FAILURE);
}
- /* pre-calculate game.rtech.u_partisan
- (tech for first partisan unit, or A_LAST */
- if (num_role_units(L_PARTISAN)==0) {
- game.rtech.u_partisan = A_LAST;
- } else {
- j = get_role_unit(L_PARTISAN, 0);
- j = game.rtech.u_partisan = get_unit_type(j)->tech_requirement;
- freelog(LOG_DEBUG, "partisan tech is %s", advances[j].name);
- }
-
update_simple_ai_types();
free(sec);
@@ -1654,8 +1641,8 @@
**************************************************************************/
static void load_ruleset_governments(struct section_file *file)
{
- int j, nval;
- char **sec, **slist;
+ int nval;
+ char **sec;
const char *filename = secfile_filename(file);
(void) check_ruleset_capabilities(file, "+1.9", filename);
@@ -1697,15 +1684,6 @@
sz_strlcpy(g->graphic_alt,
secfile_lookup_str(file, "%s.graphic_alt", sec[i]));
- g->martial_law_max = secfile_lookup_int(file, "%s.martial_law_max",
sec[i]);
- g->martial_law_per = secfile_lookup_int(file, "%s.martial_law_per",
sec[i]);
- g->max_rate = secfile_lookup_int(file, "%s.max_single_rate", sec[i]);
- g->civil_war = secfile_lookup_int(file, "%s.civil_war_chance", sec[i]);
- g->empire_size_mod = secfile_lookup_int(file, "%s.empire_size_mod",
sec[i]);
- g->empire_size_inc =
- secfile_lookup_int_default(file, 0, "%s.empire_size_inc", sec[i]);
- g->rapture_size = secfile_lookup_int(file, "%s.rapture_size", sec[i]);
-
g->free_happy
= lookup_city_cost(file, sec[i], "unit_free_unhappy", filename);
@@ -1765,26 +1743,6 @@
} government_iterate_end;
- /* flags: */
- government_iterate(g) {
- g->flags = 0;
- slist = secfile_lookup_str_vec(file, &nval, "%s.flags", sec[g->index]);
- for(j=0; j<nval; j++) {
- char *sval = slist[j];
- enum government_flag_id flag = government_flag_from_str(sval);
- if (strcmp(sval, "-") == 0) {
- continue;
- }
- if (flag == G_LAST_FLAG) {
- freelog(LOG_FATAL, "government %s has unknown flag %s", g->name, sval);
- exit(EXIT_FAILURE);
- } else {
- g->flags |= (1<<flag);
- }
- }
- free(slist);
- } government_iterate_end;
-
/* titles */
government_iterate(g) {
int i = g->index;
@@ -1821,10 +1779,6 @@
packet.notradesize = game.notradesize;
packet.fulltradesize = game.fulltradesize;
- for(i=0; i<MAX_NUM_TECH_LIST; i++) {
- packet.rtech_partisan_req[i] = game.rtech.partisan_req[i];
- }
-
packet.government_count = game.government_count;
packet.government_when_anarchy = game.government_when_anarchy;
packet.default_government = game.default_government;
@@ -2916,14 +2870,6 @@
&gov.req_survives[j], &gov.req_value[j]);
}
- gov.max_rate = g->max_rate;
- gov.civil_war = g->civil_war;
- gov.martial_law_max = g->martial_law_max;
- gov.martial_law_per = g->martial_law_per;
- gov.empire_size_mod = g->empire_size_mod;
- gov.empire_size_inc = g->empire_size_inc;
- gov.rapture_size = g->rapture_size;
-
gov.unit_happy_cost_factor = g->unit_happy_cost_factor;
gov.free_happy = g->free_happy;
@@ -2943,7 +2889,6 @@
gov.waste_max_distance_cap[o] = g->waste[o].max_distance_cap;
} output_type_iterate_end;
- gov.flags = g->flags;
gov.num_ruler_titles = g->num_ruler_titles;
sz_strlcpy(gov.name, g->name_orig);
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.223
diff -u -r1.223 settlers.c
--- server/settlers.c 21 Mar 2005 12:28:00 -0000 1.223
+++ server/settlers.c 10 Apr 2005 09:48:22 -0000
@@ -848,7 +848,7 @@
static int unit_food_upkeep(struct unit *punit)
{
struct player *pplayer = unit_owner(punit);
- int upkeep = utype_upkeep_cost(unit_type(punit),
+ int upkeep = utype_upkeep_cost(unit_type(punit), pplayer,
get_gov_pplayer(pplayer), O_FOOD);
if (punit->id != 0 && punit->homecity == 0)
upkeep = 0; /* thanks, Peter */
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.335
diff -u -r1.335 unittools.c
--- server/unittools.c 5 Apr 2005 20:36:10 -0000 1.335
+++ server/unittools.c 10 Apr 2005 09:48:22 -0000
@@ -1139,25 +1139,12 @@
**************************************************************************/
void make_partisans(struct city *pcity)
{
- struct player *pplayer;
- int i, partisans;
+ int partisans;
- if (num_role_units(L_PARTISAN)==0)
+ if (num_role_units(L_PARTISAN) <= 0
+ || pcity->original != pcity->owner
+ || get_city_bonus(pcity, EFT_INSPIRE_PARTISANS) <= 0) {
return;
- if (!tech_exists(game.rtech.u_partisan)
- || game.global_advances[game.rtech.u_partisan] == 0
- || pcity->original != pcity->owner)
- return;
-
- if (!government_has_flag(get_gov_pcity(pcity), G_INSPIRES_PARTISANS))
- return;
-
- pplayer = city_owner(pcity);
- for(i=0; i<MAX_NUM_TECH_LIST; i++) {
- int tech = game.rtech.partisan_req[i];
- if (tech == A_LAST) break;
- if (get_invention(pplayer, tech) != TECH_KNOWN) return;
- /* Was A_COMMUNISM and A_GUNPOWDER */
}
partisans = myrand(1 + pcity->size/2) + 1;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Freeciv-Dev] (PR#12757) Move some govt stuff to effects,
Per I. Mathisen <=
|
|