diff --exclude-from=../.diff_ignore -Nur freeciv-orig/ai/advdomestic.c freeciv-local/ai/advdomestic.c --- freeciv-orig/ai/advdomestic.c Sat Jun 5 17:21:15 1999 +++ freeciv-local/ai/advdomestic.c Sat Jul 3 11:36:02 1999 @@ -26,6 +26,7 @@ #include #include #include +#include "government.h" /********************************************************************** ... this function should assign a value to choice and want and type, where @@ -175,7 +176,8 @@ void ai_eval_buildings(struct city *pcity) { - int i, gov, val, a, t, food, j, k, hunger, bar, grana; + struct government *g = &governments[ get_government(pcity->owner) ]; + int i, val, a, t, food, j, k, hunger, bar, grana; int tax, prod, sci, values[B_LAST]; int est_food = pcity->food_surplus + 2 * pcity->ppl_scientist + 2 * pcity->ppl_taxman; struct player *pplayer = city_owner(pcity); @@ -209,8 +211,6 @@ if (i > 0 && !pcity->ppl_scientist && !pcity->ppl_taxman) hunger = i + 1; else hunger = 1; - gov = get_government(pcity->owner); - for (i=0;icorruption * t)>>1; - if (gov == G_DEMOCRACY) values[B_COLOSSEUM] += building_value(1, pcity, val); + /* Could someone elaborate one what COLOSSEUM does here? -- SKi */ + if (g->corruption_level == 0) { + values[B_COLOSSEUM] += building_value (1, pcity, val); + } else { + values[B_COURTHOUSE] = (pcity->corruption * t) >> 1; + } } if (could_build_improvement(pcity, B_FACTORY)) @@ -477,6 +481,7 @@ void domestic_advisor_choose_build(struct player *pplayer, struct city *pcity, struct ai_choice *choice) { + struct government *g = &governments[ pplayer->government ]; int set, con, i, want, iunit; struct ai_choice cur; int est_food = pcity->food_surplus + 2 * pcity->ppl_scientist + 2 * pcity->ppl_taxman; @@ -489,7 +494,7 @@ set = city_get_settlers(pcity); con = map_get_continent(pcity->x, pcity->y); - if (est_food > (get_government(pcity->owner) >= G_REPUBLIC ? 2 : 1)) { + if (est_food > (1 /*settler.food_cost*/ + g->extra_food_cost)) { /* allowing multiple settlers per city now. I think this is correct. -- Syela */ /* settlers are an option */ /* settler_want calculated in settlers.c, called from ai_manage_city */ diff --exclude-from=../.diff_ignore -Nur freeciv-orig/ai/aicity.c freeciv-local/ai/aicity.c --- freeciv-orig/ai/aicity.c Sat Jun 5 17:21:15 1999 +++ freeciv-local/ai/aicity.c Sat Jul 3 13:50:16 1999 @@ -95,11 +95,12 @@ void ai_manage_buildings(struct player *pplayer) { /* we have just managed all our cities but not chosen build for them yet */ + struct government *g = &governments[ pplayer->government ]; int i, j, values[B_LAST], leon = 0, palace = 0, corr = 0; memset(values, 0, sizeof(values)); memset(pplayer->ai.tech_want, 0, sizeof(pplayer->ai.tech_want)); - if (find_palace(pplayer) || pplayer->government == G_DEMOCRACY) palace = 1; + if (find_palace(pplayer) || g->corruption_level == 0) palace = 1; city_list_iterate(pplayer->cities, pcity) ai_eval_buildings(pcity); if (!palace) corr += pcity->corruption * 8; @@ -119,13 +120,11 @@ values[B_MAGELLAN] /= (MORT * improvement_value(B_MAGELLAN)); /* this is a weird place to put tech advice */ - if (pplayer->government > G_DESPOTISM) { - for (i = 0; i < B_LAST; i++) { - j = improvement_types[i].tech_requirement; - if (get_invention(pplayer, j) != TECH_KNOWN) - pplayer->ai.tech_want[j] += values[i]; - } - } /* tired of researching pottery when we need to learn Republic!! -- Syela */ + for (i = 0; i < B_LAST; i++) { + j = improvement_types[i].tech_requirement; + if (get_invention(pplayer, j) != TECH_KNOWN) + pplayer->ai.tech_want[j] += values[i]; + } /* was A_PHILOSOPHY: */ if (!game.global_advances[game.rtech.get_bonus_tech]) @@ -762,6 +761,7 @@ int ai_find_elvis_pos(struct city *pcity, int *xp, int *yp) { + struct government *g = &governments[ city_owner(pcity)->government ]; int x,y, foodneed, prodneed, gov; int luxneed, pwr, e; @@ -781,8 +781,11 @@ if (is_military_unit(punit)) prodneed++; unit_list_iterate_end; gov = get_government(pcity->owner); - if (gov == G_DESPOTISM) prodneed -= pcity->size; - if (gov == G_MONARCHY || gov == G_COMMUNISM) prodneed -= 3; + if (g->free_shield == CITY_SIZE_FREE) { + prodneed -= pcity->size; + } else { + prodneed -= g->free_shield; + } *xp = 0; *yp = 0; diff --exclude-from=../.diff_ignore -Nur freeciv-orig/ai/aihand.c freeciv-local/ai/aihand.c --- freeciv-orig/ai/aihand.c Sat Jun 5 17:21:15 1999 +++ freeciv-local/ai/aihand.c Sat Jul 3 14:52:21 1999 @@ -33,6 +33,7 @@ #include #include #include +#include "government.h" /**************************************************************************** A man builds a city @@ -220,6 +221,7 @@ void ai_manage_taxes(struct player *pplayer) { /* total rewrite by Syela */ + struct government *g = &governments[ pplayer->government ]; int gnow = pplayer->economic.gold; int sad = 0, trade = 0, m, n, i, expense = 0, tot; int waste[40]; /* waste with N elvises */ @@ -264,7 +266,9 @@ /* this code must be ABOVE the elvises[] if SIMPLISTIC is off */ if(0) freelog(LOG_DEBUG, "Does %s want to be bigger? %d", pcity->name, wants_to_be_bigger(pcity)); - if (pcity->size > 4 && pplayer->government >= G_REPUBLIC && + /* FIXME: correct? -- SKi */ +/* OLD: if (pcity->size > 4 && pplayer->government >= G_REPUBLIC && */ + if (g->rapture_size && pcity->size > g->rapture_size && pcity->food_surplus > 0 && !pcity->ppl_unhappy[4] && wants_to_be_bigger(pcity) && ai_fuzzy(pplayer,1)) { @@ -440,43 +444,56 @@ change the government form, if it can and there is a good reason **************************************************************************/ +#define DEBUG_AMG_CHANGED (0) +#define DEBUG_AMG_BOOST (0) +#define DEBUG_AMG_CHANGED (0) void ai_manage_government(struct player *pplayer) { - int government = get_race(pplayer)->goals.government; - government = G_REPUBLIC; /* need to be REPUBLIC+ to love */ -/* advantages of DEMOCRACY: partisans, no bribes, no corrup, +1 content if courthouse */ -/* disadvantages of DEMOCRACY: doubled unhappiness from attacking units, anarchy */ -/* realistically we should allow DEMOC in some circumstances but not yet -- Syela */ - if (pplayer->government == government) - return; - if (can_change_to_government(pplayer, government)) { - ai_government_change(pplayer, government); - return; - } - switch (government) { - case G_COMMUNISM: - if (can_change_to_government(pplayer, G_MONARCHY)) - ai_government_change(pplayer, G_MONARCHY); - break; - case G_DEMOCRACY: - if (can_change_to_government(pplayer, G_REPUBLIC)) - ai_government_change(pplayer, G_REPUBLIC); - else if (can_change_to_government(pplayer, G_MONARCHY)) - ai_government_change(pplayer, G_MONARCHY); - break; - case G_REPUBLIC: - if (can_change_to_government(pplayer, G_MONARCHY)) - ai_government_change(pplayer, G_MONARCHY); /* better than despotism! -- Syela */ - break; + static int prev_rating[10][10]; /* these are for debugging only */ + static int prev_choice[10]; /* -- SKi*/ + int best_government = pplayer->government, + best_rating = ai_evaluate_government (pplayer, &governments[ pplayer->government ]); + int i; + + for (i=0; igovernment) + rating += 2500; + + if (DEBUG_AMG_CHANGED && prev_rating[pplayer->player_no][i] != rating && (rating > 0 || rating > prev_rating[pplayer->player_no][i])) + freelog (LOG_DEBUG, "%d: ai_manage_government: %s: %s: %d (%+d)", game.year, pplayer->name, g->name, rating, rating - prev_rating[pplayer->player_no][i]); + prev_rating[pplayer->player_no][i] = rating; + /* compare this government with the best so far */ + if (rating > best_rating || best_government == -1) { + if (can_change_to_government(pplayer, i)) { + /* Use this thing! -- SKi */ + best_government = i; + best_rating = rating; + } else { + if (get_invention(pplayer, g->required_tech) != TECH_KNOWN && rating > 0) { + /* Research this thing! -- SKi */ + if (DEBUG_AMG_BOOST) + freelog (LOG_DEBUG, "%d: ai_manage_government: boosting %s for %s (%d -> %d)", + game.year, + advances[ g->required_tech ].name, pplayer->name, + pplayer->ai.tech_want[ g->required_tech ], + pplayer->ai.tech_want[ g->required_tech ] + rating / 100); + pplayer->ai.tech_want[ g->required_tech ] += rating / 100; /* need constant modifier? */ + } + } + } } + if (DEBUG_AMG_CHANGED && prev_choice[pplayer->player_no] != best_government) + freelog (LOG_DEBUG, "%d: %s chooses new government: %s", game.year, pplayer->name, governments[best_government].name); + prev_choice[pplayer->player_no] = best_government; - if( pplayer->government == G_ANARCHY ){ - /* if the ai ever intends to stay anarchy, */ - /* change condition to if( (pplayer->revolution==0) && */ - if( ((pplayer->revolution<=0) || (pplayer->revolution>5)) && - can_change_to_government(pplayer, G_DESPOTISM) - ) - { ai_government_change(pplayer, G_DESPOTISM); } - }/* if ANARCHY */ + if (pplayer->government != best_government) { + ai_government_change(pplayer, best_government); + } + return; } diff --exclude-from=../.diff_ignore -Nur freeciv-orig/ai/aitech.c freeciv-local/ai/aitech.c --- freeciv-orig/ai/aitech.c Sat Jun 5 17:21:15 1999 +++ freeciv-local/ai/aitech.c Sat Jul 3 13:59:48 1999 @@ -37,33 +37,21 @@ **************************************************************************/ int get_government_tech(struct player *plr) { - int government = get_race(plr)->goals.government; - if (can_change_to_government(plr, government)) - return 0; - switch (government) { - case G_MONARCHY: - return A_MONARCHY; - break; - - case G_COMMUNISM: - if (get_invention(plr, A_MONARCHY) == TECH_KNOWN) - return A_COMMUNISM; - else - return A_MONARCHY; - break; + int i, rating; + int best_government = -1, best_rating = 0; - case G_REPUBLIC: - return A_REPUBLIC; - break; - - case G_DEMOCRACY: - if (get_invention(plr, A_REPUBLIC) == TECH_KNOWN) - return A_DEMOCRACY; - else - return A_REPUBLIC; - break; + for (i = 0; i < game.government_count; ++i) { + struct government *g = &governments[ i ]; + rating = ai_evaluate_government (plr, g); + if (rating > best_rating && + get_invention (plr, g->required_tech) != TECH_KNOWN) { + best_rating = rating; + best_government = i; + } } - return 0; /* to make compiler happy */ + if (best_government == -1) + return 0; + return governments[ best_government ].required_tech; } int get_wonder_tech(struct player *plr) diff --exclude-from=../.diff_ignore -Nur freeciv-orig/ai/aitools.c freeciv-local/ai/aitools.c --- freeciv-orig/ai/aitools.c Sat Jun 5 17:21:15 1999 +++ freeciv-local/ai/aitools.c Sat Jul 3 13:56:29 1999 @@ -33,6 +33,8 @@ #include #include +#include "government.h" + struct city *dist_nearest_city(struct player *pplayer, int x, int y) { /* dist_nearest_enemy_* are no longer ever used. This is dist_nearest_enemy_city, respaced so I can read it and therefore @@ -66,7 +68,7 @@ return; preq.government=gov; pplayer->revolution=0; - pplayer->government=G_ANARCHY; + pplayer->government=game.government_when_anarchy; handle_player_government(pplayer, &preq); pplayer->revolution = -1; /* yes, I really mean this. -- Syela */ } @@ -164,48 +166,203 @@ **********************************************************************/ int ai_assess_military_unhappiness(struct city *pcity, int gov) { - int unhap=0; - int have_police; - int variant; - - if (gov < G_REPUBLIC) + struct government *g = &governments[ gov ]; + int free_happy = g->free_happy; + + int unhap = 0; + + /* bail out now if extra_happy_cost == NO_UPKEEP -- SKi */ + if (g->extra_happy_cost == NO_UPKEEP) { return 0; - - have_police = city_got_effect(pcity, B_POLICE); - variant = improvement_variant(B_WOMENS); - - if (gov == G_REPUBLIC) { - if (have_police && variant==1 ) - return 0; - - unit_list_iterate(pcity->units_supported, punit) { - if (unit_being_aggressive(punit) || is_field_unit(punit)) { - unhap++; + } + + /* handle special values of free_* -- SKi */ + if (free_happy == CITY_SIZE_FREE) { + free_happy = pcity->size; + } + + /* loop over local units -- SKi */ + unit_list_iterate(pcity->units_supported, this_unit) { + struct unit_type *ut = &unit_types[this_unit->type]; + int happy_cost = ut->happy_cost + g->extra_happy_cost; + + if (is_field_unit (this_unit)) { + happy_cost = 1; + } else if (unit_being_aggressive (this_unit) && (happy_cost > 0)) { + /* effects of police station and womens sufferage (sp?) -- SKi */ + if (improvement_variant (B_WOMENS) || city_got_effect (pcity, B_POLICE)) { + --happy_cost; } + } else { + continue; } - unit_list_iterate_end; - if (have_police) unhap--; - } - else if (gov == G_DEMOCRACY) { - unit_list_iterate(pcity->units_supported, punit) { - if (have_police && variant==1) { - if (unit_being_aggressive(punit)) { - unhap++; - } + + if (happy_cost > 0) { + if (free_happy) { + --free_happy; } else { - if (unit_being_aggressive(punit)) { - unhap += 2; - } else if (is_field_unit(punit)) { - unhap += 1; - } + unhap += happy_cost; } } - unit_list_iterate_end; - if (have_police && variant==0) { - unhap -= 2; - } } - if (unhap < 0) unhap = 0; - + unit_list_iterate_end; + return unhap; } + +/********************************************************************** + Evaluate a government form, still pretty sketchy. +**********************************************************************/ +/* this evaluation should be more dynamic (based on players current + * needs, like expansion, at war, etc, etc) -- SKi */ + +#define DEBUG_AEG_EMPIRE (0) +#define DEBUG_AEG_CORRUPTION (0) +#define DEBUG_AEG_EXTRA_FOOD (0) +#define DEBUG_AEG_EXTRA_SHIELD (0) +#define DEBUG_AEG_EXTRA_HAPPY (0) +#define DEBUG_AEG_BONUS_TRADE (0) +#define DEBUG_AEG_PENALTY (0) +#define DEBUG_AEG_FREE (0) +int ai_evaluate_government (struct player *pplayer, struct government *g) +{ + static struct player *p_last_player; + static int last_year; + + struct city *capital = find_palace(pplayer); + int rating = 25000, rating_before; + int avg_city_size = 0; + int empire_size = 0; + int aggressive_units = 0; + int free_aggressive_units = 0; + int upkept_units = 0; + int free_upkept_units = 0; + int eating_units = 0; + int free_eating_units = 0; + int trade_fields = 0; + int total_distance = 0; + + city_list_iterate (pplayer->cities, this_city) { + int free_happy = g->free_happy == CITY_SIZE_FREE ? this_city->size : g->free_happy; + int free_shield = g->free_shield == CITY_SIZE_FREE ? this_city->size : g->free_shield; + int free_food = g->free_food == CITY_SIZE_FREE ? this_city->size : g->free_food; + + ++empire_size; + avg_city_size += this_city->size; + trade_fields += this_city->tile_trade; + + total_distance += g->extra_corruption_distance; + if (g->fixed_corruption_distance) { + total_distance += g->fixed_corruption_distance; + } else if (capital) { + total_distance += min(36, map_distance(capital->x, capital->y, this_city->x, this_city->y)); + } else { + total_distance += 36; + } + + unit_list_iterate (this_city->units_supported, this_unit) { + struct unit_type *ut = &unit_types[ this_unit->type ]; + if (unit_being_aggressive (this_unit)) { + if (free_happy) { + --free_happy; + ++free_aggressive_units; + } + ++aggressive_units; + } + if (ut->shield_cost) { + if (free_shield) { + --free_shield; + ++free_upkept_units; + } + ++upkept_units; + } + if (ut->food_cost) { + if (free_food) { + --free_food; + ++free_eating_units; + } + ++eating_units; + } + } unit_list_iterate_end; + } city_list_iterate_end; + if (empire_size) + avg_city_size /= empire_size; + else + avg_city_size = 0; + + if (DEBUG_AEG_EMPIRE && (p_last_player != pplayer || last_year != game.year)) { + freelog (LOG_DEBUG, "%s:\tEmpire of %s (%d): s=%d,c=%d,a=%d,u=%d,e=%d,t=%d", + g->name, pplayer->name, game.year, + empire_size, avg_city_size, aggressive_units, upkept_units, eating_units, + trade_fields + ); + } + + /* + * Government flags, these were intentionally left out of the evaluation: + * IS_NICE - Has no impact on rules. + * FAVORS_GROWTH - Ditto. + * -- SKi + */ + rating_before = rating; + if (g->flags & BUILD_VETERAN_DIPLOMAT) { + rating += 100; /* ignore this advantage for now -- SKi */ + } + if (g->flags & REVOLUTION_WHEN_UNHAPPY) { + rating -= 50000; /* very bad! */ + } + if (g->flags & HAS_SENATE) { + rating -= 300; /* undesirable */ + } + if (g->flags & UNBRIBABLE) { + rating += 100; /* nice */ + } + if (g->flags & INSPIRES_PARTISANS) { + rating += 100; /* nice */ + } + + /* punish governments for their extra upkeep costs */ + rating_before = rating; + if (g->extra_happy_cost != NO_UPKEEP) + rating -= g->extra_happy_cost * 150 * aggressive_units; + if (DEBUG_AEG_EXTRA_HAPPY && rating != rating_before) freelog (LOG_DEBUG, "extra_happy_cost changed rating for %s by %d", g->name, rating - rating_before); + rating_before = rating; + if (g->extra_shield_cost != NO_UPKEEP) + rating -= g->extra_shield_cost * 150 * upkept_units; + if (DEBUG_AEG_EXTRA_SHIELD && rating != rating_before) freelog (LOG_DEBUG, "extra_shield_cost changed rating for %s by %d", g->name, rating - rating_before); + rating_before = rating; + if (g->extra_food_cost != NO_UPKEEP) + rating -= g->extra_food_cost * 150 * eating_units; + if (DEBUG_AEG_EXTRA_FOOD && rating != rating_before) freelog (LOG_DEBUG, "extra_food_cost changed rating for %s by %d", g->name, rating - rating_before); + + /* reward governments that give us some upkeep for free */ + rating_before= rating; + rating += free_upkept_units * 250; + if (DEBUG_AEG_FREE && rating != rating_before) freelog (LOG_DEBUG, "free upkeep changed rating for %s by %d", g->name, rating - rating_before); + + /* Punish governments for their production penalties. */ + rating_before = rating; + if (g->trade_before_penalty) + rating -= max(g->trade_before_penalty - 2, 2) * 400; + /* trade bonuses */ + rating_before = rating; + if (g->trade_bonus) + rating += g->trade_bonus * 350 * trade_fields; + if (DEBUG_AEG_BONUS_TRADE && rating != rating_before) freelog (LOG_DEBUG, "trade bonus changed rating for %s by %d", g->name, rating - rating_before); + /* corruption level */ + rating_before = rating; + rating += (100 - g->corruption_level) * 50; + rating -= g->corruption_level * max(0, 100 - g->corruption_modifier) * trade_fields / 45; + rating -= total_distance * g->corruption_distance_factor * trade_fields / 3; + if (DEBUG_AEG_CORRUPTION) freelog(LOG_DEBUG, "corruption changed rating for %s by %d", g->name, rating - rating_before); + /* empire_size_factor */ + rating_before = rating; + if (g->empire_size_factor > empire_size) + rating += 500; + + p_last_player = pplayer; + last_year = game.year; + + return rating; +} + diff --exclude-from=../.diff_ignore -Nur freeciv-orig/ai/aitools.h freeciv-local/ai/aitools.h --- freeciv-orig/ai/aitools.h Sat Jun 5 17:21:15 1999 +++ freeciv-local/ai/aitools.h Sat Jul 3 13:56:07 1999 @@ -36,5 +36,6 @@ void ai_advisor_choose_building(struct city *pcity, struct ai_choice *choice); int ai_assess_military_unhappiness(struct city *pcity, int gov); +int ai_evaluate_government(struct player *pplayer, struct government *g); #endif diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/civclient.c freeciv-local/client/civclient.c --- freeciv-orig/client/civclient.c Sat Jun 12 10:46:23 1999 +++ freeciv-local/client/civclient.c Mon Jun 7 23:55:36 1999 @@ -67,6 +67,8 @@ 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_ruler_title(struct packet_ruleset_government_ruler_title *packet); /************************************************************************** ... @@ -229,6 +231,14 @@ 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_INCITE_COST: handle_incite_cost((struct packet_generic_values *)packet); break; diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-gtk/dialogs.c freeciv-local/client/gui-gtk/dialogs.c --- freeciv-orig/client/gui-gtk/dialogs.c Sat Jun 5 17:21:18 1999 +++ freeciv-local/client/gui-gtk/dialogs.c Sat Jul 3 14:53:27 1999 @@ -39,6 +39,8 @@ extern int ai_popup_windows; extern GdkGC *fill_bg_gc; +/******************************************************************/ +gint popup_mes_del_callback(GtkWidget *widget, GdkEvent *event, gpointer data); /******************************************************************/ GtkWidget *races_dialog_shell=NULL; @@ -1086,43 +1088,53 @@ *****************************************************************/ void popup_government_dialog(void) { - if(!is_showing_government_dialog) { - GtkWidget *shl, *button; + int i; + GtkWidget *dshell, *button, *dlabel, *vbox; + if(!is_showing_government_dialog) { is_showing_government_dialog=1; - shl=popup_message_dialog(toplevel, /*"governmentdialog"*/"Choose Your New Government", - "Select government type:", - "Despotism", government_callback, G_DESPOTISM, - "Monarchy", government_callback, G_MONARCHY, - "Communism", government_callback, G_COMMUNISM, - "Republic", government_callback, G_REPUBLIC, - "Democracy", government_callback, G_DEMOCRACY, 0); - if(!can_change_to_government(game.player_ptr, G_DESPOTISM)) - { - button = gtk_object_get_data( GTK_OBJECT( shl ), "button0" ); - gtk_widget_set_sensitive( button, FALSE ); - } - if(!can_change_to_government(game.player_ptr, G_MONARCHY)) - { - button = gtk_object_get_data( GTK_OBJECT( shl ), "button1" ); - gtk_widget_set_sensitive( button, FALSE ); - } - if(!can_change_to_government(game.player_ptr, G_COMMUNISM)) - { - button = gtk_object_get_data( GTK_OBJECT( shl ), "button2" ); - gtk_widget_set_sensitive( button, FALSE ); - } - if(!can_change_to_government(game.player_ptr, G_REPUBLIC)) - { - button = gtk_object_get_data( GTK_OBJECT( shl ), "button3" ); - gtk_widget_set_sensitive( button, FALSE ); - } - if(!can_change_to_government(game.player_ptr, G_DEMOCRACY)) - { - button = gtk_object_get_data( GTK_OBJECT( shl ), "button4" ); - gtk_widget_set_sensitive( button, FALSE ); + gtk_widget_set_sensitive(toplevel, FALSE); + + dshell=gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_position (GTK_WINDOW(dshell), GTK_WIN_POS_MOUSE); + + gtk_signal_connect( + GTK_OBJECT(dshell), + "delete_event", + GTK_SIGNAL_FUNC(popup_mes_del_callback), + (gpointer) toplevel + ); + + gtk_window_set_title(GTK_WINDOW(dshell), "Choose Your New Government"); + + vbox = gtk_vbox_new(0,TRUE); + gtk_container_add(GTK_CONTAINER(dshell),vbox); + + gtk_container_border_width(GTK_CONTAINER(vbox),5); + + dlabel = gtk_label_new("Select government type:"); + gtk_box_pack_start(GTK_BOX(vbox), dlabel, TRUE, FALSE, 0); + + gtk_object_set_data(GTK_OBJECT(vbox), "parent",(gpointer) toplevel); + + for (i=0; iname); + gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, FALSE, 0); + gtk_signal_connect( + GTK_OBJECT(button), + "clicked", + GTK_SIGNAL_FUNC(government_callback), + (gpointer) g->index + ); + if(!can_change_to_government(game.player_ptr, i)) + gtk_widget_set_sensitive(button, FALSE); } + + gtk_widget_show_all( vbox ); + gtk_widget_show(dshell); } } diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-gtk/diplodlg.c freeciv-local/client/gui-gtk/diplodlg.c --- freeciv-orig/client/gui-gtk/diplodlg.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/client/gui-gtk/diplodlg.c Fri Jun 4 20:15:24 1999 @@ -390,10 +390,10 @@ sprintf(buf, "This Eternal Treaty\nmarks the results of the diplomatic work between\nThe %s %s %s\nand\nThe %s %s %s", get_race_name(plr0->race), - get_ruler_title(plr0->government), + get_ruler_title(plr0->government, plr0->is_male, plr0->race), plr0->name, get_race_name(plr1->race), - get_ruler_title(plr1->government), + get_ruler_title(plr1->government, plr1->is_male, plr1->race), plr1->name); pdialog->dip_labelm=gtk_label_new(buf); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-gtk/inteldlg.c freeciv-local/client/gui-gtk/inteldlg.c --- freeciv-orig/client/gui-gtk/inteldlg.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/client/gui-gtk/inteldlg.c Fri Jun 4 20:16:48 1999 @@ -89,7 +89,7 @@ gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, FALSE, 2); sprintf(buf, "Ruler: %s %s", - get_ruler_title(p->government), p->name); + get_ruler_title(p->government, p->is_male, p->race), p->name); label=gtk_label_new(buf); gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, FALSE, 5); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-gtk/mapview.c freeciv-local/client/gui-gtk/mapview.c --- freeciv-orig/client/gui-gtk/mapview.c Sat Jun 5 17:35:33 1999 +++ freeciv-local/client/gui-gtk/mapview.c Sun Jun 20 13:11:42 1999 @@ -1119,6 +1119,10 @@ NORMAL_TILE_HEIGHT, NORMAL_TILE_HEIGHT+SMALL_TILE_HEIGHT); /* draw overlay pixmaps */ + /* FIXME: + * For now only two food, one shield and two masks can be drawn per unit, + * the proper way to do this is probably something like what Civ II does. + * (One food/shield/mask drawn N times, possibly one top of it self. -- SKi */ if (punit->upkeep_food > 0) put_overlay_tile_gpixmap (p, 0, 1, CITY_FOOD_TILES + (punit->upkeep_food > 1 ? 1 : 0)); if (punit->upkeep > 0) diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-gtk/repodlgs.c freeciv-local/client/gui-gtk/repodlgs.c --- freeciv-orig/client/gui-gtk/repodlgs.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/client/gui-gtk/repodlgs.c Fri Jun 4 20:17:42 1999 @@ -131,7 +131,7 @@ report_name, get_government_name(game.player_ptr->government), get_race_name_plural(game.player_ptr->race), - get_ruler_title(game.player_ptr->government), + get_ruler_title(game.player_ptr->government, game.player_ptr->is_male, game.player_ptr->race), game.player_ptr->name, textyear(game.year)); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-xaw/dialogs.c freeciv-local/client/gui-xaw/dialogs.c --- freeciv-orig/client/gui-xaw/dialogs.c Sat Jun 5 17:21:19 1999 +++ freeciv-local/client/gui-xaw/dialogs.c Sat Jul 3 11:42:38 1999 @@ -1122,31 +1122,34 @@ /**************************************************************** ... *****************************************************************/ + void popup_government_dialog(void) { + int i, button; + if(!is_showing_government_dialog) { Widget shl; is_showing_government_dialog=1; + /* FIXME: It's pretty obvious what need fixing here :) -- SKi */ shl=popup_message_dialog(toplevel, "governmentdialog", "Select government type:", - government_callback, G_DESPOTISM, - government_callback, G_MONARCHY, - government_callback, G_COMMUNISM, - government_callback, G_REPUBLIC, - government_callback, G_DEMOCRACY, 0); - - if(!can_change_to_government(game.player_ptr, G_DESPOTISM)) - XtSetSensitive(XtNameToWidget(shl, "*button0"), FALSE); - if(!can_change_to_government(game.player_ptr, G_MONARCHY)) - XtSetSensitive(XtNameToWidget(shl, "*button1"), FALSE); - if(!can_change_to_government(game.player_ptr, G_COMMUNISM)) - XtSetSensitive(XtNameToWidget(shl, "*button2"), FALSE); - if(!can_change_to_government(game.player_ptr, G_REPUBLIC)) - XtSetSensitive(XtNameToWidget(shl, "*button3"), FALSE); - if(!can_change_to_government(game.player_ptr, G_DEMOCRACY)) - XtSetSensitive(XtNameToWidget(shl, "*button4"), FALSE); + government_callback, /*G_DESPOTISM*/ 1, + government_callback, /*G_MONARCHY*/ 2, + government_callback, /*G_COMMUNISM*/ 3, + government_callback, /*G_REPUBLIC*/ 4, + government_callback, /*G_DEMOCRACY*/ 5, 0); + + button = 0; + for (i=0; i < game.government_count; ++i) { + if (i == game.government_when_anarchy) continue; + if (! can_change_to_government(game.player_ptr, i)) { + char name[10]; /* long enough? -- SKi */ + sprintf (name, "*button%d", button++); + XtSetSensitive(XtNameToWidget(shl, name), FALSE); + } + } } } diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-xaw/diplodlg.c freeciv-local/client/gui-xaw/diplodlg.c --- freeciv-orig/client/gui-xaw/diplodlg.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/client/gui-xaw/diplodlg.c Sat Jun 5 11:26:47 1999 @@ -439,10 +439,10 @@ sprintf(buf, "This Eternal Treaty\nmarks the results of the diplomatic work between\nThe %s %s %s\nand\nThe %s %s %s", get_race_name(plr0->race), - get_ruler_title(plr0->government), + get_ruler_title(plr0->government, plr0->is_male, plr0->race), plr0->name, get_race_name(plr1->race), - get_ruler_title(plr1->government), + get_ruler_title(plr1->government, plr0->is_male, plr0->race), plr1->name); pheadlinem=create_centered_string(buf); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-xaw/inteldlg.c freeciv-local/client/gui-xaw/inteldlg.c --- freeciv-orig/client/gui-xaw/inteldlg.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/client/gui-xaw/inteldlg.c Sat Jun 5 11:27:33 1999 @@ -93,7 +93,7 @@ NULL); sprintf(buf, "Ruler: %s %s", - get_ruler_title(p->government), p->name); + get_ruler_title(p->government, p->is_male, p->race), p->name); XtVaCreateManagedWidget("intelnamelabel", labelWidgetClass, form, diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/gui-xaw/repodlgs.c freeciv-local/client/gui-xaw/repodlgs.c --- freeciv-orig/client/gui-xaw/repodlgs.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/client/gui-xaw/repodlgs.c Sat Jun 5 11:29:13 1999 @@ -145,7 +145,7 @@ report_name, get_government_name(game.player_ptr->government), get_race_name_plural(game.player_ptr->race), - get_ruler_title(game.player_ptr->government), + get_ruler_title(game.player_ptr->government, game.player_ptr->is_male, game.player_ptr->race), game.player_ptr->name, textyear(game.year)); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/client/packhand.c freeciv-local/client/packhand.c --- freeciv-orig/client/packhand.c Sat Jun 12 10:46:23 1999 +++ freeciv-local/client/packhand.c Sat Jul 3 11:56:34 1999 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include @@ -41,6 +42,7 @@ #include #include #include +#include "government.h" extern int seconds_to_turndone; extern int turn_gold_difference; @@ -626,6 +628,9 @@ game.rtech.cathedral_minus = pinfo->rtech.cathedral_minus; game.rtech.colosseum_plus = pinfo->rtech.colosseum_plus; + game.government_when_anarchy = pinfo->government_when_anarchy; + game.default_government = pinfo->default_government; + boot_help = (get_client_state() == CLIENT_GAME_RUNNING_STATE && game.spacerace != pinfo->spacerace); game.spacerace=pinfo->spacerace; @@ -706,7 +711,7 @@ if(pplayer==game.player_ptr && (pplayer->revolution < 1 || pplayer->revolution > 5) && - pplayer->government==G_ANARCHY && + pplayer->government==game.government_when_anarchy && (!game.player_ptr->ai.control || ai_popup_windows)) popup_government_dialog(); @@ -737,13 +742,14 @@ **************************************************************************/ int spaceship_autoplace(struct player *pplayer, struct player_spaceship *ship) { + struct government *g = &governments[ pplayer->government ]; struct packet_spaceship_action packet; int i; if (ship->modules > (ship->habitation + ship->life_support + ship->solar_panels)) { - int nice = (pplayer->government >= G_REPUBLIC); + int nice = g->flags & IS_NICE; /* "nice" governments prefer to keep success 100%; * others build habitation first (for score?) (Thanks Massimo.) */ @@ -1047,6 +1053,67 @@ 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 >= game.government_count) { + game.government_count = p->id + 1; + governments = fc_realloc (governments, game.government_count * sizeof (struct government)); + } + + gov = &governments[p->id]; + + gov->index = p->id; + + gov->required_tech = p->required_tech; + gov->max_rate = p->max_rate; + gov->civil_war = p->civil_war; + gov->martial_law = p->martial_law; + gov->empire_size_factor = p->empire_size_factor; + gov->rapture_size = p->rapture_size; + + 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->trade_before_penalty = p->trade_before_penalty; + gov->shields_before_penalty = p->shields_before_penalty; + gov->food_before_penalty = p->food_before_penalty; + + gov->trade_bonus = p->trade_bonus; + gov->shield_bonus = p->shield_bonus; + gov->food_bonus = p->food_bonus; + + gov->corruption_level = p->corruption_level; + gov->corruption_modifier = p->corruption_modifier; + gov->fixed_corruption_distance = p->fixed_corruption_distance; + gov->corruption_distance_factor = p->corruption_distance_factor; + gov->extra_corruption_distance = p->extra_corruption_distance; + + gov->flags = p->flags; + + gov->name = strdup (p->name); + + gov->ruler_title = fc_calloc (p->ruler_title_count + 1, sizeof (struct ruler_title)); +} +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 --exclude-from=../.diff_ignore -Nur freeciv-orig/common/Makefile.am freeciv-local/common/Makefile.am --- freeciv-orig/common/Makefile.am Sat Jun 12 10:47:07 1999 +++ freeciv-local/common/Makefile.am Wed Jun 2 23:51:14 1999 @@ -38,4 +38,6 @@ tech.c \ tech.h \ unit.c \ - unit.h + unit.h \ + government.c \ + governemnt.h diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/city.c freeciv-local/common/city.c --- freeciv-orig/common/city.c Sat Jun 5 17:21:20 1999 +++ freeciv-local/common/city.c Thu Jun 10 21:19:32 1999 @@ -959,10 +959,8 @@ int s=0; enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2); enum tile_terrain_type tile_t=map_get_terrain(pcity->x+x-2, pcity->y+y-2); + struct government *g = &governments[ get_government(pcity->owner) ]; - int gov=get_government(pcity->owner); - if (city_celebrating(pcity)) - gov+=2; if (spec_t & S_SPECIAL) s=get_tile_type(tile_t)->shield_special; else @@ -982,7 +980,10 @@ s++; if (city_got_building(pcity, B_OFFSHORE) && tile_t==T_OCEAN) s++; - if (s>2 && gov <=G_DESPOTISM) + /* government shield bonus & penalty -- SKi */ + if (s) + s += g->shield_bonus; + if (g->shields_before_penalty && s > g->shields_before_penalty) s--; if (spec_t & S_POLLUTION) return s=(s+1)/2; /* The shields here is icky */ return s; @@ -996,10 +997,8 @@ { enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2); enum tile_terrain_type tile_t=map_get_terrain(pcity->x+x-2, pcity->y+y-2); + struct government *g = &governments[ get_government(pcity->owner) ]; int t; - int gov=get_government(pcity->owner); - if (city_celebrating(pcity)) - gov+=2; if (spec_t & S_SPECIAL) t=get_tile_type(tile_t)->trade_special; @@ -1020,18 +1019,18 @@ if (spec_t & S_RAILROAD) t+=(t*game.rail_trade)/100; - /* Civ1 specifically documents that Railroad trade increase is before - * Democracy/Republic bonus -AJS */ - - if (gov >=G_REPUBLIC) - t++; + /* Civ1 specifically documents that Railroad trade increase is before + * Democracy/Republic [government in general now -- SKi] bonus -AJS */ + if (t) + t += g->trade_bonus; if(city_affected_by_wonder(pcity, B_COLLOSSUS)) t++; if((spec_t&S_ROAD) && city_got_building(pcity, B_SUPERHIGHWAYS)) t*=1.5; - if (t>2 && gov <=G_DESPOTISM) + /* government trade penalty -- SKi */ + if (g->trade_before_penalty && t > g->trade_before_penalty) t--; if (spec_t & S_POLLUTION) t=(t+1)/2; /* The trade here is dirty */ @@ -1050,14 +1049,11 @@ int f; enum tile_special_type spec_t=map_get_special(pcity->x+x-2, pcity->y+y-2); enum tile_terrain_type tile_t=map_get_terrain(pcity->x+x-2, pcity->y+y-2); + struct government *g = &governments[ get_government(pcity->owner) ]; struct tile_type *type; - int gov=get_government(pcity->owner); type=get_tile_type(tile_t); - if (city_celebrating(pcity)) - gov+=2; - if (spec_t & S_SPECIAL) f=get_tile_type(tile_t)->food_special; else @@ -1075,7 +1071,9 @@ if (city_got_building(pcity, B_SUPERMARKET) && (spec_t & S_IRRIGATION)) f *= 1.5; - if (f>2 && gov <=G_DESPOTISM) + if (f) + f += g->food_bonus; + if (g->food_before_penalty && f > g->food_before_penalty) f--; if (spec_t & S_POLLUTION) diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/game.c freeciv-local/common/game.c --- freeciv-orig/common/game.c Sat Jun 12 10:46:24 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 --exclude-from=../.diff_ignore -Nur freeciv-orig/common/game.h freeciv-local/common/game.h --- freeciv-orig/common/game.h Sat Jun 12 10:46:24 1999 +++ freeciv-local/common/game.h Sat Jul 3 11:19:18 1999 @@ -77,8 +77,14 @@ int aqueduct_size; int sewer_size; int spacerace; + + int government_count; + int default_government; + int government_when_anarchy; + struct { char techs[MAX_LENGTH_NAME]; + char governments[MAX_LENGTH_NAME]; char units[MAX_LENGTH_NAME]; char buildings[MAX_LENGTH_NAME]; } ruleset; diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/government.c freeciv-local/common/government.c --- freeciv-orig/common/government.c Thu Jan 1 01:00:00 1970 +++ freeciv-local/common/government.c Sat Jul 3 13:40:15 1999 @@ -0,0 +1,51 @@ +/********************************************************************** + Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ +#include +#include + +#include "player.h" +#include "government.h" +#include "tech.h" +#include "game.h" + +/* TODO: + * o The government names are still hardcoded in the Xaw client, + * and it expects there to be _exactly_ 6 governments. + * o Update to latest CVS snapshot. + * o Implement the features needed for fundamentalism: + * - Units that require a government to be built, and have special + * upkeep values under that government. (Fanatics). + * - NO_UNHAPPY_CITIZENS flag for governments. + * - CONVERT_TITHES_TO_MONEY flag for governments (surplus only?). + * - A research penalty that is applied after all other modifiers. + * - A diplomatic penalty modifier when international incidents occur. + * (Spy places nuke in city, goes to war, etc). + * o Test the new government evaluation code (AI). + */ + +struct government *governments; + + +struct government *find_government_by_name(char *name) +{ + int i; + + for (i = 0; i < game.government_count; ++i) { + if (strcmp (governments[i].name, name) == 0) { + return &governments[i]; + } + } + + return NULL; +} + diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/government.h freeciv-local/common/government.h --- freeciv-orig/common/government.h Thu Jan 1 01:00:00 1970 +++ freeciv-local/common/government.h Sat Jul 3 11:40:21 1999 @@ -0,0 +1,118 @@ +/********************************************************************** + Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. +***********************************************************************/ +#ifndef FC__GOVERNMENT_H +#define FC__GOVERNMENT_H + +#include "genlist.h" +#include "shared.h" + +/* + * 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 (42) +/* special values for free_* fields -- SKi */ +#define CITY_SIZE_FREE (42) +/* generic special values (for modifiers) -- SKi */ +#define ENTIRE_CITY (42) +/* other flags (on/off) -- SKi */ +#define BUILD_VETERAN_DIPLOMAT (0x01) /* does this flag count for spies too? -- SKi */ +#define REVOLUTION_WHEN_UNHAPPY (0x02) +#define HAS_SENATE (0x04) +#define UNBRIBABLE (0x08) +#define INSPIRES_PARTISANS (0x10) +#define IS_NICE (0x20) +#define FAVORS_GROWTH (0x40) + +/* 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 (42) +#define NULL_RULER_TITLE { 0, NULL, NULL } + +struct ruler_title +{ + int race; + char* male_title; + char* female_title; +}; + +/* This is struct government itself. All information about + * a form of government is contained inhere. + * -- SKi */ +struct government +{ + /* index into governments[] array -- SKi */ + int index; + + /* government name */ + char* name; + /* ruler titles */ + struct ruler_title *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; + /* how many unhappy citizens can military units suppress? -- SKi */ + int martial_law; + /* empire size factor -- size of empire (city count) before number + * of content citizens is decreased -- SKi */ + int empire_size_factor; + /* tells what size a city has to have for rapture to happen, no rapture + * can happen if it is zero -- SKi */ + int rapture_size; + + /* tech (only one) required to use this government -- SKi */ + int required_tech; + + /* cost modifiers -- SKi*/ + int extra_happy_cost; + int extra_shield_cost; + int extra_food_cost; + int extra_gold_cost; + + /* number of units that a city does not have to "pay" for --SKi */ + int free_happy; + int free_shield; + int free_food; + int free_gold; + + /* government production penalties -- SKi */ + int trade_before_penalty; + int shields_before_penalty; + int food_before_penalty; + + /* government production bonuses -- SKi */ + int trade_bonus; + int shield_bonus; + int food_bonus; + + /* corruption modifiers -- SKi */ + int corruption_level; + int corruption_modifier; + int fixed_corruption_distance; + int corruption_distance_factor; + int extra_corruption_distance; + + /* various other flags */ + int flags; +}; + +extern struct government *governments; + +struct government *find_government_by_name (char *name); + +#endif diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/packets.c freeciv-local/common/packets.c --- freeciv-orig/common/packets.c Sat Jun 12 10:46:24 1999 +++ freeciv-local/common/packets.c Sat Jul 3 12:19:05 1999 @@ -214,6 +214,10 @@ 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_RULER_TITLE: + return receive_packet_ruleset_government_ruler_title(pc); case PACKET_SPACESHIP_INFO: return recieve_packet_spaceship_info(pc); @@ -850,6 +854,9 @@ cptr=put_int8(cptr, pinfo->rtech.cathedral_plus); cptr=put_int8(cptr, pinfo->rtech.cathedral_minus); cptr=put_int8(cptr, pinfo->rtech.colosseum_plus); + + cptr=put_int8(cptr, pinfo->default_government); + cptr=put_int8(cptr, pinfo->government_when_anarchy); put_int16(buffer, cptr-buffer); @@ -908,6 +915,9 @@ cptr=get_int8(cptr, &pinfo->rtech.cathedral_minus); cptr=get_int8(cptr, &pinfo->rtech.colosseum_plus); + cptr=get_int8(cptr, &pinfo->default_government); + cptr=get_int8(cptr, &pinfo->government_when_anarchy); + remove_packet_from_buffer(&pc->buffer); return pinfo; } @@ -1732,6 +1742,151 @@ 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->required_tech); + 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->empire_size_factor); + cptr=put_int8(cptr, packet->rapture_size); + + 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->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->trade_before_penalty); + cptr=put_int8(cptr, packet->shields_before_penalty); + cptr=put_int8(cptr, packet->food_before_penalty); + + cptr=put_int8(cptr, packet->trade_bonus); + cptr=put_int8(cptr, packet->shield_bonus); + cptr=put_int8(cptr, packet->food_bonus); + + cptr=put_int8(cptr, packet->corruption_level); + cptr=put_int8(cptr, packet->corruption_modifier); + cptr=put_int8(cptr, packet->fixed_corruption_distance); + cptr=put_int8(cptr, packet->corruption_distance_factor); + cptr=put_int8(cptr, packet->extra_corruption_distance); + + cptr=put_int8(cptr, packet->flags); + + cptr=put_int8(cptr, packet->ruler_title_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); +} + +/************************************************************************** +... +**************************************************************************/ +struct packet_ruleset_government * +receive_packet_ruleset_government(struct connection *pc) +{ + unsigned char *cptr; + struct packet_ruleset_government *packet= + fc_calloc(1, 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->required_tech); + 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->empire_size_factor); + + 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->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->trade_before_penalty); + cptr=get_int8(cptr, &packet->shields_before_penalty); + cptr=get_int8(cptr, &packet->food_before_penalty); + + cptr=get_int8(cptr, &packet->trade_bonus); + cptr=get_int8(cptr, &packet->shield_bonus); + cptr=get_int8(cptr, &packet->food_bonus); + + cptr=get_int8(cptr, &packet->corruption_level); + cptr=get_int8(cptr, &packet->corruption_modifier); + cptr=get_int8(cptr, &packet->fixed_corruption_distance); + cptr=get_int8(cptr, &packet->corruption_distance_factor); + cptr=get_int8(cptr, &packet->extra_corruption_distance); + + cptr=get_int8(cptr, &packet->flags); + + cptr=get_int8(cptr, &packet->ruler_title_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); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/packets.h freeciv-local/common/packets.h --- freeciv-orig/common/packets.h Sat Jun 12 10:46:24 1999 +++ freeciv-local/common/packets.h Sat Jul 3 11:48:49 1999 @@ -84,6 +84,8 @@ PACKET_RULESET_TECH, PACKET_RULESET_UNIT, PACKET_RULESET_BUILDING, + PACKET_RULESET_GOVERNMENT, + PACKET_RULESET_GOVERNMENT_RULER_TITLE, PACKET_CITY_OPTIONS, PACKET_SPACESHIP_INFO, PACKET_SPACESHIP_ACTION, @@ -457,6 +459,55 @@ int variant; }; +struct packet_ruleset_government { + int id; + + int required_tech; + int max_rate; + int civil_war; + int martial_law; + int empire_size_factor; + int rapture_size; + + 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 trade_before_penalty; + int shields_before_penalty; + int food_before_penalty; + + int trade_bonus; + int shield_bonus; + int food_bonus; + + int corruption_level; + int corruption_modifier; + int fixed_corruption_distance; + int corruption_distance_factor; + int extra_corruption_distance; + + int flags; + + int ruler_title_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]; +}; + /********************************************************* ... @@ -492,6 +543,9 @@ int cathedral_minus; int colosseum_plus; } rtech; + + int government_when_anarchy; + int default_government; }; /********************************************************* @@ -672,6 +726,15 @@ 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_before_end_year(struct connection *pc); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/player.c freeciv-local/common/player.c --- freeciv-orig/common/player.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/common/player.c Sat Jul 3 11:39:40 1999 @@ -20,6 +20,8 @@ #include #include #include +#include "government.h" +#include "log.h" extern int is_server; @@ -28,85 +30,85 @@ {100,100,100,100,100,100,100}, { {A_REPUBLIC, A_WHEEL, A_IRON, A_CONSTRUCTION, A_RAILROAD, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE}, - B_LEONARDO , G_DEMOCRACY} /* wonder not actually checked in choose_build */ + B_LEONARDO} /* wonder not actually checked in choose_build */ }, {"Babylonian", "Babylonians", 0, 0, 2, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_PHILOSOPHY, A_MATHEMATICS, A_CHIVALRY, A_THEOLOGY, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE}, - B_HANGING , G_MONARCHY} + B_HANGING} }, {"German", "Germans", 2, 0, 2, {100,100,100,100,100,100,100}, { {A_REPUBLIC, A_IRON, A_GUNPOWDER, A_EXPLOSIVES, A_FLIGHT, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE}, - B_BACH , G_REPUBLIC} + B_BACH} }, {"Egyptian", "Egyptians", 1, 1, 2, {100,100,100,100,100,100,100}, /* different order for experiment and flavor */ { {A_MONARCHY, A_PHILOSOPHY, A_NAVIGATION, A_IRON, A_RAILROAD, A_NONE, A_NONE, A_NONE, A_NONE, A_NONE}, - B_PYRAMIDS , G_MONARCHY} + B_PYRAMIDS} }, {"American", "Americans", 0, 1, 2, {100,100,100,100,100,100,100}, { {A_REPUBLIC, A_TRADE, A_ENGINEERING, A_DEMOCRACY, A_RAILROAD, A_EXPLOSIVES, A_AUTOMOBILE, A_NONE, A_NONE, A_NONE}, - B_LIBERTY , G_DEMOCRACY} + B_LIBERTY} }, {"Greek", "Greeks", 1, 2, 0, {100,100,100,100,100,100,100}, { {A_REPUBLIC, A_PHILOSOPHY, A_TRADE, A_ENGINEERING, A_IRON, A_RAILROAD, A_NONE, A_NONE, A_NONE, A_NONE}, - B_LIGHTHOUSE, G_REPUBLIC} + B_LIGHTHOUSE} }, {"Indian", "Indians", 0, 0, 1, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_PHILOSOPHY, A_REPUBLIC, A_IRON, A_ENGINEERING, A_RAILROAD, A_NONE, A_NONE, A_NONE, A_NONE}, - B_ORACLE , G_REPUBLIC} + B_ORACLE} }, {"Russian", "Russians", 2, 1, 0, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_PHILOSOPHY, A_CHIVALRY, A_TRADE, A_BRIDGE, A_RAILROAD, A_COMMUNISM, A_NONE, A_NONE, A_NONE}, - B_WOMENS , G_COMMUNISM} + B_WOMENS} }, {"Zulu", "Zulus", 2, 1, 1, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_PHILOSOPHY, A_CHIVALRY, A_TRADE, A_BRIDGE, A_RAILROAD, A_COMMUNISM, A_NONE, A_NONE, A_NONE}, - B_APOLLO , G_COMMUNISM} + B_APOLLO} }, {"French", "French", 2, 2, 2, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_CHIVALRY, A_PHILOSOPHY, A_REPUBLIC, A_MONOTHEISM, A_ENGINEERING, A_NAVIGATION, A_RAILROAD, A_NONE, A_NONE}, - B_MAGELLAN , G_REPUBLIC} + B_MAGELLAN} }, {"Aztec", "Aztecs", 1, 0, 2, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_CHIVALRY, A_IRON, A_TRADE, A_NAVIGATION, A_RAILROAD, A_COMMUNISM, A_NONE, A_NONE, A_NONE}, - B_HOOVER , G_COMMUNISM} + B_HOOVER} }, {"Chinese", "Chinese", 1, 1, 2, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_TRADE, A_PHILOSOPHY, A_BRIDGE, A_RAILROAD, A_COMMUNISM, A_NONE ,A_NONE ,A_NONE, A_NONE}, - B_WALL , G_COMMUNISM} + B_WALL} }, {"English", "English", 1, 2, 1, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_CHIVALRY, A_TRADE, A_THEOLOGY, A_NAVIGATION, A_DEMOCRACY,A_RAILROAD, A_NONE, A_NONE, A_NONE}, - B_RICHARDS , G_DEMOCRACY} + B_RICHARDS} }, {"Mongol", "Mongols", 2, 2, 0, {100,100,100,100,100,100,100}, { {A_MONARCHY, A_CHIVALRY, A_TRADE, A_BRIDGE, A_RAILROAD, A_NONE, A_NONE ,A_NONE ,A_NONE, A_NONE}, - B_SUNTZU , G_MONARCHY} + B_SUNTZU} } }; @@ -127,24 +129,6 @@ "Genghis" }; -int government_rates[G_LAST] = { - 100, 60, 70, 80, 80, 100 -}; - -int government_civil_war[G_LAST] = { - 90, 80, 70, 50, 40, 30 -}; - -char *government_names[G_LAST] = { - "Anarchy", "Despotism", "Monarchy", - "Communism", "Republic", "Democracy" -}; - -char *ruler_titles[G_LAST] = { - "Mr.", "Emperor", "King", /* even for Elizabeth */ - "Comrade", "President", "President" -}; - /*************************************************************** ... ***************************************************************/ @@ -167,6 +151,20 @@ /*************************************************************** ... ***************************************************************/ +enum race_type find_race_by_name(char *name) +{ + int i; + + for(i=0; irace == DEFAULT_TITLE && best_match == NULL) { + best_match = title; + } else if (title->race == race) { + best_match = title; + break; + } + ++title; + } while (title->male_title != NULL); + + if (best_match) { + return male ? best_match->male_title : best_match->female_title; + } else { + freelog (LOG_NORMAL, "get_ruler_title: found no title for government %d", gov); + return "Mr."; + } } /*************************************************************** ... ***************************************************************/ -int get_government_max_rate(enum government_type type) +int get_government_max_rate(int type) { - return government_rates[type]; + return governments[type].max_rate; } /*************************************************************** Added for civil war probability computation - Kris Bubendorfer ***************************************************************/ -int get_government_civil_war_prob(enum government_type type) +int get_government_civil_war_prob(int type) { - if(type >= G_ANARCHY && type < G_LAST) - return government_civil_war[type]; + if(type >= 0 && type < game.government_count) + return governments[type].civil_war; return 0; } /*************************************************************** ... ***************************************************************/ -char *get_government_name(enum government_type type) +char *get_government_name(int type) { - return government_names[type]; + return governments[type].name; } /*************************************************************** ... ***************************************************************/ -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; - - switch (gov) { - case G_ANARCHY: - case G_DESPOTISM: + /* ok if: + * - no required tech + * - we have an appropriate wonder + * - player has reqired tech + */ + if (player_owns_active_govchange_wonder(pplayer) || + governments[government].required_tech == A_LAST || + get_invention(pplayer, governments[government].required_tech) == TECH_KNOWN) { 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 */ + return 0; } /*************************************************************** @@ -263,7 +263,8 @@ plr->player_no=plr-game.players; strcpy(plr->name, "YourName"); - plr->government=G_DESPOTISM; + plr->is_male = 1; + plr->government=game.default_government; plr->race=R_LAST; plr->capital=0; unit_list_init(&plr->units); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/common/player.h freeciv-local/common/player.h --- freeciv-orig/common/player.h Sat Jun 12 10:47:07 1999 +++ freeciv-local/common/player.h Thu Jun 17 23:08:19 1999 @@ -17,6 +17,7 @@ #include "unit.h" #include "city.h" #include "spaceship.h" +#include "government.h" struct tile; @@ -24,10 +25,6 @@ #define PLAYER_DEFAULT_SCIENCE_RATE 50 #define PLAYER_DEFAULT_LUXURY_RATE 0 #define TECH_GOALS 10 -enum government_type { - G_ANARCHY, G_DESPOTISM, G_MONARCHY, G_COMMUNISM, G_REPUBLIC, G_DEMOCRACY, - G_LAST -}; enum race_type { R_ROMAN, R_BABYLONIAN, R_GERMAN, R_EGYPTIAN, R_AMERICAN, R_GREEK, R_INDIAN, @@ -67,7 +64,9 @@ struct { /* basically disabled -- Syela */ int tech[TECH_GOALS]; /* Tech goals */ int wonder; /* primary Wonder (maybe primary opponent, if other builds it) */ +#ifdef UNUSED int government; /* wanted government form */ +#endif } goals; }; @@ -122,7 +121,8 @@ struct player { int player_no; char name[MAX_LENGTH_NAME]; - enum government_type government; + int is_male; + int government; enum race_type race; int turn_done; int nturns_idle; @@ -149,12 +149,12 @@ 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 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); -char *get_ruler_title(enum government_type type); +int can_change_to_government(struct player *pplayer, int government); +int get_government_max_rate(int type); +int get_government_civil_war_prob(int type); +char *get_government_name(int type); +char *get_ruler_title(int 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 --exclude-from=../.diff_ignore -Nur freeciv-orig/common/shared.h freeciv-local/common/shared.h --- freeciv-orig/common/shared.h Sat Jun 12 10:46:24 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 --exclude-from=../.diff_ignore -Nur 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 13 20:34:09 1999 @@ -0,0 +1,136 @@ + +; 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 +default="Despotism" +when_anarchy="Anarchy" + +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_tech = { "government", "tech" + "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" +}; + +; corruption: +; level: percent of actual calculated corruption that is applied +; modifier: greater-than-zero divisor; the higher the less corruption +; fixed_distance: use this distance for all cities +; distance_factor: multiply actual distance with this +; extra_distance: add this to the calculated distance +corruption = { "government", "level", "modifier", "fixed_distance", "distance_factor", "extra_distance" + "Anarchy", 100, 40, 0, 1, 0 + "Despotism", 100, 27, 0, 2, 3 + "Monarchy", 100, 67, 0, 1, 0 + "Communism", 50, 80, 10, 1, 0 + "Republic", 100, 67, 0, 1, 0 + "Democracy", 0, 1, 0, 0, 0 +}; + +; production bonuses +bonus = { "government", "trade_bonus", "shield_bonus", "food_bonus" + "Anarchy", 0, 0, 0 + "Despotism", 0, 0, 0 + "Monarchy", 0, 0, 0 + "Communism", 0, 0, 0 + "Republic", 0, 0, 0 + "Democracy", 1, 0, 0 +}; + +; production penalties +penalty = { "government", "trade_before", "shields_before", "food_before" + "Anarchy", 0, 0, 2 + "Despotism", 0, 0, 2 + "Monarchy", 0, 0, 0 + "Communism", 0, 0, 0 + "Republic", 0, 0, 0 + "Democracy", 0, 0, 0 +}; + +flags = { "government", "flags" + "Anarchy", "FAVORS_GROWTH" + "Despotism", "FAVORS_GROWTH" + "Monarchy", "FAVORS_GROWTH" + "Communism", "BUILD_VETERAN_DIPLOMAT", "FAVORS_GROWTH" + "Republic", "HAS_SENATE", "IS_NICE" + "Democracy", "HAS_SENATE", "REVOLUTION_WHEN_UNHAPPY", "IS_NICE" +}; + +others = { "government", "martial_law", "max_rates", "civil_war", "empire_size_factor", "rapture_size" + "Anarchy", 3, 60, 90, 0, 0 + "Despotism", 3, 60, 80, 1, 0 + "Monarchy", 3, 70, 70, 2, 0 + "Communism", 3, 80, 50, 3, 0 + "Republic", 0, 90, 40, 4, 4 + "Democracy", 0, 100, 30, 5, 4 +}; + +; "-" 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 --exclude-from=../.diff_ignore -Nur 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 13 21:22:27 1999 @@ -0,0 +1,161 @@ + +; 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 +default="Despotism" +when_anarchy="Anarchy" + +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_tech = { "government", "tech" + "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" +}; + +; corruption: +; level: percent of actual calculated corruption that is applied +; modifier: greater-than-zero divisor; the higher the less corruption +; fixed_distance: use this distance for all cities +; distance_factor: multiply actual distance with this +; extra_distance: add this to the calculated distance +corruption = { "government", "level", "modifier", "fixed_distance", "distance_factor", "extra_distance" + "Anarchy", 100, 40, 0, 1, 0 + "Despotism", 100, 27, 0, 2, 3 + "Monarchy", 100, 67, 0, 1, 0 + "Communism", 50, 80, 10, 1, 0 +; "Fundamentalism", 100, 80, 0, 1, 0 + "Republic", 100, 67, 0, 1, 0 + "Democracy", 0, 1, 0, 0, 0 +}; + +; production bonuses +bonus = { "government", "trade_bonus", "shield_bonus", "food_bonus" + "Anarchy", 0, 0, 0 + "Despotism", 0, 0, 0 + "Monarchy", 0, 0, 0 + "Communism", 0, 0, 0 +; "Fundamentalism", 0, 0, 0 + "Republic", 0, 0, 0 + "Democracy", 1, 0, 0 +}; + +; production penalties +penalty = { "government", "trade_before", "shields_before", "food_before" + "Anarchy", 0, 0, 2 + "Despotism", 0, 0, 2 + "Monarchy", 0, 0, 0 + "Communism", 0, 0, 0 +; "Fundamentalism", 0, 0, 0 + "Republic", 0, 0, 0 + "Democracy", 0, 0, 0 +}; + +flags = { "government", "flags" + "Anarchy", "FAVORS_GROWTH" + "Despotism", "FAVORS_GROWTH" + "Monarchy", "FAVORS_GROWTH" + "Communism", "BUILD_VETERAN_DIPLOMAT", "INSPIRES_PARTISANS", "FAVORS_GROWTH" +; "Fundamentalism", "FAVORS_GROWTH" + "Republic", "HAS_SENATE", "IS_NICE" + "Democracy", "HAS_SENATE", "REVOLUTION_WHEN_UNHAPPY", "INSPIRES_PARTISANS", "IS_NICE" +}; + +others = { "government", "martial_law", "max_rates", "civil_war", "empire_size_factor", "rapture_size" + "Anarchy", 3, 60, 90, 0, 0 + "Despotism", 3, 60, 80, 1, 0 + "Monarchy", 3, 70, 70, 2, 0 + "Communism", 3, 80, 50, 3, 0 +; "Fundamentalism", 0, 80, 60, 4, 0 + "Republic", 0, 90, 40, 4, 4 + "Democracy", 0, 100, 30, 5, 4 +}; + +; "-" 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 --exclude-from=../.diff_ignore -Nur freeciv-orig/server/citytools.c freeciv-local/server/citytools.c --- freeciv-orig/server/citytools.c Sat Jun 5 17:21:21 1999 +++ freeciv-local/server/citytools.c Sat Jul 3 11:32:46 1999 @@ -36,6 +36,7 @@ #include /* send_game_info */ #include /* set_ai_level_direct */ #include +#include "government.h" /**************************************************************** ... @@ -84,7 +85,7 @@ { int cities = city_list_size(&pplayer->cities); int content = game.unhappysize; - int basis = game.cityfactor - (G_DEMOCRACY - pplayer->government); + int basis = game.cityfactor + governments[ pplayer->government ].empire_size_factor; if (cities > basis) content--; @@ -238,16 +239,28 @@ **************************************************************************/ int settler_eats(struct city *pcity) { - int eat=0; + struct government *g = &governments[ get_government(pcity->owner) ]; + int free_food = g->free_food; + int eat = 0; + + if (free_food == CITY_SIZE_FREE) { + free_food = pcity->size; + } + unit_list_iterate(pcity->units_supported, this_unit) { - if (unit_flag(this_unit->type, F_SETTLERS)) { - eat++; - if (get_government(pcity->owner)>=G_COMMUNISM) { - eat++; + struct unit_type *ut = &unit_types[this_unit->type]; + int food_cost = (g->extra_food_cost == NO_UPKEEP || ut->food_cost == 0) ? 0 : ut->food_cost + g->extra_food_cost; + + if (food_cost > 0) { + if (free_food) { + --free_food; + } else { + eat += food_cost; } } } unit_list_iterate_end; + return eat; } @@ -283,9 +296,10 @@ **************************************************************************/ void eval_buildings(struct city *pcity,int *values) { - int i, gov, tech; + int i, tech; + int gov = get_government(pcity->owner); struct player *plr = city_owner(pcity); - gov = get_government(pcity->owner); + struct government *g = &governments[gov]; tech = (plr->research.researching != A_NONE); for (i=0;isize < 5) { + if (g->flags & FAVORS_GROWTH || pcity->size < 5) { if (can_build_improvement(pcity, B_GRANARY)) values[B_GRANARY]=pcity->food_surplus*50; } @@ -328,11 +342,11 @@ if (can_build_improvement(pcity, B_STOCK)) values[B_STOCK]=pcity->tax_total*100; - if (gov > G_COMMUNISM) + if (g->flags & IS_NICE) if (can_build_improvement(pcity, B_SUPERHIGHWAYS)) values[B_SUPERHIGHWAYS]=pcity->trade_prod*60; if (can_build_improvement(pcity, B_COURTHOUSE)) { - if (gov != G_DEMOCRACY) + if (g->corruption_level) values[B_COURTHOUSE]=pcity->corruption*100; else values[B_COURTHOUSE]=pcity->ppl_unhappy[4]*200+pcity->ppl_elvis*400; @@ -420,7 +434,7 @@ int do_make_unit_veteran(struct city *pcity, enum unit_type_id id) { if (unit_flag(id,F_DIPLOMAT)) - return(get_government(pcity->owner)==G_COMMUNISM); + return governments[ get_government(pcity->owner) ].flags & BUILD_VETERAN_DIPLOMAT; if (is_ground_unittype(id) || improvement_variant(B_BARRACKS)==1) return city_got_barracks(pcity); @@ -435,15 +449,13 @@ **************************************************************************/ int city_corruption(struct city *pcity, int trade) { + struct government *g = &governments[ get_government(pcity->owner) ]; struct city *capital; int dist; int val; - int corruption[]= { 40,27,67,80,67,0}; /* original {12,8,16,20,24,0} */ - if (get_government(pcity->owner)==G_DEMOCRACY) { - return(0); - } - if (get_government(pcity->owner)==G_COMMUNISM) { - dist=10; + + if (g->fixed_corruption_distance) { + dist = g->fixed_corruption_distance; } else { capital=find_palace(city_owner(pcity)); if (!capital) @@ -451,16 +463,13 @@ else dist=min(36,map_distance(capital->x, capital->y, pcity->x, pcity->y)); } - if (get_government(pcity->owner) == G_DESPOTISM) - dist = dist*2 + 3; /* yes, DESPOTISM is even worse than ANARCHY */ - - val=trade*dist/corruption[get_government(pcity->owner)]; + dist = dist * g->corruption_distance_factor + g->extra_corruption_distance; + val=trade*dist*g->corruption_level; if (city_got_building(pcity, B_COURTHOUSE) || city_got_building(pcity, B_PALACE)) val /= 2; - if (get_government(pcity->owner)==G_COMMUNISM) - val /= 2; + val *= g->corruption_modifier; if (val >= trade && val) val = trade - 1; return(val); /* how did y'all let me forget this one? -- Syela */ @@ -704,7 +713,7 @@ cplayer->is_connected = 0; cplayer->conn = NULL; - cplayer->government = G_ANARCHY; + cplayer->government = game.government_when_anarchy; pplayer->revolution = 1; cplayer->capital = 1; @@ -740,7 +749,7 @@ /* change the original player */ - pplayer->government = G_ANARCHY; + pplayer->government = game.government_when_anarchy; pplayer->revolution = 1; pplayer->economic.tax = PLAYER_DEFAULT_TAX_RATE; pplayer->economic.science = PLAYER_DEFAULT_SCIENCE_RATE; @@ -776,6 +785,8 @@ * * Note: In the event that Fundamentalism is added, you need to * update the array government_civil_war[G_LAST] in player.c + * + * [ SKi: That would now be data/default/governments.ruleset. ] * * In addition each city in revolt adds 5%, each city in rapture * subtracts 5% from the probability of a civil war. diff --exclude-from=../.diff_ignore -Nur freeciv-orig/server/cityturn.c freeciv-local/server/cityturn.c --- freeciv-orig/server/cityturn.c Sat Jun 12 10:47:07 1999 +++ freeciv-local/server/cityturn.c Sat Jul 3 11:39:21 1999 @@ -38,6 +38,7 @@ #include #include #include +#include extern signed short int minimap[MAP_MAX_WIDTH][MAP_MAX_HEIGHT]; @@ -83,7 +84,7 @@ pcity->tax_total = 0; rate = pcity->trade_prod; while (rate) { - if( game.players[pcity->owner].government!= G_ANARCHY ){ + if( game.players[pcity->owner].government!= game.government_when_anarchy ){ tax += (100 - game.players[pcity->owner].economic.science - game.players[pcity->owner].economic.luxury); sci += game.players[pcity->owner].economic.science; lux += game.players[pcity->owner].economic.luxury; @@ -185,13 +186,6 @@ { int step; - if (improvement_variant(B_WOMENS)==0 - && city_got_effect(pcity, B_POLICE)) { - if (get_government(pcity->owner)==G_DEMOCRACY) - unhap-=2; - else - unhap--; - } if (unhap>0) { step=min(unhap,pcity->ppl_content[3]); pcity->ppl_content[3]-=step; @@ -218,6 +212,7 @@ **************************************************************************/ void citizen_happy_buildings(struct city *pcity) { + struct government *g = &governments[ get_government(pcity->owner) ]; int faces=0; happy_copy(pcity, 1); @@ -225,7 +220,7 @@ faces+=get_temple_power(pcity); } if (city_got_building(pcity,B_COURTHOUSE) && - get_government(pcity->owner) == G_DEMOCRACY ) { + g->corruption_level == 0) { faces++; } @@ -417,20 +412,16 @@ /************************************************************************** ... **************************************************************************/ -#define extra_happy_cost governments[gov].extra_happy_cost -#define extra_shield_cost governments[gov].extra_shield_cost -#define extra_food_cost governments[gov].extra_food_cost -#define extra_gold_cost governments[gov].extra_gold_cost void city_support(struct city *pcity) { - int gov = get_government(pcity->owner); + struct government *g = &governments[ get_government(pcity->owner) ]; - int content_mod = governments[gov].military_contentment_mod; + int content_mod = g->martial_law; - int free_happy = governments[gov].free_happy; - int free_shield = governments[gov].free_shield; - int free_food = governments[gov].free_food; - int free_gold = governments[gov].free_gold; + int free_happy = g->free_happy; + int free_shield = g->free_shield; + int free_food = g->free_food; + int free_gold = g->free_gold; /* handle special values of free_* -- SKi */ if (free_happy == CITY_SIZE_FREE) { @@ -446,15 +437,25 @@ free_gold = pcity->size; } + /* FIXME: What does this de? -- SKi */ happy_copy(pcity, 2); - /* loop units, subtracting appropriate amounts of food, shields, gold etc -- SKi */ + /* + * If you modify anything here these places might also need updating: + * - ai/aitools.c : ai_assess_military_unhappiness + * Military discontentment evaluation for AI. + * + * P.S. This list is by no means complete. + * --SKi + */ + + /* loop over units, subtracting appropriate amounts of food, shields, gold etc -- SKi */ unit_list_iterate(pcity->units_supported, this_unit) { struct unit_type *ut = &unit_types[this_unit->type]; - int happy_cost = (extra_happy_cost == NO_UPKEEP || ut->happy_cost == 0) ? 0 : ut->happy_cost + extra_happy_cost; - int shield_cost = (extra_shield_cost == NO_UPKEEP || ut->shield_cost == 0) ? 0 : ut->shield_cost + extra_shield_cost; - int food_cost = (extra_food_cost == NO_UPKEEP || ut->food_cost == 0) ? 0 : ut->food_cost + extra_food_cost; - int gold_cost = (extra_gold_cost == NO_UPKEEP || ut->gold_cost == 0) ? 0 : ut->gold_cost + extra_gold_cost; + int happy_cost = (g->extra_happy_cost == NO_UPKEEP || ut->happy_cost == 0) ? 0 : ut->happy_cost + g->extra_happy_cost; + int shield_cost = (g->extra_shield_cost == NO_UPKEEP || ut->shield_cost == 0) ? 0 : ut->shield_cost + g->extra_shield_cost; + int food_cost = (g->extra_food_cost == NO_UPKEEP || ut->food_cost == 0) ? 0 : ut->food_cost + g->extra_food_cost; + int gold_cost = (g->extra_gold_cost == NO_UPKEEP || ut->gold_cost == 0) ? 0 : ut->gold_cost + g->extra_gold_cost; /* set current upkeep on unit to zero */ this_unit->unhappiness = 0; @@ -462,25 +463,30 @@ this_unit->upkeep_food = 0; this_unit->upkeep_gold = 0; - /* no happy_cost for non agressive units -- SKi */ - if (! unit_being_aggressive (this_unit)) { + /* Units come in three groupings (here): + * - Field units, under open-governments. + * - Agressive units, under open-governments. + * - Others. (Both other unit types and government types). + */ + if (is_field_unit (this_unit) && (g->extra_happy_cost != NO_UPKEEP)) { + happy_cost = 1; + } else if (unit_being_aggressive (this_unit) && (happy_cost > 0)) { + /* effects of police station and womens sufferage (sp?) -- SKi */ + if (improvement_variant (B_WOMENS) || city_got_effect (pcity, B_POLICE)) { + --happy_cost; + } + } else { happy_cost = 0; } - /* effects of police stations; - * ignored if it's a field unit - * -- SKi */ - if (happy_cost > 0 && city_got_effect (pcity, B_POLICE) - && ! is_field_unit (this_unit)) { - --happy_cost; - } /* military units in home city can make unhappy citizens content -- SKi */ if (content_mod > 0 && pcity->ppl_unhappy[3] > 0 && - this_unit->x == pcity->x && this_unit->y == pcity->y) { + this_unit->x == pcity->x && this_unit->y == pcity->y) { --content_mod; --pcity->ppl_unhappy[3]; ++pcity->ppl_content[3]; } + /* subtract values found above from citys resources -- SKi */ if (happy_cost > 0) { if (free_happy) { --free_happy; @@ -509,17 +515,13 @@ if (free_gold) { --free_gold; } else { - /* hmmm... */ + /* FIXME: This is not implemented -- SKi */ this_unit->upkeep_gold = gold_cost; } } } unit_list_iterate_end; } -#undef extra_happy_cost -#undef extra_shield_cost -#undef extra_food_cost -#undef extra_gold_cost /************************************************************************** ... @@ -637,10 +639,16 @@ void auto_arrange_workers(struct city *pcity) { + struct government *g = &governments[ get_government(pcity->owner) ]; int workers=pcity->size; + int free_shield = g->free_shield; int taxwanted,sciwanted; int x,y; - int foodneed, prodneed, gov; + int foodneed, prodneed; + + if (free_shield == CITY_SIZE_FREE) { + free_shield = pcity->size; + } city_map_iterate(x, y) if (get_worker_city(pcity, x, y)==C_TILE_WORKER) @@ -650,12 +658,20 @@ foodneed=(pcity->size *2 -get_food_tile(2,2, pcity)) + settler_eats(pcity); prodneed = 0; prodneed -= get_shields_tile(2,2,pcity); - unit_list_iterate(pcity->units_supported, punit) - if (is_military_unit(punit)) prodneed++; + + unit_list_iterate(pcity->units_supported, this_unit) { + struct unit_type *ut = &unit_types[this_unit->type]; + int shield_cost = (g->extra_shield_cost == NO_UPKEEP || ut->shield_cost == 0) ? 0 : ut->shield_cost + g->extra_shield_cost; + + if (shield_cost > 0) { + if (free_shield) { + --free_shield; + } else { + prodneed += shield_cost; + } + } + } unit_list_iterate_end; - gov = get_government(pcity->owner); - if (gov == G_DESPOTISM) prodneed -= pcity->size; - if (gov == G_MONARCHY || gov == G_COMMUNISM) prodneed -= 3; taxwanted=pcity->ppl_taxman; sciwanted=pcity->ppl_scientist; @@ -1100,7 +1116,7 @@ break; } } - } else if( pplayer->government != G_ANARCHY ){ + } else if( pplayer->government != game.government_when_anarchy ){ if (pplayer->economic.gold-improvement_upkeep(pcity, i)<0) { notify_player_ex(pplayer, pcity->x, pcity->y, E_IMP_AUCTIONED, "Game: Can't afford to maintain %s in %s, building sold!", @@ -1198,7 +1214,7 @@ **************************************************************************/ void city_incite_cost(struct city *pcity) { - + struct government *g = &governments[ get_government(pcity->owner) ]; struct city *capital; int dist; @@ -1213,8 +1229,8 @@ dist=32; if (city_got_building(pcity, B_COURTHOUSE)) dist/=2; - if (get_government(city_owner(pcity)->player_no)==G_COMMUNISM) - dist = min(10, dist); + if (g->fixed_corruption_distance) + dist = min (g->fixed_corruption_distance, dist); pcity->incite_revolt_cost/=(dist + 3); pcity->incite_revolt_cost*=pcity->size; if (city_unhappy(pcity)) @@ -1229,13 +1245,16 @@ **************************************************************************/ int update_city_activity(struct player *pplayer, struct city *pcity) { + struct government *g = &governments[ get_government(pcity->owner) ]; int got_tech = 0; int turns_growth, turns_granary; city_check_workers(pplayer, pcity); - if (city_refresh(pcity) && - get_government(pcity->owner)>=G_REPUBLIC && - pcity->food_surplus>0 && pcity->size>4) { + + /* fill citys food box if it is in rapture -- SKi */ + if (city_refresh(pcity) && g->rapture_size && + pcity->size > g->rapture_size && + pcity->food_surplus > 0) { pcity->food_stock=(pcity->size+1)*game.foodbox+1; } @@ -1267,13 +1286,13 @@ if (!pcity->was_happy && city_happy(pcity) && pcity->size>4) { notify_player_ex(pplayer, pcity->x, pcity->y, E_CITY_LOVE, "Game: We Love The %s Day celebrated in %s", - get_ruler_title(pplayer->government), + get_ruler_title(pplayer->government, pplayer->is_male, pplayer->race), pcity->name); } if (!city_happy(pcity) && pcity->was_happy && pcity->size>4) { notify_player_ex(pplayer, pcity->x, pcity->y, E_CITY_NORMAL, "Game: We Love The %s Day canceled in %s", - get_ruler_title(pplayer->government), + get_ruler_title(pplayer->government, pplayer->is_male, pplayer->race), pcity->name); } @@ -1317,7 +1336,7 @@ city_incite_cost(pcity); send_city_info(0, pcity, 0); - if (pcity->anarchy>2 && get_government(pplayer->player_no)==G_DEMOCRACY) { + if (pcity->anarchy>2 && g->flags & REVOLUTION_WHEN_UNHAPPY) { notify_player_ex(pplayer, pcity->x, pcity->y, E_ANARCHY, "Game: The people have overthrown your democracy, your country is in turmoil"); handle_player_revolution(pplayer); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/server/civserver.h freeciv-local/server/civserver.h --- freeciv-orig/server/civserver.h Sat Jun 5 17:21:21 1999 +++ freeciv-local/server/civserver.h Sat Jul 3 12:12:30 1999 @@ -44,5 +44,6 @@ extern enum server_states server_state; extern int nocity_send; +extern int is_new_game; #endif /* FC__CIVSERVER_H */ diff --exclude-from=../.diff_ignore -Nur freeciv-orig/server/gamehand.c freeciv-local/server/gamehand.c --- freeciv-orig/server/gamehand.c Sat Jun 5 17:21:21 1999 +++ freeciv-local/server/gamehand.c Sat Jul 3 11:48:43 1999 @@ -169,6 +169,9 @@ ginfo.rtech.cathedral_minus = game.rtech.cathedral_minus; ginfo.rtech.colosseum_plus = game.rtech.colosseum_plus; + ginfo.government_when_anarchy = game.government_when_anarchy; + ginfo.default_government = game.default_government; + for(o=0; ogovernment!=G_ANARCHY || + if( pplayer->government!=game.government_when_anarchy || !can_change_to_government(pplayer, preq->government) ) return; @@ -842,10 +842,10 @@ { if ((pplayer->revolution<=5) && (pplayer->revolution>0) && - ( pplayer->government==G_ANARCHY)) + ( pplayer->government==game.government_when_anarchy)) return; pplayer->revolution=myrand(5)+1; - pplayer->government=G_ANARCHY; + pplayer->government=game.government_when_anarchy; notify_player(pplayer, "Game: The %s have incited a revolt!", races[pplayer->race].name); gamelog(GAMELOG_REVOLT,"The %s revolt!", diff --exclude-from=../.diff_ignore -Nur freeciv-orig/server/ruleset.c freeciv-local/server/ruleset.c --- freeciv-orig/server/ruleset.c Sat Jun 12 10:46:24 1999 +++ freeciv-local/server/ruleset.c Sat Jul 3 12:15:01 1999 @@ -15,6 +15,7 @@ #include #include +#include "mem.h" #include "game.h" #include "registry.h" #include "packets.h" @@ -24,6 +25,7 @@ #include "city.h" #include "ruleset.h" #include "capability.h" +#include "civserver.h" static char *openload_ruleset_file(struct section_file *file, char *subdir, char *whichset); @@ -37,10 +39,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 +555,262 @@ } /************************************************************************** +... +**************************************************************************/ +static void load_ruleset_governments(char *ruleset_subdir) +{ + struct section_file file; + char *filename, *datafile_options; + struct government *g = NULL; + 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 */ + + game.government_count = secfile_lookup_int (&file, "governments.count"); + if (game.government_count == 0) { + freelog (LOG_FATAL, "no governments!"); + exit (1); + } + governments = fc_calloc (game.government_count, sizeof (struct government)); + + /* first fill in government names so find_government_by_name will work -SKi */ + for(i = 0; i < game.government_count; i++) { + g = &governments[i]; + + /* get government name --SKi */ + c = secfile_lookup_str (&file, "governments.names%d.name", i); + if (! c) { + freelog (LOG_FATAL, "government %d has no name!", i); + exit (1); + } + g->index = i; + g->name = strdup (c); + } + + /* read default government -- SKi */ + game.default_government = 1; + c = secfile_lookup_str_default (&file, NULL, "governments.default"); + if (c) { + game.default_government = find_government_by_name (c)->index; + } + + /* because player_init is called before rulesets are loaded we set + * all players governments here (but only if is_new_game). --SKi */ + if (is_new_game) + for (i = 0; i < MAX_PLAYERS; ++i) + game.players[i].government = game.default_government; + + /* read government to use when in anarchy -- SKi */ + game.government_when_anarchy = 0; + c = secfile_lookup_str_default (&file, NULL, "governments.when_anarchy"); + if (c) { + game.government_when_anarchy = find_government_by_name (c)->index; + } + + /* get list of required techs --SKi */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.required_tech%d.government", i)) != NULL) { + g = find_government_by_name(c); + c = secfile_lookup_str_default (&file, NULL, "governments.required_tech%d.tech", i); + if (c == NULL) { + g->required_tech = A_LAST; + } else if ((g->required_tech = find_tech_by_name (c)) == A_LAST) { + freelog (LOG_FATAL, "government type %s required non-existant tech %s", g->name, c); + exit (1); + } + ++i; + } + + /* get extra_*_cost fields -- SKi */ + 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 --SKi */ + 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 corruption fields --SKi */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.corruption%d.government", i)) != NULL) { + g = find_government_by_name(c); + + g->corruption_level = secfile_lookup_int (&file, "governments.corruption%d.level", i); + g->corruption_modifier = secfile_lookup_int (&file, "governments.corruption%d.modifier", i); + g->fixed_corruption_distance = secfile_lookup_int (&file, "governments.corruption%d.fixed_distance", i); + g->corruption_distance_factor = secfile_lookup_int (&file, "governments.corruption%d.distance_factor", i); + g->extra_corruption_distance = secfile_lookup_int (&file, "governments.corruption%d.extra_distance", i); + + ++i; + } + + /* get production bonuses --SKi */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.bonus%d.government", i)) != NULL) { + g = find_government_by_name(c); + + g->trade_bonus = secfile_lookup_int (&file, "governments.bonus%d.trade_bonus", i); + g->shield_bonus = secfile_lookup_int (&file, "governments.bonus%d.shield_bonus", i); + g->food_bonus = secfile_lookup_int (&file, "governments.bonus%d.food_bonus", i); + + ++i; + } + + /* get production penalties --SKi */ + i = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.penalty%d.government", i)) != NULL) { + g = find_government_by_name(c); + + g->trade_before_penalty = secfile_lookup_int (&file, "governments.penalty%d.trade_before", i); + g->shields_before_penalty = secfile_lookup_int (&file, "governments.penalty%d.shields_before", i); + g->food_before_penalty = secfile_lookup_int (&file, "governments.penalty%d.food_before", i); + + ++i; + } + + /* get government flags -- SKi */ + i = 0; + g->flags = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.flags%d.government", i)) != NULL) { + g = find_government_by_name(c); + + j = 0; + while ((c = secfile_lookup_str_default (&file, NULL, "governments.flags%d.flags,%d", i, j)) != NULL) { + if (strcmp (c, "BUILD_VETERAN_DIPLOMAT") == 0) { + g->flags |= BUILD_VETERAN_DIPLOMAT; + } else if (strcmp (c, "REVOLUTION_WHEN_UNHAPPY") == 0) { + g->flags |= REVOLUTION_WHEN_UNHAPPY; + } else if (strcmp (c, "HAS_SENATE") == 0) { + g->flags |= HAS_SENATE; + } else if (strcmp (c, "UNBRIBABLE") == 0) { + g->flags |= UNBRIBABLE; + } else if (strcmp (c, "INSPIRES_PARTISANS") == 0) { + g->flags |= INSPIRES_PARTISANS; + } else if (strcmp (c, "IS_NICE") == 0) { + g->flags |= IS_NICE; + } else if (strcmp (c, "FAVORS_GROWTH") == 0) { + g->flags |= FAVORS_GROWTH; + } else { + freelog (LOG_FATAL, "government %s has unknown flag %s", g->name, c); + exit (1); + } + ++j; + } + + ++i; + } + + /* get other fields -- SKi */ + 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); + g->empire_size_factor = secfile_lookup_int (&file, "governments.others%d.empire_size_factor", i); + g->rapture_size = secfile_lookup_int (&file, "governments.others%d.rapture_size", i); + ++i; + } + + /* get ruler titles -- SKi */ + for (i = 0; i < game.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 +903,87 @@ /************************************************************************** ... **************************************************************************/ +static void send_ruleset_governments(struct player *dest) +{ + struct packet_ruleset_government gov; + struct packet_ruleset_government_ruler_title title; + struct ruler_title *p_title; + struct government *g; + int i, j, to; + + for (i = 0; i < game.government_count; ++i) { + g = &governments[i]; + + /* send one packet_government */ + gov.id = i; + + gov.required_tech = g->required_tech; + gov.max_rate = g->max_rate; + gov.civil_war = g->civil_war; + gov.martial_law = g->martial_law; + gov.empire_size_factor = g->empire_size_factor; + gov.rapture_size = g->rapture_size; + + 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; + + gov.trade_before_penalty = g->trade_before_penalty; + gov.shields_before_penalty = g->shields_before_penalty; + gov.food_before_penalty = g->food_before_penalty; + + gov.trade_bonus = g->trade_bonus; + gov.shield_bonus = g->shield_bonus; + gov.food_bonus = g->food_bonus; + + gov.corruption_level = g->corruption_level; + gov.corruption_modifier = g->corruption_modifier; + gov.fixed_corruption_distance = g->fixed_corruption_distance; + gov.corruption_distance_factor = g->corruption_distance_factor; + gov.extra_corruption_distance = g->extra_corruption_distance; + + for (p_title = g->ruler_title, j = 0; p_title->male_title != NULL; ++p_title, ++j); + gov.ruler_title_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); + } + } + } + } +} + +/************************************************************************** +... +**************************************************************************/ 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 +1002,7 @@ } send_ruleset_techs(dest); + send_ruleset_governments(dest); send_ruleset_units(dest); send_ruleset_buildings(dest); diff --exclude-from=../.diff_ignore -Nur freeciv-orig/server/settlers.c freeciv-local/server/settlers.c --- freeciv-orig/server/settlers.c Sat Jun 5 17:21:21 1999 +++ freeciv-local/server/settlers.c Tue Jun 8 16:53:25 1999 @@ -769,7 +769,7 @@ else food_cost = 40 * (mycity->size - 1) / mycity->size; if (city_got_effect(mycity, B_GRANARY)) food_cost -= 20; } - food_upkeep = (get_government(pplayer->player_no) > G_COMMUNISM ? 2 : 1); + food_upkeep = 1 + governments[ get_government(pplayer->player_no) ].extra_food_cost; if (punit->id && !punit->homecity) food_upkeep = 0; /* thanks, Peter */ /** First find the best square to upgrade, diff --exclude-from=../.diff_ignore -Nur freeciv-orig/server/unitfunc.c freeciv-local/server/unitfunc.c --- freeciv-orig/server/unitfunc.c Sat Jun 5 17:35:34 1999 +++ freeciv-local/server/unitfunc.c Tue Jun 8 16:49:23 1999 @@ -160,9 +160,9 @@ pvictim->bribe_cost = unit_bribe_cost(pvictim); } if(pplayer->economic.gold>=pvictim->bribe_cost) { - if(game.players[pvictim->owner].government==G_DEMOCRACY) + if(governments[ game.players[pvictim->owner].government ].flags & UNBRIBABLE) notify_player_ex(pplayer, pdiplomat->x, pdiplomat->y, E_NOEVENT, - "Game: You can't bribe a unit from a democratic nation."); + "Game: You can't bribe a unit from this nation."); else { pplayer->economic.gold-=pvictim->bribe_cost; notify_player_ex(&game.players[pvictim->owner], @@ -425,9 +425,9 @@ cplayer=city_owner(pcity); if (cplayer==pplayer || cplayer==NULL) return; - if(game.players[cplayer->player_no].government==G_DEMOCRACY) { + if(governments[ game.players[cplayer->player_no].government ].flags & UNBRIBABLE) { notify_player_ex(pplayer, pcity->x, pcity->y, E_NOEVENT, - "Game: You can't subvert a city from a democratic nation."); + "Game: You can't subvert a city from this nation."); return; } @@ -1543,7 +1543,9 @@ **************************************************************************/ void make_partisans(struct city *pcity) { + struct government *g = &governments[ get_government(pcity->owner) ]; int partisans; + if (num_role_units(L_PARTISAN)==0) return; if (!game.global_advances[A_GUERILLA] || pcity->original != pcity->owner) @@ -1551,8 +1553,7 @@ if (get_invention(city_owner(pcity), A_COMMUNISM) != TECH_KNOWN && get_invention(city_owner(pcity), A_GUNPOWDER) != TECH_KNOWN) return; - if (get_government(pcity->owner)!=G_DEMOCRACY - && get_government(pcity->owner)!=G_COMMUNISM) + if (! g->flags & INSPIRES_PARTISANS) return; partisans = myrand(1 + pcity->size/2) + 1; diff --exclude-from=../.diff_ignore -Nur freeciv-orig/server/unittools.c freeciv-local/server/unittools.c --- freeciv-orig/server/unittools.c Sat Jun 5 17:21:21 1999 +++ freeciv-local/server/unittools.c Tue Jun 8 16:51:10 1999 @@ -218,6 +218,7 @@ **************************************************************************/ int unit_bribe_cost(struct unit *punit) { + struct government *g = &governments[ get_government(punit->owner) ]; int cost; struct city *capital; int dist; @@ -229,8 +230,8 @@ dist=min(32, map_distance(capital->x, capital->y, punit->x, punit->y)); else dist=32; - if (get_government(punit->owner)==G_COMMUNISM) - dist = min(10, dist); + if (g->fixed_corruption_distance) + dist = min(g->fixed_corruption_distance, dist); cost=(cost/(dist+2))*(get_unit_type(punit->type)->build_cost/10); if (unit_flag(punit->type, F_SETTLERS)) cost/=2;