diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/client/civclient.c freeciv-local/client/civclient.c --- freeciv-orig/client/civclient.c Sat Jun 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 -N -u -r --exclude-from ../.diff_ignore 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 Sun Jun 13 21:20:02 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 Jun 12 10:49:57 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; @@ -706,7 +708,7 @@ if(pplayer==game.player_ptr && (pplayer->revolution < 1 || pplayer->revolution > 5) && - pplayer->government==G_ANARCHY && + pplayer->government==government_when_anarchy && (!game.player_ptr->ai.control || ai_popup_windows)) popup_government_dialog(); @@ -737,13 +739,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 +1050,66 @@ b->obsolete_by = p->obsolete_by; b->variant = p->variant; +} + +/************************************************************************** +... +**************************************************************************/ +void handle_ruleset_government(struct packet_ruleset_government *p) +{ + struct government *gov; + + if (p->id >= government_count) { + government_count = p->id + 1; + governments = fc_realloc (governments, government_count * sizeof (struct government)); + } + gov = &governments[p->id]; + + gov->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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 Sun Jun 6 17:34:24 1999 @@ -79,6 +79,7 @@ int spacerace; struct { char techs[MAX_LENGTH_NAME]; + char governments[MAX_LENGTH_NAME]; char units[MAX_LENGTH_NAME]; char buildings[MAX_LENGTH_NAME]; } ruleset; diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/government.c freeciv-local/common/government.c --- freeciv-orig/common/government.c Thu Jan 1 01:00:00 1970 +++ freeciv-local/common/government.c Sun Jun 13 21:25:39 1999 @@ -0,0 +1,46 @@ +/********************************************************************** + 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" + +/* TODO: + * o remove enum government_types + * o let the AI in on this + * o The government names are still hardcoded in the Xaw client, + * and it expects there to be _exactly_ G_LAST governments. + */ + +int government_count; +int default_government; +int government_when_anarchy; + +struct government *governments; + + +struct government *find_government_by_name(char *name) +{ + int i; + + for (i = 0; i < government_count; ++i) { + if (strcmp (governments[i].name, name) == 0) { + return &governments[i]; + } + } + + return NULL; +} + diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/government.h freeciv-local/common/government.h --- freeciv-orig/common/government.h Thu Jan 1 01:00:00 1970 +++ freeciv-local/common/government.h Sun Jun 13 20:51:04 1999 @@ -0,0 +1,135 @@ +/********************************************************************** + 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" +#include "limits.h" + +/* governements.ruleset anyone? -- SKi */ +enum government_type { + G_ANARCHY, + G_DESPOTISM, + G_MONARCHY, + G_COMMUNISM, +/* G_FUNDAMENTALISM, */ + G_REPUBLIC, + G_DEMOCRACY, + G_LAST +}; + +/* + * 42 is the magic constant here, it should be high enough that noone + * will be limited by it, right? -SKi + */ +/* speical values for extra_* fields -- SKi */ +#define NO_UPKEEP (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 int default_government; +extern int government_when_anarchy; +extern int government_count; + +extern struct government *governments; + +struct government *find_government_by_name (char *name); + +#endif diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/packets.c freeciv-local/common/packets.c --- freeciv-orig/common/packets.c Sat Jun 12 10:46:24 1999 +++ freeciv-local/common/packets.c Sat Jun 12 00:11:12 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); @@ -1732,6 +1736,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 -N -u -r --exclude-from ../.diff_ignore 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 Jun 12 00:10:52 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]; +}; + /********************************************************* ... @@ -672,6 +723,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 -N -u -r --exclude-from ../.diff_ignore 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 Jun 12 10:52:25 1999 @@ -20,6 +20,8 @@ #include #include #include +#include "government.h" +#include "log.h" extern int is_server; @@ -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."; + } } /*************************************************************** @@ -198,7 +215,7 @@ ***************************************************************/ int get_government_max_rate(enum government_type type) { - return government_rates[type]; + return governments[type].max_rate; } /*************************************************************** @@ -206,8 +223,8 @@ ***************************************************************/ int get_government_civil_war_prob(enum government_type type) { - if(type >= G_ANARCHY && type < G_LAST) - return government_civil_war[type]; + if(type >= 0 && type < government_count) + return governments[type].civil_war; return 0; } @@ -216,43 +233,26 @@ ***************************************************************/ char *get_government_name(enum government_type 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=default_government; plr->race=R_LAST; plr->capital=0; unit_list_init(&plr->units); diff -N -u -r --exclude-from ../.diff_ignore 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 Sun Jun 6 18:06:18 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, @@ -122,6 +119,7 @@ struct player { int player_no; char name[MAX_LENGTH_NAME]; + int is_male; enum government_type government; enum race_type race; int turn_done; @@ -149,12 +147,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 can_change_to_government(struct player *pplayer, int government); int get_government_max_rate(enum government_type type); int get_government_civil_war_prob(enum government_type type); char *get_government_name(enum government_type type); -char *get_ruler_title(enum government_type type); +char *get_ruler_title(enum government_type gov, int male, int race); +enum race_type find_race_by_name (char *name); char *get_race_name(enum race_type race); char *get_race_name_plural(enum race_type race); struct player_race *get_race(struct player *plr); diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/common/shared.h freeciv-local/common/shared.h --- freeciv-orig/common/shared.h Sat Jun 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" Binary files freeciv-orig/core and freeciv-local/core differ diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/data/civ1/governments.ruleset freeciv-local/data/civ1/governments.ruleset --- freeciv-orig/data/civ1/governments.ruleset Thu Jan 1 01:00:00 1970 +++ freeciv-local/data/civ1/governments.ruleset Sun Jun 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 -N -u -r --exclude-from ../.diff_ignore freeciv-orig/data/default/governments.ruleset freeciv-local/data/default/governments.ruleset --- freeciv-orig/data/default/governments.ruleset Thu Jan 1 01:00:00 1970 +++ freeciv-local/data/default/governments.ruleset Sun Jun 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 -N -u -r --exclude-from ../.diff_ignore 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 Sun Jun 13 20:58:05 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 = government_when_anarchy; pplayer->revolution = 1; cplayer->capital = 1; @@ -740,7 +749,7 @@ /* change the original player */ - pplayer->government = G_ANARCHY; + pplayer->government = 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 -N -u -r --exclude-from ../.diff_ignore 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 Sun Jun 13 20:29:06 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!= 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++; } @@ -425,7 +420,7 @@ { int gov = get_government(pcity->owner); - int content_mod = governments[gov].military_contentment_mod; + int content_mod = governments[gov].martial_law; int free_happy = governments[gov].free_happy; int free_shield = governments[gov].free_shield; @@ -466,11 +461,11 @@ if (! unit_being_aggressive (this_unit)) { 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)) { + /* effects of police station and womens sufferage (sp?) + * (ignored if it is a field unit) -- SKi */ + if ((happy_cost > 0) && + (improvement_variant(B_WOMENS) || city_got_effect (pcity, B_POLICE)) && + (! is_field_unit (this_unit))) { --happy_cost; } /* military units in home city can make unhappy citizens content -- SKi */ @@ -637,10 +632,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 +651,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 +1109,7 @@ break; } } - } else if( pplayer->government != G_ANARCHY ){ + } else if( pplayer->government != 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 +1207,7 @@ **************************************************************************/ void city_incite_cost(struct city *pcity) { - + struct government *g = &governments[ get_government(pcity->owner) ]; struct city *capital; int dist; @@ -1213,8 +1222,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 +1238,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 +1279,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 +1329,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 -N -u -r --exclude-from ../.diff_ignore freeciv-orig/server/plrhand.c freeciv-local/server/plrhand.c --- freeciv-orig/server/plrhand.c Sat Jun 5 17:31:45 1999 +++ freeciv-local/server/plrhand.c Tue Jun 8 16:45:29 1999 @@ -811,7 +811,7 @@ void handle_player_government(struct player *pplayer, struct packet_player_request *preq) { - if( pplayer->government!=G_ANARCHY || + if( pplayer->government!=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==government_when_anarchy)) return; pplayer->revolution=myrand(5)+1; - pplayer->government=G_ANARCHY; + pplayer->government=government_when_anarchy; notify_player(pplayer, "Game: The %s have incited a revolt!", races[pplayer->race].name); gamelog(GAMELOG_REVOLT,"The %s revolt!", diff -N -u -r --exclude-from ../.diff_ignore freeciv-orig/server/ruleset.c freeciv-local/server/ruleset.c --- freeciv-orig/server/ruleset.c Sat Jun 12 10:46:24 1999 +++ freeciv-local/server/ruleset.c Sun Jun 13 21:18:32 1999 @@ -15,6 +15,7 @@ #include #include +#include "mem.h" #include "game.h" #include "registry.h" #include "packets.h" @@ -37,10 +38,12 @@ char *description); static int match_name_from_list(char *name, char **list, int n_list); +static void load_ruleset_governments(char *ruleset_subdir); static void load_ruleset_techs(char *ruleset_subdir); static void load_ruleset_units(char *ruleset_subdir); static void load_ruleset_buildings(char *ruleset_subdir); +static void send_ruleset_governments(struct player *dest); static void send_ruleset_techs(struct player *dest); static void send_ruleset_units(struct player *dest); static void send_ruleset_buildings(struct player *dest); @@ -551,6 +554,256 @@ } /************************************************************************** +... +**************************************************************************/ +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 */ + + government_count = secfile_lookup_int (&file, "governments.count"); + if (government_count == 0) { + freelog (LOG_FATAL, "no governments!"); + exit (1); + } + governments = fc_calloc (government_count, sizeof (struct government)); + + /* first fill in government names so find_government_by_name will work -SKi */ + for(i = 0; i < government_count; i++) { + g = &governments[i]; + + /* get government name --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 */ + default_government = 1; + c = secfile_lookup_str_default (&file, NULL, "governments.default"); + if (c) { + default_government = find_government_by_name (c)->index; + } + + /* read government to use when in anarchy -- SKi */ + government_when_anarchy = 0; + c = secfile_lookup_str_default (&file, NULL, "governments.when_anarchy"); + if (c) { + 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 < 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 +896,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 < 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 +995,7 @@ } send_ruleset_techs(dest); + send_ruleset_governments(dest); send_ruleset_units(dest); send_ruleset_buildings(dest); diff -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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 -N -u -r --exclude-from ../.diff_ignore 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;