? rc ? msgfmt1.diff ? came_from.diff.txt ? diff ? remove_init.diff ? ok ? circle_iterate-3.diff ? new ? tmp_diff ? trailing_newline_remove1.diff.gz ? unit_move_turns1.diff ? short_worklists1.diff ? sound4.patch ? data/diff Index: common/game.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/game.c,v retrieving revision 1.113 diff -u -r1.113 game.c --- common/game.c 2001/11/23 17:27:07 1.113 +++ common/game.c 2001/12/09 15:32:55 @@ -678,6 +678,7 @@ game.cityfactor = GAME_DEFAULT_CITYFACTOR; game.citymindist = GAME_DEFAULT_CITYMINDIST; game.civilwarsize= GAME_DEFAULT_CIVILWARSIZE; + game.savepalace = GAME_DEFAULT_SAVEPALACE; game.unhappysize = GAME_DEFAULT_UNHAPPYSIZE; game.angrycitizen= GAME_DEFAULT_ANGRYCITIZEN; game.foodbox = GAME_DEFAULT_FOODBOX; Index: common/game.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/game.h,v retrieving revision 1.90 diff -u -r1.90 game.h --- common/game.h 2001/10/26 07:33:23 1.90 +++ common/game.h 2001/12/09 15:32:55 @@ -120,6 +120,7 @@ int aqueduct_size; int sewer_size; int add_to_size_limit; + int savepalace; int spacerace; int turnblock; int fixedlength; @@ -332,6 +333,10 @@ #define GAME_DEFAULT_CIVILWARSIZE 10 #define GAME_MIN_CIVILWARSIZE 6 #define GAME_MAX_CIVILWARSIZE 1000 + +#define GAME_MIN_SAVEPALACE 0 +#define GAME_MAX_SAVEPALACE 1 +#define GAME_DEFAULT_SAVEPALACE 1 #define GAME_DEFAULT_FOODBOX 10 #define GAME_MIN_FOODBOX 5 Index: server/citytools.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v retrieving revision 1.147 diff -u -r1.147 citytools.c --- server/citytools.c 2001/12/06 11:59:06 1.147 +++ server/citytools.c 2001/12/09 15:32:56 @@ -700,6 +700,37 @@ } } +/************************************************************************** +Create a palace in a random city. Used when the capital was conquered. +**************************************************************************/ +static void build_free_palace(struct player *pplayer, + const char *const old_capital_name) +{ + int size = city_list_size(&pplayer->cities); + struct city *pnew_capital; + + if (size == 0) { + /* The last city was removed or transfered to the enemy. R.I.P. */ + return; + } + + assert(find_palace(pplayer) == NULL); + + pnew_capital = city_list_get(&pplayer->cities, myrand(size)); + + city_add_improvement(pnew_capital, B_PALACE); + + /* + * send_player_cities will recalculate all cities and send them to + * the client. + */ + send_player_cities(pplayer); + + notify_player(pplayer, _("Game: You lost your capital %s. A new palace " + "was built in %s."), old_capital_name, + pnew_capital->name); +} + /********************************************************************** Handles all transactions in relation to transferring a city. @@ -715,6 +746,7 @@ struct unit_list old_city_units; struct player *pgiver = city_owner(pcity); int old_trade_routes[4]; + int had_palace = pcity->improvements[B_PALACE] != I_NONE; assert(pgiver != ptaker); @@ -840,6 +872,11 @@ get_nation_name_plural(pgiver->nation), pcity->name, pcity->x, pcity->y); + /* We can't end up without palace if savepalace is on. */ + if (had_palace && game.savepalace) { + build_free_palace(pgiver, pcity->name); + } + sync_cities(); return pcity; } @@ -994,6 +1031,8 @@ struct player *pplayer = city_owner(pcity); struct tile *ptile = map_get_tile(pcity->x, pcity->y); int i; + int had_palace = pcity->improvements[B_PALACE] != I_NONE; + char *city_name = strdup(pcity->name); gamelog(GAMELOG_LOSEC,"%s lose %s (%i,%i)", get_nation_name_plural(pplayer->nation), @@ -1108,6 +1147,11 @@ } } map_city_radius_iterate_end; } map_city_radius_iterate_end; + + if (had_palace && game.savepalace) { + build_free_palace(pplayer, city_name); + free(city_name); + } sync_cities(); } Index: server/savegame.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v retrieving revision 1.40 diff -u -r1.40 savegame.c --- server/savegame.c 2001/11/23 17:27:10 1.40 +++ server/savegame.c 2001/12/09 15:32:58 @@ -1808,6 +1808,8 @@ "game.aqueductloss"); game.killcitizen = secfile_lookup_int_default(file, game.killcitizen, "game.killcitizen"); + game.savepalace = secfile_lookup_int_default(file,game.savepalace, + "game.savepalace"); game.turnblock = secfile_lookup_int_default(file,game.turnblock, "game.turnblock"); game.fixedlength = secfile_lookup_int_default(file,game.fixedlength, @@ -2129,6 +2131,7 @@ secfile_insert_int(file, game.aqueductloss, "game.aqueductloss"); secfile_insert_int(file, game.killcitizen, "game.killcitizen"); secfile_insert_int(file, game.turnblock, "game.turnblock"); + secfile_insert_int(file, game.savepalace, "game.savepalace"); secfile_insert_int(file, game.fixedlength, "game.fixedlength"); secfile_insert_int(file, game.barbarianrate, "game.barbarians"); secfile_insert_int(file, game.onsetbarbarian, "game.onsetbarbs"); Index: server/stdinhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v retrieving revision 1.195 diff -u -r1.195 stdinhand.c --- server/stdinhand.c 2001/12/08 16:52:38 1.195 +++ server/stdinhand.c 2001/12/09 15:33:02 @@ -670,6 +670,14 @@ "and the player's capital is captured. If this option is set to " "the maximum value, civil wars are turned off altogether.") }, + { "savepalace", &game.savepalace, NULL, NULL, + SSET_RULES_FLEXIBLE, SSET_TO_CLIENT, + GAME_MIN_SAVEPALACE, GAME_MAX_SAVEPALACE, GAME_DEFAULT_SAVEPALACE, + N_("Rebuild palace if capital is conquered"), + N_("If this is set to 1 when the capital is conquered, palace is " + "automatically rebuilt for free in another randomly choosed " + "city, regardless on the knowledge of Masonry.") }, + /* Meta options: these don't affect the internal rules of the game, but * do affect players. Also options which only produce extra server * "output" and don't affect the actual game.