diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/government.c freeciv-struct_government+upkeep/common/government.c --- freeciv-orig/common/government.c Sat Jun 5 17:35:31 1999 +++ freeciv-struct_government+upkeep/common/government.c Sun Jun 6 13:19:01 1999 @@ -13,14 +13,17 @@ #include #include -#include "player.h" +#include #include +#include /* governemnts.ruleset, anyone? -- SKi */ +int required_techs_anarchy[] = { LAST_TECH }; struct ruler_title ruler_titles_anarchy[] = { { DEFAULT_TITLE, "Mr.", "Mrs." }, NULL_RULER_TITLE }; +int required_techs_despotism[] = { LAST_TECH }; struct ruler_title ruler_titles_despotism[] = { { DEFAULT_TITLE, "Emperor", "Empress" }, { R_ROMAN, "Dictator", "Dictator" }, @@ -29,6 +32,7 @@ /* { R_SIOUX, "Chief", "Chief" }, */ NULL_RULER_TITLE }; +int required_techs_monarchy[] = { A_MONARCHY, LAST_TECH }; struct ruler_title ruler_titles_monarchy[] = { { DEFAULT_TITLE, "King", "Queen" }, { R_ROMAN, "Imperator", "Imperatrix" }, @@ -41,12 +45,14 @@ /* { R_ARAB, "Sultan", "Sultan" }, */ NULL_RULER_TITLE }; +int required_techs_communism[] = { A_COMMUNISM, LAST_TECH }; struct ruler_title ruler_titles_communism[] = { { DEFAULT_TITLE, "Comrade", "Comrade" }, { R_CHINESE, "Chairman", "Chairperson" }, NULL_RULER_TITLE }; /* +int required_techs_fundamentalism[] = { A_FUNDAMENTALISM, LAST_TECH }; struct ruler_title ruler_titles_fundamentalism[] = { { DEFAULT_TITLE, "High Priest", "High Priestess" }, { R_GERMAN, "Archbishop", "Archbishop" }, @@ -61,11 +67,13 @@ NULL_RULER_TITLE }; */ +int required_techs_republic[] = { A_REPUBLIC, LAST_TECH }; struct ruler_title ruler_titles_republic[] = { { DEFAULT_TITLE, "Consul", "Consul" }, { R_AMERICAN, "Speaker", "Speaker" }, NULL_RULER_TITLE }; +int required_techs_democracy[] = { A_DEMOCRACY, LAST_TECH }; struct ruler_title ruler_titles_democracy[] = { { DEFAULT_TITLE, "President", "President" }, { R_GERMAN, "Chancellor", "Chancellor" }, @@ -79,6 +87,7 @@ { "Anarchy", ruler_titles_anarchy, 100, 90, + required_techs_anarchy, NO_UPKEEP, 0, 0, 0, 0, CITY_SIZE_FREE, 0, 0, ENTIRE_CITY, 0 @@ -86,6 +95,7 @@ { "Despotism", ruler_titles_despotism, 60, 80, + required_techs_despotism, NO_UPKEEP, 0, 0, 0, 0, CITY_SIZE_FREE, 0, 0, ENTIRE_CITY, 0 @@ -93,6 +103,7 @@ { "Monarchy", ruler_titles_monarchy, 70, 70, + required_techs_monarchy, NO_UPKEEP, 0, 1, 0, 0, 3, 0, 0, 3, 0 @@ -100,6 +111,7 @@ { "Communism", ruler_titles_communism, 80, 50, + required_techs_communism, NO_UPKEEP, 0, 1, 0, 0, 3, 0, 0, 0, 0 @@ -108,6 +120,7 @@ { "Fundamentalism", ruler_titles_fundamentalism, 60, 30, + required_techs_fundamentalism, NO_UPKEEP, 0, 0, 0, 0, 10, 0, 0, 0, 0 @@ -116,6 +129,7 @@ { "Republic", ruler_titles_republic, 80, 40, + required_techs_republic, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0 @@ -123,6 +137,7 @@ { "Democracy", ruler_titles_democracy, 100, 30, + required_techs_democracy, 1, 0, 1, 0, 0, 0, 0, 0, 0, UNBRIBABLE diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/government.h freeciv-struct_government+upkeep/common/government.h --- freeciv-orig/common/government.h Sat Jun 5 17:35:31 1999 +++ freeciv-struct_government+upkeep/common/government.h Sat Jun 5 16:59:17 1999 @@ -44,6 +44,9 @@ #define DEFAULT_TITLE -1 #define NULL_RULER_TITLE { 0, NULL, NULL } +/* Technology list terminator -- SKi */ +#define LAST_TECH -1 + struct ruler_title { int race; @@ -51,19 +54,27 @@ char* female_title; }; +/* This is struct government itself. All information about + * a form of government is contained inhere. + * -- SKi */ +/* TODO: + * o read this from a ruleset + * o let the AI in on this + */ struct government { /* government name */ char* name; /* ruler titles */ struct ruler_title *ruler_title; -/* char* male_ruler_title; - char* female_ruler_title; */ /* max rate that can go to one place -- SKi */ int max_rate; /* something to do with civil wars I suppose -- SKi */ int civil_war; + + /* list of techs required to use this government -- SKi */ + int *required_techs; /* cost modifiers -- SKi*/ int extra_happy_cost; diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/player.c freeciv-struct_government+upkeep/common/player.c --- freeciv-orig/common/player.c Sat Jun 5 17:35:31 1999 +++ freeciv-struct_government+upkeep/common/player.c Sun Jun 6 13:09:57 1999 @@ -225,37 +225,21 @@ /*************************************************************** ... ***************************************************************/ -int can_change_to_government(struct player *pplayer, enum government_type gov) +int can_change_to_government(struct player *pplayer, int government) { - if (gov>=G_LAST) - return 0; + int *t; - switch (gov) { - case G_ANARCHY: - case G_DESPOTISM: + /* ok if we have an appropriate wonder */ + if (player_owns_active_govchange_wonder(pplayer)) { return 1; - break; - case G_MONARCHY: - if (get_invention(pplayer, A_MONARCHY)==TECH_KNOWN) - return 1; - break; - case G_COMMUNISM: - if (get_invention(pplayer, A_COMMUNISM)==TECH_KNOWN) - return 1; - break; - case G_REPUBLIC: - if (get_invention(pplayer, A_REPUBLIC)==TECH_KNOWN) - return 1; - break; - case G_DEMOCRACY: - if (get_invention(pplayer, A_DEMOCRACY)==TECH_KNOWN) - return 1; - break; - default: - return 0; /* unknown govt type */ - break; } - return player_owns_active_govchange_wonder(pplayer); + /* not ok if we miss a required tech */ + for (t = governments[government].required_techs; *t != LAST_TECH; ++t) { + if (get_invention(pplayer, *t) != TECH_KNOWN) + return 0; + } + /* ok */ + return 1; } /*************************************************************** diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/player.h freeciv-struct_government+upkeep/common/player.h --- freeciv-orig/common/player.h Sat Jun 5 17:35:31 1999 +++ freeciv-struct_government+upkeep/common/player.h Sun Jun 6 12:42:50 1999 @@ -147,8 +147,7 @@ void player_set_unit_focus_status(struct player *pplayer); int player_has_embassy(struct player *pplayer, struct player *pplayer2); -int can_change_to_government(struct player *pplayer, - enum government_type); +int can_change_to_government(struct player *pplayer, int government); int get_government_max_rate(enum government_type type); int get_government_civil_war_prob(enum government_type type); char *get_government_name(enum government_type type);