diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/client/civclient.c freeciv-local/client/civclient.c --- freeciv-orig/client/civclient.c Sat Jun 5 17:21:19 1999 +++ freeciv-local/client/civclient.c Sun Jun 6 21:13:15 1999 @@ -67,6 +67,9 @@ void handle_ruleset_unit(struct packet_ruleset_unit *packet); void handle_ruleset_tech(struct packet_ruleset_tech *packet); void handle_ruleset_building(struct packet_ruleset_building *packet); +void handle_ruleset_government(struct packet_ruleset_government *packet); +void handle_ruleset_government_required_tech(struct packet_ruleset_government_required_tech *packet); +void handle_ruleset_government_ruler_title(struct packet_ruleset_government_ruler_title *packet); /************************************************************************** ... @@ -227,6 +230,18 @@ case PACKET_RULESET_BUILDING: handle_ruleset_building((struct packet_ruleset_building *)packet); + break; + + case PACKET_RULESET_GOVERNMENT: + handle_ruleset_government((struct packet_ruleset_government *)packet); + break; + + case PACKET_RULESET_GOVERNMENT_RULER_TITLE: + handle_ruleset_government_ruler_title((struct packet_ruleset_government_ruler_title *)packet); + break; + + case PACKET_RULESET_GOVERNMENT_REQUIRED_TECH: + handle_ruleset_government_required_tech((struct packet_ruleset_government_required_tech *)packet); break; case PACKET_INCITE_COST: diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/client/packhand.c freeciv-local/client/packhand.c --- freeciv-orig/client/packhand.c Sat Jun 5 17:35:33 1999 +++ freeciv-local/client/packhand.c Sun Jun 6 22:20:45 1999 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -1047,6 +1048,50 @@ b->obsolete_by = p->obsolete_by; b->variant = p->variant; +} + +/************************************************************************** +... +**************************************************************************/ +void handle_ruleset_government(struct packet_ruleset_government *p) +{ + struct government *gov; + + if (p->id >= government_count) { + government_count = p->id + 1; + governments = fc_realloc (governments, government_count * sizeof (struct government)); + } + gov = &governments[p->id]; + + gov->max_rate = p->max_rate; + gov->civil_war = p->civil_war; + gov->martial_law = p->martial_law; + gov->extra_happy_cost = p->extra_happy_cost; + gov->extra_shield_cost = p->extra_shield_cost; + gov->extra_food_cost = p->extra_food_cost; + gov->extra_gold_cost = p->extra_gold_cost; + gov->free_happy = p->free_happy; + gov->free_shield = p->free_shield; + gov->free_food = p->free_food; + gov->free_gold = p->free_gold; + + gov->name = strdup (p->name); + + gov->required_techs = fc_calloc (p->required_tech_count + 1, sizeof (int)); + gov->required_techs[p->required_tech_count] = LAST_TECH; + gov->ruler_title = fc_calloc (p->ruler_title_count + 1, sizeof (struct ruler_title)); +} +void handle_ruleset_government_required_tech(struct packet_ruleset_government_required_tech *p) +{ + struct government *gov = &governments[p->gov]; + gov->required_techs[p->id] = p->tech; +} +void handle_ruleset_government_ruler_title(struct packet_ruleset_government_ruler_title *p) +{ + struct government *gov = &governments[p->gov]; + gov->ruler_title[p->id].race = p->race; + gov->ruler_title[p->id].male_title = strdup (p->male_title); + gov->ruler_title[p->id].female_title = strdup (p->female_title); } diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/game.c freeciv-local/common/game.c --- freeciv-orig/common/game.c Sat Jun 5 17:21:20 1999 +++ freeciv-local/common/game.c Sun Jun 6 17:34:04 1999 @@ -290,6 +290,7 @@ game.randseed=GAME_DEFAULT_RANDSEED; strcpy(game.ruleset.techs, GAME_DEFAULT_RULESET); + strcpy(game.ruleset.governments, GAME_DEFAULT_RULESET); strcpy(game.ruleset.units, GAME_DEFAULT_RULESET); strcpy(game.ruleset.buildings, GAME_DEFAULT_RULESET); game.firepower_factor = 1; diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/game.h freeciv-local/common/game.h --- freeciv-orig/common/game.h Sat Jun 5 17:21:20 1999 +++ freeciv-local/common/game.h Sun Jun 6 17:34:24 1999 @@ -79,6 +79,7 @@ int spacerace; struct { char techs[MAX_LENGTH_NAME]; + char governments[MAX_LENGTH_NAME]; char units[MAX_LENGTH_NAME]; char buildings[MAX_LENGTH_NAME]; } ruleset; diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/government.c freeciv-local/common/government.c --- freeciv-orig/common/government.c Sun Jun 6 15:35:14 1999 +++ freeciv-local/common/government.c Sun Jun 6 21:58:52 1999 @@ -17,130 +17,20 @@ #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" }, - { R_EGYPTIAN, "Pharaoh", "Pharaoh" }, -/* { R_VIKINGS, "Warlord", "Warlord" }, */ -/* { 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" }, - { R_EGYPTIAN, "Great Pharaoh", "Great Pharaoh" }, - { R_INDIAN, "Maharaja", "Maharaja" }, - { R_RUSSIAN, "Czar", "Czarina" }, -/* { R_JAPANESE, "Shogun", "Shogun" }, */ -/* { R_PERSIAN, "Shah", "Shah" }, */ -/* { R_SIOUX, "Great Chief", "Great Chief" } */ -/* { 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" }, - { R_AMERICAN, "Reverend", "Reverend" }, - { R_RUSSIAN, "Patriarch", "Matriarch" }, - { R_FRENCH, "Archbishop", "Archbishop" }, - { R_ENGLISH, "Lord Protector", "Lady Protector" }, - { R_CELT, "Druid", "Druid" }, - { R_SPANISH, "Archbishop", "Archbishop" }, - { R_PERSIAN, "Ayatollah", "Ayatollah" }, - { R_ARAB, "Ayatollah", "Ayatollah" }, - 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" }, - { R_GREEK, "Prime Minister", "Prime Minister" }, - { R_FRENCH, "Premier", "Premier" }, - { R_ENGLISH, "Prime Minister", "Prime Minister" }, -/* { R_JAPANESE, "Prime Minister", "Prime Minister" }, */ - NULL_RULER_TITLE -}; -struct government governments[] = { - { - "Anarchy", ruler_titles_anarchy, - 100, 90, - required_techs_anarchy, - NO_UPKEEP, 0, 0, 0, - 0, CITY_SIZE_FREE, 0, 0, - ENTIRE_CITY, 0 - }, - { - "Despotism", ruler_titles_despotism, - 60, 80, - required_techs_despotism, - NO_UPKEEP, 0, 0, 0, - 0, CITY_SIZE_FREE, 0, 0, - ENTIRE_CITY, 0 - }, - { - "Monarchy", ruler_titles_monarchy, - 70, 70, - required_techs_monarchy, - NO_UPKEEP, 0, 1, 0, - 0, 3, 0, 0, - 3, 0 - }, - { - "Communism", ruler_titles_communism, - 80, 50, - required_techs_communism, - NO_UPKEEP, 0, 1, 0, - 0, 3, 0, 0, - 0, 0 - }, -/* - { - "Fundamentalism", ruler_titles_fundamentalism, - 60, 30, - required_techs_fundamentalism, - NO_UPKEEP, 0, 0, 0, - 0, 10, 0, 0, - 0, 0 - }, -*/ - { - "Republic", ruler_titles_republic, - 80, 40, - required_techs_republic, - 0, 0, 1, 0, - 1, 0, 0, 0, - 0, 0 - }, - { - "Democracy", ruler_titles_democracy, - 100, 30, - required_techs_democracy, - 1, 0, 1, 0, - 0, 0, 0, 0, - 0, UNBRIBABLE +int government_count; +struct government *governments; + + +struct government *find_government_by_name(char *name) +{ + int i; + + for (i = 0; i < government_count; ++i) { + if (strcmp (governments[i].name, name) == 0) { + return &governments[i]; + } } -}; + + return NULL; +} diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/government.h freeciv-local/common/government.h --- freeciv-orig/common/government.h Sun Jun 6 15:35:14 1999 +++ freeciv-local/common/government.h Sun Jun 6 22:18:25 1999 @@ -29,23 +29,27 @@ G_LAST }; +/* + * 42 is the magic constant here, it should be high enough that noone + * will be limited by it, right? -SKi + */ /* speical values for extra_* fields -- SKi */ -#define NO_UPKEEP (INT_MAX) +#define NO_UPKEEP (42) /* special values for free_* fields -- SKi */ -#define CITY_SIZE_FREE (INT_MAX-1) +#define CITY_SIZE_FREE (42) /* generic special values (for modifiers) -- SKi */ -#define ENTIRE_CITY (INT_MAX-1) -#define UNBRIBABLE (INT_MAX-1) +#define ENTIRE_CITY (42) +#define UNBRIBABLE (42) /* each government has a NULL-record terminated list of ruler titles, * at least one entry (the default) should be in it, the list is traversed * when a players title is needed. * -- SKi */ -#define DEFAULT_TITLE -1 +#define DEFAULT_TITLE (42) #define NULL_RULER_TITLE { 0, NULL, NULL } /* Technology list terminator -- SKi */ -#define LAST_TECH -1 +#define LAST_TECH (242) struct ruler_title { @@ -58,8 +62,8 @@ * a form of government is contained inhere. * -- SKi */ /* TODO: - * o read this from a ruleset * o let the AI in on this + * o different tech-list and title-list terminators? */ struct government { @@ -91,12 +95,17 @@ /* how many unhappy citizens can military units suppress? * (ENTRIE_CITY is possible here.) * -- SKi */ - int military_contentment_mod; + int martial_law; /* additional cost in bribing units (how should it be measured?) * (UNBRIBABLE is possible here.) * -- SKi */ int extra_bribe_cost; }; -extern struct government governments[]; + +int government_count; +extern struct government *governments; + + +struct government *find_government_by_name (char *name); #endif diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/packets.c freeciv-local/common/packets.c --- freeciv-orig/common/packets.c Sat Jun 5 17:35:33 1999 +++ freeciv-local/common/packets.c Sun Jun 6 21:39:05 1999 @@ -214,6 +214,12 @@ return recieve_packet_ruleset_unit(pc); case PACKET_RULESET_BUILDING: return recieve_packet_ruleset_building(pc); + case PACKET_RULESET_GOVERNMENT: + return receive_packet_ruleset_government(pc); + case PACKET_RULESET_GOVERNMENT_REQUIRED_TECH: + return receive_packet_ruleset_government_required_tech(pc); + case PACKET_RULESET_GOVERNMENT_RULER_TITLE: + return receive_packet_ruleset_government_ruler_title(pc); case PACKET_SPACESHIP_INFO: return recieve_packet_spaceship_info(pc); @@ -1732,6 +1738,141 @@ cptr=get_int8(cptr, &packet->obsolete_by); cptr=get_int8(cptr, &packet->variant); cptr=get_string(cptr, packet->name); + + remove_packet_from_buffer(&pc->buffer); + + return packet; +} + +/************************************************************************** +... +**************************************************************************/ +int send_packet_ruleset_government(struct connection *pc, + struct packet_ruleset_government *packet) +{ + unsigned char buffer[MAX_PACKET_SIZE], *cptr; + cptr=put_int8(buffer+2, PACKET_RULESET_GOVERNMENT); + + cptr=put_int8(cptr, packet->id); + cptr=put_int8(cptr, packet->max_rate); + cptr=put_int8(cptr, packet->civil_war); + cptr=put_int8(cptr, packet->martial_law); + cptr=put_int8(cptr, packet->extra_happy_cost); + cptr=put_int8(cptr, packet->extra_shield_cost); + cptr=put_int8(cptr, packet->extra_food_cost); + cptr=put_int8(cptr, packet->extra_gold_cost); + cptr=put_int8(cptr, packet->extra_bribe_cost); + cptr=put_int8(cptr, packet->free_happy); + cptr=put_int8(cptr, packet->free_shield); + cptr=put_int8(cptr, packet->free_food); + cptr=put_int8(cptr, packet->free_gold); + cptr=put_int8(cptr, packet->ruler_title_count); + cptr=put_int8(cptr, packet->required_tech_count); + + cptr=put_string(cptr, packet->name); + + put_int16(buffer, cptr-buffer); + return send_connection_data(pc, buffer, cptr-buffer); +} +int send_packet_ruleset_government_ruler_title(struct connection *pc, + struct packet_ruleset_government_ruler_title *packet) +{ + unsigned char buffer[MAX_PACKET_SIZE], *cptr; + cptr=put_int8(buffer+2, PACKET_RULESET_GOVERNMENT_RULER_TITLE); + + cptr=put_int8(cptr, packet->gov); + cptr=put_int8(cptr, packet->id); + cptr=put_int8(cptr, packet->race); + + cptr=put_string(cptr, packet->male_title); + cptr=put_string(cptr, packet->female_title); + + put_int16(buffer, cptr-buffer); + return send_connection_data(pc, buffer, cptr-buffer); +} +int send_packet_ruleset_government_required_tech(struct connection *pc, + struct packet_ruleset_government_required_tech *packet) +{ + unsigned char buffer[MAX_PACKET_SIZE], *cptr; + cptr=put_int8(buffer+2, PACKET_RULESET_GOVERNMENT_REQUIRED_TECH); + + cptr=put_int8(cptr, packet->gov); + cptr=put_int8(cptr, packet->id); + cptr=put_int8(cptr, packet->tech); + + put_int16(buffer, cptr-buffer); + return send_connection_data(pc, buffer, cptr-buffer); +} + +/************************************************************************** +... +**************************************************************************/ +struct packet_ruleset_government * +receive_packet_ruleset_government(struct connection *pc) +{ + unsigned char *cptr; + struct packet_ruleset_government *packet= + fc_malloc(sizeof(struct packet_ruleset_government)); + + cptr=get_int16(pc->buffer.data, NULL); + cptr=get_int8(cptr, NULL); + + cptr=get_int8(cptr, &packet->id); + cptr=get_int8(cptr, &packet->max_rate); + cptr=get_int8(cptr, &packet->civil_war); + cptr=get_int8(cptr, &packet->martial_law); + cptr=get_int8(cptr, &packet->extra_happy_cost); + cptr=get_int8(cptr, &packet->extra_shield_cost); + cptr=get_int8(cptr, &packet->extra_food_cost); + cptr=get_int8(cptr, &packet->extra_gold_cost); + cptr=get_int8(cptr, &packet->extra_bribe_cost); + cptr=get_int8(cptr, &packet->free_happy); + cptr=get_int8(cptr, &packet->free_shield); + cptr=get_int8(cptr, &packet->free_food); + cptr=get_int8(cptr, &packet->free_gold); + cptr=get_int8(cptr, &packet->ruler_title_count); + cptr=get_int8(cptr, &packet->required_tech_count); + + cptr=get_string(cptr, packet->name); + + remove_packet_from_buffer(&pc->buffer); + + return packet; +} +struct packet_ruleset_government_ruler_title * +receive_packet_ruleset_government_ruler_title(struct connection *pc) +{ + unsigned char *cptr; + struct packet_ruleset_government_ruler_title *packet= + fc_malloc(sizeof(struct packet_ruleset_government_ruler_title)); + + cptr=get_int16(pc->buffer.data, NULL); + cptr=get_int8(cptr, NULL); + + cptr=get_int8(cptr, &packet->gov); + cptr=get_int8(cptr, &packet->id); + cptr=get_int8(cptr, &packet->race); + + cptr=get_string(cptr, packet->male_title); + cptr=get_string(cptr, packet->female_title); + + remove_packet_from_buffer(&pc->buffer); + + return packet; +} +struct packet_ruleset_government_required_tech * +receive_packet_ruleset_government_required_tech(struct connection *pc) +{ + unsigned char *cptr; + struct packet_ruleset_government_required_tech *packet= + fc_malloc(sizeof(struct packet_ruleset_government_required_tech)); + + cptr=get_int16(pc->buffer.data, NULL); + cptr=get_int8(cptr, NULL); + + cptr=get_int8(cptr, &packet->gov); + cptr=get_int8(cptr, &packet->id); + cptr=get_int8(cptr, &packet->tech); remove_packet_from_buffer(&pc->buffer); diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/packets.h freeciv-local/common/packets.h --- freeciv-orig/common/packets.h Sat Jun 5 17:35:33 1999 +++ freeciv-local/common/packets.h Sun Jun 6 20:32:10 1999 @@ -84,6 +84,9 @@ PACKET_RULESET_TECH, PACKET_RULESET_UNIT, PACKET_RULESET_BUILDING, + PACKET_RULESET_GOVERNMENT, + PACKET_RULESET_GOVERNMENT_REQUIRED_TECH, + PACKET_RULESET_GOVERNMENT_RULER_TITLE, PACKET_CITY_OPTIONS, PACKET_SPACESHIP_INFO, PACKET_SPACESHIP_ACTION, @@ -457,6 +460,41 @@ int variant; }; +struct packet_ruleset_government { + int id; + int max_rate; + int civil_war; + int martial_law; + + int extra_happy_cost; + int extra_shield_cost; + int extra_food_cost; + int extra_gold_cost; + int extra_bribe_cost; + + int free_happy; + int free_shield; + int free_food; + int free_gold; + + int ruler_title_count; + int required_tech_count; + + char name[MAX_LENGTH_NAME]; +}; +struct packet_ruleset_government_ruler_title { + int gov; + int id; + int race; + char male_title[MAX_LENGTH_NAME]; + char female_title[MAX_LENGTH_NAME]; +}; +struct packet_ruleset_government_required_tech { + int gov; + int id; + int tech; +}; + /********************************************************* ... @@ -672,6 +710,19 @@ struct packet_ruleset_building *packet); struct packet_ruleset_building * recieve_packet_ruleset_building(struct connection *pc); + +int send_packet_ruleset_government(struct connection *pc, + struct packet_ruleset_government *packet); +struct packet_ruleset_government * +receive_packet_ruleset_government(struct connection *pc); +int send_packet_ruleset_government_ruler_title(struct connection *pc, + struct packet_ruleset_government_ruler_title *packet); +struct packet_ruleset_government_ruler_title * +receive_packet_ruleset_government_ruler_title(struct connection *pc); +int send_packet_ruleset_government_required_tech(struct connection *pc, + struct packet_ruleset_government_required_tech *packet); +struct packet_ruleset_government_required_tech * +receive_packet_ruleset_government_required_tech(struct connection *pc); int send_packet_before_end_year(struct connection *pc); diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/player.c freeciv-local/common/player.c --- freeciv-orig/common/player.c Sun Jun 6 15:35:14 1999 +++ freeciv-local/common/player.c Sun Jun 6 22:33:43 1999 @@ -151,6 +151,20 @@ /*************************************************************** ... ***************************************************************/ +enum race_type find_race_by_name(char *name) +{ + int i; + + for(i=0; irace == -1 && best_match == NULL) { + if (title->race == DEFAULT_TITLE && best_match == NULL) { best_match = title; } else if (title->race == race) { best_match = title; diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/player.h freeciv-local/common/player.h --- freeciv-orig/common/player.h Sun Jun 6 15:35:14 1999 +++ freeciv-local/common/player.h Sun Jun 6 18:06:18 1999 @@ -152,6 +152,7 @@ int get_government_civil_war_prob(enum government_type type); char *get_government_name(enum government_type type); char *get_ruler_title(enum government_type gov, int male, int race); +enum race_type find_race_by_name (char *name); char *get_race_name(enum race_type race); char *get_race_name_plural(enum race_type race); struct player_race *get_race(struct player *plr); diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/shared.h freeciv-local/common/shared.h --- freeciv-orig/common/shared.h Sat Jun 5 17:35:33 1999 +++ freeciv-local/common/shared.h Sun Jun 6 22:02:49 1999 @@ -73,7 +73,7 @@ */ /* The default string is really simple */ -#define CAPABILITY "+1.8 caravan1 nuke +unit_upkeep" +#define CAPABILITY "+1.8 caravan1 nuke +unit_upkeep +government" /* caravan1 means to server automatically established a traderoute when a caravan type unit moves into an enemy city. For older servers the client has to explicitly ask for a trade route. @@ -85,6 +85,8 @@ unit_upkeep means that unit costs are specified in units.ruleset, instead of being figured out from unit attributes. + + "government" is for governments.ruleset. */ #define CITY_NAMES_FONT "10x20" diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/data/civ1/governments.ruleset freeciv-local/data/civ1/governments.ruleset --- freeciv-orig/data/civ1/governments.ruleset Thu Jan 1 01:00:00 1970 +++ freeciv-local/data/civ1/governments.ruleset Sun Jun 6 22:39:54 1999 @@ -0,0 +1,90 @@ + +; Modifying this file: +; You shouldn't modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "set governments " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description="Civiliation I governments data for Freeciv" +options="1.8" + +[governments] +count=6 + +names = { "name" + "Anarchy" + "Despotism" + "Monarchy" + "Communism" + "Republic" + "Democracy" +}; + +; at present an empty list is required here, even for those government forms +; that always are available -SKi +required_techs = { "government", "techs" + "Anarchy" + "Despotism" + "Monarchy", "Monarchy" + "Communism", "Communism" + "Republic", "The Republic" + "Democracy", "Democracy" +}; + +; the numbers are wrapped in strings because secfile_lookup_* barf when trying +; to extract strings where there are numbers, and the other way too -SKi +unit_upkeep = { "government", "extra_happy", "extra_shield", "extra_food", "extra_gold" + "Anarchy", "NO_UPKEEP", "NO_UPKEEP", "NO_UPKEEP", "NO_UPKEEP" + "Despotism", "NO_UPKEEP", "0", "0", "0" + "Monarchy", "NO_UPKEEP", "0", "0", "0" + "Communism", "NO_UPKEEP", "0", "0", "0" + "Republic", "0", "0", "1", "0" + "Democracy", "1", "0", "1", "0" +}; +free_units = { "government", "free_happy", "free_shield", "free_food", "free_gold" + "Anarchy", "0", "0", "0", "0" + "Despotism", "0", "CITY_SIZE", "0", "0" + "Monarchy", "0", "3", "0", "0" + "Communism", "0", "0", "0", "0" + "Republic", "1", "0", "0", "0" + "Democracy", "0", "0", "0", "0" +}; + +others = { "government", "martial_law", "max_rates", "civil_war" + "Anarchy", 3, 60, 90 + "Despotism", 3, 60, 80 + "Monarchy", 3, 70, 70 + "Communism", 3, 80, 50 + "Republic", 0, 90, 40 + "Democracy", 0, 100, 30 +}; + +; "-" is the default title +ruler_titles = { "government", "race", "male_title", "female_title" + "Anarchy", "-", "Mr.", "Mrs." + "Despotism", "-", "Emperor", "Empress" + "Despotism", "Roman", "Dictator", "Dictator" + "Despotism", "Egyptian", "Pharaoh", "Pharaoh" + "Monarchy", "-", "King", "Queen" + "Monarchy", "Roman", "Imperator", "Imperatrix" + "Monarchy", "Egyptian", "Great Pharaoh", "Great Pharaoh" + "Monarchy", "Indian", "Maharaja", "Maharaja" + "Monarchy", "Russian", "Czar", "Czarina" + "Communism", "-", "Comrade", "Comrade" + "Communism", "Chinese", "Chairman", "Chairperson" + "Republic", "-", "Consul", "Consul" + "Republic", "American", "Speaker", "Speaker" + "Democracy", "-", "President", "President" + "Democracy", "German", "Chancellor", "Chancellor" + "Democracy", "Greek", "Prime Minister", "Prime Minister" + "Democracy", "French", "Premier", "Premier" + "Democracy", "English", "Prime Minister", "Prime Minister" +; "Democracy", "Japanese", "Prime Minister", "Prime Minister" +}; + diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/data/default/governments.ruleset freeciv-local/data/default/governments.ruleset --- freeciv-orig/data/default/governments.ruleset Thu Jan 1 01:00:00 1970 +++ freeciv-local/data/default/governments.ruleset Sun Jun 6 18:53:26 1999 @@ -0,0 +1,111 @@ + +; Modifying this file: +; You shouldn't modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "set governments " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description="Default governments data for Freeciv (as Civ2, minus fundamentalism)" +options="1.8" + +[governments] +count=6 + +names = { "name" + "Anarchy" + "Despotism" + "Monarchy" + "Communism" +; "Fundamentalism" + "Republic" + "Democracy" +}; + +; at present an empty list is required here, even for those government forms +; that always are available -SKi +required_techs = { "government", "techs" + "Anarchy" + "Despotism" + "Monarchy", "Monarchy" + "Communism", "Communism" +; "Fundamentalism", "Fundamentalism" + "Republic", "The Republic" + "Democracy", "Democracy" +}; + +; the numbers are wrapped in strings because secfile_lookup_* barf when trying +; to extract strings where there are numbers, and the other way too -SKi +unit_upkeep = { "government", "extra_happy", "extra_shield", "extra_food", "extra_gold" + "Anarchy", "NO_UPKEEP", "NO_UPKEEP", "NO_UPKEEP", "NO_UPKEEP" + "Despotism", "NO_UPKEEP", "0", "0", "0" + "Monarchy", "NO_UPKEEP", "0", "0", "0" + "Communism", "NO_UPKEEP", "0", "0", "0" +; "Fundamentalism", "NO_UPKEEP", "0", "0", "0" + "Republic", "0", "0", "1", "0" + "Democracy", "1", "0", "1", "0" +}; +free_units = { "government", "free_happy", "free_shield", "free_food", "free_gold" + "Anarchy", "0", "0", "0", "0" + "Despotism", "0", "CITY_SIZE", "0", "0" + "Monarchy", "0", "3", "0", "0" + "Communism", "0", "0", "0", "0" +; "Fundamentalism", "0", "10", "0", "0" + "Republic", "1", "0", "0", "0" + "Democracy", "0", "0", "0", "0" +}; + +others = { "government", "martial_law", "max_rates", "civil_war" + "Anarchy", 3, 60, 90 + "Despotism", 3, 60, 80 + "Monarchy", 3, 70, 70 + "Communism", 3, 80, 50 +; "Fundamentalism", 0, 80, 30 + "Republic", 0, 90, 40 + "Democracy", 0, 100, 30 +}; + +; "-" is the default title +ruler_titles = { "government", "race", "male_title", "female_title" + "Anarchy", "-", "Mr.", "Mrs." + "Despotism", "-", "Emperor", "Empress" + "Despotism", "Roman", "Dictator", "Dictator" + "Despotism", "Egyptian", "Pharaoh", "Pharaoh" +; "Despotism", "Vikings", "Warlord", "Warlord" +; "Despotism", "Sioux", "Chief", "Chief" + "Monarchy", "-", "King", "Queen" + "Monarchy", "Roman", "Imperator", "Imperatrix" + "Monarchy", "Egyptian", "Great Pharaoh", "Great Pharaoh" + "Monarchy", "Indian", "Maharaja", "Maharaja" + "Monarchy", "Russian", "Czar", "Czarina" +; "Monarchy", "Japanese", "Shogun", "Shogun" +; "Monarchy", "Persian", "Shah", "Shah" +; "Monarchy", "Sioux", "Great Chief", "Great Chief" +; "Monarchy", "Arab", "Sultan", "Sultan" + "Communism", "-", "Comrade", "Comrade" + "Communism", "Chinese", "Chairman", "Chairperson" +; "Fundamentalism", "-", "High Priest", "High Priestess" +; "Fundamentalism", "German", "Archbishop", "Archbishop" +; "Fundamentalism", "American", "Reverend", "Reverend" +; "Fundamentalism", "Russian", "Patriarch", "Matriarch" +; "Fundamentalism", "French", "Archbishop", "Archbishop" +; "Fundamentalism", "English", "Lord Protector", "Lady Protector" +; "Fundamentalism", "Celt", "Druid", "Druid" +; "Fundamentalism", "Spanish", "Archbishop", "Archbishop" +; "Fundamentalism", "Persian", "Ayatollah", "Ayatollah" +; "Fundamentalism", "Arab", "Ayatollah", "Ayatollah" + "Republic", "-", "Consul", "Consul" + "Republic", "American", "Speaker", "Speaker" + "Democracy", "-", "President", "President" + "Democracy", "German", "Chancellor", "Chancellor" + "Democracy", "Greek", "Prime Minister", "Prime Minister" + "Democracy", "French", "Premier", "Premier" + "Democracy", "English", "Prime Minister", "Prime Minister" +; "Democracy", "Japanese", "Prime Minister", "Prime Minister" +}; + diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/server/cityturn.c freeciv-local/server/cityturn.c --- freeciv-orig/server/cityturn.c Sat Jun 5 17:35:33 1999 +++ freeciv-local/server/cityturn.c Sun Jun 6 18:58:01 1999 @@ -426,7 +426,7 @@ { int gov = get_government(pcity->owner); - int content_mod = governments[gov].military_contentment_mod; + int content_mod = governments[gov].martial_law; int free_happy = governments[gov].free_happy; int free_shield = governments[gov].free_shield; diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/server/ruleset.c freeciv-local/server/ruleset.c --- freeciv-orig/server/ruleset.c Sat Jun 5 17:35:33 1999 +++ freeciv-local/server/ruleset.c Sun Jun 6 22:12:37 1999 @@ -15,6 +15,7 @@ #include #include +#include "mem.h" #include "game.h" #include "registry.h" #include "packets.h" @@ -37,10 +38,12 @@ char *description); static int match_name_from_list(char *name, char **list, int n_list); +static void load_ruleset_governments(char *ruleset_subdir); static void load_ruleset_techs(char *ruleset_subdir); static void load_ruleset_units(char *ruleset_subdir); static void load_ruleset_buildings(char *ruleset_subdir); +static void send_ruleset_governments(struct player *dest); static void send_ruleset_techs(struct player *dest); static void send_ruleset_units(struct player *dest); static void send_ruleset_buildings(struct player *dest); @@ -551,6 +554,178 @@ } /************************************************************************** +... +**************************************************************************/ +static void load_ruleset_governments(char *ruleset_subdir) +{ + struct section_file file; + char *filename, *datafile_options; + struct government *g; + int i, j; + char *c; + + filename = openload_ruleset_file(&file, ruleset_subdir, "governments"); + datafile_options = check_ruleset_capabilities(&file, "1.8", filename); + section_file_lookup(&file,"datafile.description"); /* unused */ + + government_count = secfile_lookup_int (&file, "governments.count"); + if (government_count == 0) { + freelog (LOG_FATAL, "no governments!"); + exit (1); + } + governments = fc_calloc (government_count, sizeof (struct government)); + + /* first fill in government names so find_government_by_name will work -SKi */ + for(i = 0; i < government_count; i++) { + g = &governments[i]; + + /* get government name */ + c = secfile_lookup_str (&file, "governments.names%d.name", i); + if (! c) { + freelog (LOG_FATAL, "government %d has no name!", i); + exit (1); + } + g->name = strdup (c); + } + + /* get list of required techs */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.required_techs%d.government", i)) != NULL) { + g = find_government_by_name(c); + + j = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.required_techs%d.techs,%d", i, j++)) != NULL) { + int tech_id; + + tech_id = find_tech_by_name (c); + if (tech_id == A_LAST) { + freelog (LOG_FATAL, "government type %s required non-existant tech %s", g->name, c); + exit (1); + } + g->required_techs = fc_realloc (g->required_techs, j * sizeof (int)); + g->required_techs[j-1] = tech_id; + } + g->required_techs = fc_realloc (g->required_techs, (j + 1) * sizeof (int)); + g->required_techs[j-1] = LAST_TECH; + + ++i; + } + + /* get extra_*_cost fields */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.unit_upkeep%d.government", i)) != NULL) { + g = find_government_by_name(c); + + c = secfile_lookup_str (&file, "governments.unit_upkeep%d.extra_happy", i); + if (strcmp (c, "NO_UPKEEP") == 0) { + g->extra_happy_cost = NO_UPKEEP; + } else { + g->extra_happy_cost = atoi (c); + } + c = secfile_lookup_str (&file, "governments.unit_upkeep%d.extra_shield", i); + if (strcmp (c, "NO_UPKEEP") == 0) { + g->extra_shield_cost = NO_UPKEEP; + } else { + g->extra_shield_cost = atoi (c); + } + c = secfile_lookup_str (&file, "governments.unit_upkeep%d.extra_food", i); + if (strcmp (c, "NO_UPKEEP") == 0) { + g->extra_food_cost = NO_UPKEEP; + } else { + g->extra_food_cost = atoi (c); + } + c = secfile_lookup_str (&file, "governments.unit_upkeep%d.extra_gold", i); + if (strcmp (c, "NO_UPKEEP") == 0) { + g->extra_gold_cost = NO_UPKEEP; + } else { + g->extra_gold_cost = atoi (c); + } + + ++i; + } + + /* get free_* fields */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.free_units%d.government", i)) != NULL) { + g = find_government_by_name(c); + + c = secfile_lookup_str (&file, "governments.free_units%d.free_happy", i); + if (strcmp (c, "CITY_SIZE") == 0) { + g->free_happy = CITY_SIZE_FREE; + } else { + g->free_happy = atoi (c); + } + c = secfile_lookup_str (&file, "governments.free_units%d.free_shield", i); + if (strcmp (c, "CITY_SIZE") == 0) { + g->free_shield = CITY_SIZE_FREE; + } else { + g->free_shield = atoi (c); + } + c = secfile_lookup_str (&file, "governments.free_units%d.free_food", i); + if (strcmp (c, "CITY_SIZE") == 0) { + g->free_food = CITY_SIZE_FREE; + } else { + g->free_food = atoi (c); + } + c = secfile_lookup_str (&file, "governments.free_units%d.free_gold", i); + if (strcmp (c, "CITY_SIZE") == 0) { + g->free_gold = CITY_SIZE_FREE; + } else { + g->free_gold = atoi (c); + } + + ++i; + } + + /* get other fields */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.others%d.government", i)) != NULL) { + g = find_government_by_name(c); + g->martial_law = secfile_lookup_int (&file, "governments.others%d.martial_law", i); + g->max_rate = secfile_lookup_int (&file, "governments.others%d.max_rates", i); + g->civil_war = secfile_lookup_int (&file, "governments.others%d.civil_war", i); + ++i; + } + + /* get ruler titles */ + for (i = 0; i < government_count; ++i) { + int titles = 0; + struct ruler_title t_last = NULL_RULER_TITLE; + g = &governments[i]; + + j = -1; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.ruler_titles%d.government", ++j)) != NULL) { + struct ruler_title t; + + if (find_government_by_name(c) != g) { + continue; + } + + /* t.race */ + c = secfile_lookup_str (&file, "governments.ruler_titles%d.race", j); + if (strcmp (c, "-") == 0) { + t.race = DEFAULT_TITLE; + } else if ((t.race = find_race_by_name (c)) == -1) { + freelog (LOG_FATAL, "government type %s has ruler title for non existing race %s", g->name, c); + exit (1); + } + /* t.male_title */ + t.male_title = strdup (secfile_lookup_str (&file, "governments.ruler_titles%d.male_title", j)); + /* t.female_title */ + t.female_title = strdup (secfile_lookup_str (&file, "governments.ruler_titles%d.female_title", j)); + + g->ruler_title = fc_realloc (g->ruler_title, ++titles * sizeof (struct ruler_title)); + g->ruler_title[titles-1] = t; + } + g->ruler_title = fc_realloc (g->ruler_title, (titles + 1) * sizeof (struct ruler_title)); + g->ruler_title[titles] = t_last; + } + + section_file_check_unused(&file, filename); + section_file_free(&file); +} + +/************************************************************************** ... **************************************************************************/ void send_ruleset_units(struct player *dest) @@ -643,10 +818,84 @@ /************************************************************************** ... **************************************************************************/ +static void send_ruleset_governments(struct player *dest) +{ + struct packet_ruleset_government gov; + struct packet_ruleset_government_ruler_title title; + struct packet_ruleset_government_required_tech tech; + struct government *g; + int i, j, to; + int *p_i; + struct ruler_title *p_title; + + for (i = 0; i < government_count; ++i) { + g = &governments[i]; + + /* send one packet_government */ + gov.id = i; + gov.max_rate = g->max_rate; + gov.civil_war = g->civil_war; + gov.martial_law = g->martial_law; + gov.extra_happy_cost = g->extra_happy_cost; + gov.extra_shield_cost = g->extra_shield_cost; + gov.extra_food_cost = g->extra_food_cost; + gov.extra_gold_cost = g->extra_gold_cost; + gov.free_happy = g->free_happy; + gov.free_shield = g->free_shield; + gov.free_food = g->free_food; + gov.free_gold = g->free_gold; + + for (p_title = g->ruler_title, j = 0; p_title->male_title != NULL; ++p_title, ++j); + gov.ruler_title_count = j; + for (p_i = g->required_techs, j = 0; *p_i != LAST_TECH; ++p_i, ++j); + gov.required_tech_count = j; + + strcpy (gov.name, g->name); + + for(to=0; toconn, &gov); + } + } + + /* send one packet_government_ruler_title per ruler title */ + for (p_title = g->ruler_title, j = 0; p_title->male_title != NULL; ++p_title, ++j) { + title.gov = i; + title.id = j; + title.race = p_title->race; + strcpy (title.male_title, p_title->male_title); + strcpy (title.female_title, p_title->female_title); + + for(to=0; toconn, &title); + } + } + } + + /* send one packet_government_required_tech per required tech */ + for (p_i = g->required_techs, j = 0; *p_i != LAST_TECH; ++p_i, ++j) { + tech.gov = i; + tech.id = j; + tech.tech = *p_i; + + for(to=0; toconn, &tech); + } + } + } + } +} + +/************************************************************************** +... +**************************************************************************/ void load_rulesets(void) { freelog(LOG_NORMAL, "Loading rulesets"); load_ruleset_techs(game.ruleset.techs); + load_ruleset_governments(game.ruleset.governments); load_ruleset_units(game.ruleset.units); load_ruleset_buildings(game.ruleset.buildings); } @@ -665,6 +914,7 @@ } send_ruleset_techs(dest); + send_ruleset_governments(dest); send_ruleset_units(dest); send_ruleset_buildings(dest);