diff common/capstr.c common/capstr.c --- common/capstr.c Tue Jul 25 21:18:17 2000 +++ common/capstr.c Wed Jul 26 20:25:46 2000 @@ -71,7 +71,8 @@ */ #define CAPABILITY "+1.11 diplomat_investigate_fix production_change_fix" \ -" game_ruleset nuclear_fallout land_channel_requirement" +" game_ruleset nuclear_fallout land_channel_requirement" \ +" cont_unavailable_units" /* "+1.11" is protocol for 1.11.0 stable release. @@ -91,6 +92,8 @@ "land_channel_requirement" extends the protocol for the requirement of a minimum number of ocean tiles adjacent to a land tile wished to be changed to ocean. + + "cont_unavailable_units" FIXME */ void init_our_capability(void) diff common/game.h common/game.h --- common/game.h Tue Jul 25 21:18:18 2000 +++ common/game.h Wed Jul 26 20:25:48 2000 @@ -48,6 +48,8 @@ #define CONTAMINATION_POLLUTION 1 #define CONTAMINATION_FALLOUT 2 +#define CONT_UNIT_FOREVER -1 + struct civ_game { int is_new_game; /* 1 for games never started */ int version; @@ -160,6 +162,7 @@ int hut_overflight; int pillage_select; int nuke_contamination; + int cont_unavailable_units; } rgame; char demography[MAX_LEN_DEMOGRAPHY]; diff common/packets.c common/packets.c --- common/packets.c Wed Jul 26 19:40:00 2000 +++ common/packets.c Wed Jul 26 20:25:47 2000 @@ -3427,6 +3427,9 @@ if (pc && has_capability("nuclear_fallout", pc->capability)) { cptr=put_uint8(cptr, packet->nuke_contamination); } +if (pc && has_capability("cont_unavailable_units", pc->capability)) { + cptr=put_sint16(cptr, packet->cont_unavailable_units); +} put_uint16(buffer, cptr-buffer); return send_connection_data(pc, buffer, cptr-buffer); @@ -3455,6 +3458,11 @@ iget_uint8(&iter, &packet->nuke_contamination); } else { packet->nuke_contamination = CONTAMINATION_POLLUTION; +} +if (pc && has_capability("cont_unavailable_units", pc->capability)) { + iget_sint16(&iter, &packet->cont_unavailable_units); +} else { + packet->cont_unavailable_units = CONT_UNIT_FOREVER; } pack_iter_end(&iter, pc); diff common/packets.h common/packets.h --- common/packets.h Tue Jul 25 21:18:21 2000 +++ common/packets.h Wed Jul 26 20:25:46 2000 @@ -726,6 +726,7 @@ int hut_overflight; int pillage_select; int nuke_contamination; + int cont_unavailable_units; }; /********************************************************* diff data/civ1/game.ruleset data/civ1/game.ruleset --- data/civ1/game.ruleset Mon Jul 10 04:48:07 2000 +++ data/civ1/game.ruleset Wed Jul 26 20:27:00 2000 @@ -38,3 +38,9 @@ ; "Pollution" - Pollution (same as industrial/population-generated). ; "Fallout" - Nuclear Fallout (distinct from industrial/population). nuke_contamination = "Pollution" + +; Can city continue unit building if its conqueror does not have required tech. +; 0 - Production must be changed immediately. +; 1 - City can make one unit. +; "Forever" - City can continue producing units forever. +cont_unavailable_units = "Forever" diff data/civ2/game.ruleset data/civ2/game.ruleset --- data/civ2/game.ruleset Mon Jul 10 04:48:08 2000 +++ data/civ2/game.ruleset Wed Jul 26 20:27:02 2000 @@ -38,3 +38,9 @@ ; "Pollution" - Pollution (same as industrial/population-generated). ; "Fallout" - Nuclear Fallout (distinct from industrial/population). nuke_contamination = "Pollution" + +; Can city continue unit building if its conqueror does not have required tech. +; 0 - Production must be changed immediately. +; 1 - City can make one unit. +; "Forever" - City can continue producing units forever. +cont_unavailable_units = "Forever" diff data/default/game.ruleset data/default/game.ruleset --- data/default/game.ruleset Mon Jul 10 04:48:10 2000 +++ data/default/game.ruleset Wed Jul 26 20:44:21 2000 @@ -38,3 +38,9 @@ ; "Pollution" - Pollution (same as industrial/population-generated). ; "Fallout" - Nuclear Fallout (distinct from industrial/population). nuke_contamination = "Fallout" + +; Can city continue unit building if its conqueror does not have required tech. +; 0 - Production must be changed immediately. +; 1 - City can make one unit. +; "Forever" - City can continue producing units forever. +cont_unavailable_units = "Forever" diff server/cityturn.c server/cityturn.c --- server/cityturn.c Tue Jul 25 21:18:35 2000 +++ server/cityturn.c Wed Jul 26 20:25:45 2000 @@ -77,6 +77,7 @@ static void upgrade_building_prod(struct city *pcity); static Unit_Type_id unit_upgrades_to(struct city *pcity, Unit_Type_id id); static void upgrade_unit_prod(struct city *pcity); +static void change_production_from_unavailable(struct city *pcity); static void obsolete_building_test(struct city *pcity, int b1, int b2); static void pay_for_buildings(struct player *pplayer, struct city *pcity); @@ -1340,6 +1341,13 @@ upgrade_unit_prod(pcity); + if(get_invention(pplayer, + unit_types[pcity->currently_building].tech_requirement) + != TECH_KNOWN && game.rgame.cont_unavailable_units == 0) + { + change_production_from_unavailable(pcity); + } + /* FIXME: F_CITIES should be changed to any unit * that 'contains' 1 (or more) pop -- sjolie */ @@ -1385,9 +1393,16 @@ If there's nothing there, worklist_change_build_target won't do anything. */ worklist_change_build_target(pplayer, pcity); + if (pcity->is_building_unit && + get_invention(pplayer, + unit_types[pcity->currently_building].tech_requirement)!= + TECH_KNOWN && game.rgame.cont_unavailable_units != CONT_UNIT_FOREVER) + { + change_production_from_unavailable(pcity); + } - gamelog(GAMELOG_UNIT, "%s build %s in %s (%i,%i)", + gamelog(GAMELOG_UNIT, "%s build %s in %s (%i,%i)", get_nation_name_plural(pplayer->nation), unit_types[pcity->currently_building].name, pcity->name, pcity->x, pcity->y); @@ -1396,6 +1411,23 @@ } } return 1; +} + +/************************************************************************** +... +**************************************************************************/ +static void change_production_from_unavailable(struct city *pcity) +{ + Unit_Type_id old_prod; + + old_prod = pcity->currently_building; + pcity->currently_building=best_role_unit(pcity, L_FIRSTBUILD); + notify_player_ex(&game.players[pcity->owner], pcity->x, pcity->y, + E_UNIT_UPGRADED, + _("Game: %s cant build %s. It is building %s instead."), + pcity->name, + get_unit_type(old_prod)->name, + get_unit_type(pcity->currently_building)->name); } /************************************************************************** diff server/ruleset.c server/ruleset.c --- server/ruleset.c Thu Jul 13 17:45:40 2000 +++ server/ruleset.c Wed Jul 26 20:32:43 2000 @@ -1943,6 +1943,18 @@ game.rgame.nuke_contamination = CONTAMINATION_POLLUTION; } + sval = secfile_lookup_str_int(&file, &game.rgame.cont_unavailable_units, + "civstyle.cont_unavailable_units" ); + if (sval != 0) { + if (mystrcasecmp(sval, "Forever") == 0) { + game.rgame.cont_unavailable_units = CONT_UNIT_FOREVER; + } else { + freelog(LOG_NORMAL, _("Bad value %s for cont_unavailable_units. Using " + "\"Forever\"."), sval); + game.rgame.cont_unavailable_units = CONT_UNIT_FOREVER; + } + } + section_file_check_unused(&file, filename); section_file_free(&file); } @@ -2293,6 +2305,7 @@ misc_p.hut_overflight = game.rgame.hut_overflight; misc_p.pillage_select = game.rgame.pillage_select; misc_p.nuke_contamination = game.rgame.nuke_contamination; + misc_p.cont_unavailable_units = game.rgame.cont_unavailable_units; for(to = 0; to < game.nplayers; to++) { /* dests */ if(dest==0 || get_player(to)==dest) {