Index: client/packhand.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v retrieving revision 1.94 diff -u -w -r1.94 client//packhand.c --- cvs/client/packhand.c 1999/09/19 02:57:14 1.94 +++ local/client/packhand.c 1999/09/19 13:34:36 @@ -1064,6 +1064,7 @@ u->defense_strength = p->defense_strength; u->move_rate = p->move_rate; u->tech_requirement = p->tech_requirement; + u->gov_build_requirement = p->gov_build_requirement; u->vision_range = p->vision_range; u->transport_capacity = p->transport_capacity; u->hp = p->hp; @@ -1137,6 +1138,7 @@ **************************************************************************/ void handle_ruleset_government(struct packet_ruleset_government *p) { + int i; struct government *gov; if (p->id < 0 || p->id >= game.government_count) { @@ -1199,6 +1201,16 @@ gov->ruler_titles = fc_calloc(gov->num_ruler_titles, sizeof(struct ruler_title)); + + gov->special_units = fc_calloc (p->special_unit_count + 1, sizeof (struct special_unit)); + for (i=0; ispecial_unit_count; ++i) { + gov->special_units[i].unit_type_id = p->special_units[i].unit_type_id; + gov->special_units[i].happy_factor = p->special_units[i].happy_factor; + gov->special_units[i].shield_factor = p->special_units[i].shield_factor; + gov->special_units[i].food_factor = p->special_units[i].food_factor; + gov->special_units[i].gold_factor = p->special_units[i].gold_factor; + } + gov->special_units[i].unit_type_id = -1; tilespec_setup_government(p->id); } Index: common/city.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/city.c,v retrieving revision 1.58 diff -u -w -r1.58 common//city.c --- cvs/common/city.c 1999/09/15 09:09:27 1.58 +++ local/common/city.c 1999/09/19 13:34:36 @@ -444,6 +444,8 @@ return 0; if (get_invention(p,unit_types[id].tech_requirement)!=TECH_KNOWN) return 0; + if ((unit_types[id].gov_build_requirement != G_NO_GOVERNMENT) && (p->government != unit_types[id].gov_build_requirement)) + return 0; if (!is_terrain_near_tile(pcity->x, pcity->y, T_OCEAN) && is_water_unit(id)) return 0; return 1; @@ -461,6 +463,8 @@ if (unit_flag(id, F_NUCLEAR) && !game.global_wonders[B_MANHATTEN]) return 0; if (get_invention(p,unit_types[id].tech_requirement)!=TECH_KNOWN) + return 0; + if ((unit_types[id].gov_build_requirement != G_NO_GOVERNMENT) && (p->government != unit_types[id].gov_build_requirement)) return 0; return 1; } Index: common/government.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/government.c,v retrieving revision 1.11 diff -u -w -r1.11 common//government.c --- cvs/common/government.c 1999/09/19 02:52:33 1.11 +++ local/common/government.c 1999/09/19 13:34:36 @@ -42,8 +42,8 @@ /* * WISHLIST: * o Implement the features needed for fundamentalism: - * - Units that require a government to be built, and have special - * upkeep values under that government. (Fanatics). + * - The evil twin of gov_build_requirement for units (that would be + * gov_upkeep_requirement), neede for CTP mode. * - 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. Index: common/government.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/government.h,v retrieving revision 1.8 diff -u -w -r1.8 common//government.h --- cvs/common/government.h 1999/09/15 09:09:27 1.8 +++ local/common/government.h 1999/09/19 13:34:36 @@ -23,6 +23,8 @@ /* special values for free_* fields -- SKi */ #define G_CITY_SIZE_FREE G_MAGIC +/* used when no government applies -- SKi */ +#define G_NO_GOVERNMENT G_MAGIC enum government_flag_id { G_BUILD_VETERAN_DIPLOMAT=0, /* and Spies (in general: all F_DIPLOMAT) */ @@ -50,6 +52,23 @@ char female_title[MAX_LEN_NAME]; }; +/* struct for special unit abilities, upkeep costs, etc on a per government + * basis -SKi */ +struct special_unit +{ + /* id of unit type to which this applies -SKi */ + int unit_type_id; + + /* upkeep modifiers -SKi*/ + /* these currently overrule the government-wide factors, + * should they just modify them? -SKi */ + /* FIXME: only shild_cost_factor is implemented in utype_cost -SKi */ + int happy_factor; + int shield_factor; + int food_factor; + int gold_factor; +}; + /* This is struct government itself. All information about * a form of government is contained inhere. * -- SKi */ @@ -88,6 +107,10 @@ int free_shield; int free_food; int free_gold; + + /* list of units with special abilities, upkeep costs, etc under + * this government -SKi */ + struct special_unit *special_units; /* government production penalties -- SKi */ int trade_before_penalty; Index: common/packets.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v retrieving revision 1.70 diff -u -w -r1.70 common//packets.c --- cvs/common/packets.c 1999/09/19 02:57:16 1.70 +++ local/common/packets.c 1999/09/19 13:34:36 @@ -1980,6 +1980,7 @@ cptr=put_int8(cptr, packet->defense_strength); cptr=put_int8(cptr, packet->move_rate); cptr=put_int8(cptr, packet->tech_requirement); + cptr=put_int8(cptr, packet->gov_build_requirement); cptr=put_int8(cptr, packet->vision_range); cptr=put_int8(cptr, packet->transport_capacity); cptr=put_int8(cptr, packet->hp); @@ -2027,6 +2028,7 @@ iget_int8(&iter, &packet->defense_strength); iget_int8(&iter, &packet->move_rate); iget_int8(&iter, &packet->tech_requirement); + iget_int8(&iter, &packet->gov_build_requirement); iget_int8(&iter, &packet->vision_range); iget_int8(&iter, &packet->transport_capacity); iget_int8(&iter, &packet->hp); @@ -2339,10 +2341,14 @@ struct packet_ruleset_government *packet) { unsigned char buffer[MAX_LEN_PACKET], *cptr; + int i; + cptr=put_int8(buffer+2, PACKET_RULESET_GOVERNMENT); cptr=put_int8(cptr, packet->id); + cptr=put_string(cptr, packet->name); + cptr=put_int8(cptr, packet->required_tech); cptr=put_int8(cptr, packet->max_rate); cptr=put_int8(cptr, packet->civil_war); @@ -2361,6 +2367,15 @@ cptr=put_int8(cptr, packet->free_food); cptr=put_int8(cptr, packet->free_gold); + cptr=put_int8(cptr, packet->special_unit_count); + for (i=0; ispecial_unit_count; ++i) { + cptr=put_int8(cptr, packet->special_units[i].unit_type_id); + cptr=put_int8(cptr, packet->special_units[i].happy_factor); + cptr=put_int8(cptr, packet->special_units[i].shield_factor); + cptr=put_int8(cptr, packet->special_units[i].food_factor); + cptr=put_int8(cptr, packet->special_units[i].gold_factor); + } + cptr=put_int8(cptr, packet->trade_before_penalty); cptr=put_int8(cptr, packet->shields_before_penalty); cptr=put_int8(cptr, packet->food_before_penalty); @@ -2421,8 +2436,9 @@ receive_packet_ruleset_government(struct connection *pc) { struct pack_iter iter; - struct packet_ruleset_government *packet= - fc_calloc(1, sizeof(struct packet_ruleset_government)); + int pack_size = sizeof (struct packet_ruleset_government); + struct packet_ruleset_government *packet = fc_calloc(1, pack_size); + int i; pack_iter_init(&iter, pc); @@ -2446,6 +2462,18 @@ iget_int8(&iter, &packet->free_shield); iget_int8(&iter, &packet->free_food); iget_int8(&iter, &packet->free_gold); + + iget_int8(&iter, &packet->special_unit_count); + packet->special_units = (struct __packet_ruleset_government_special_unit *) ((char *) packet + pack_size); + pack_size += sizeof (struct __packet_ruleset_government_special_unit) * packet->special_unit_count; + packet = fc_realloc (packet, pack_size); + for (i=0; ispecial_unit_count; ++i) { + iget_int8 (&iter, &packet->special_units[i].unit_type_id); + iget_int8 (&iter, &packet->special_units[i].happy_factor); + iget_int8 (&iter, &packet->special_units[i].shield_factor); + iget_int8 (&iter, &packet->special_units[i].food_factor); + iget_int8 (&iter, &packet->special_units[i].gold_factor); + } iget_int8(&iter, &packet->trade_before_penalty); iget_int8(&iter, &packet->shields_before_penalty); Index: common/packets.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/packets.h,v retrieving revision 1.49 diff -u -w -r1.49 common//packets.h --- cvs/common/packets.h 1999/09/19 02:57:16 1.49 +++ local/common/packets.h 1999/09/19 13:34:37 @@ -474,6 +474,7 @@ int defense_strength; int move_rate; int tech_requirement; + int gov_build_requirement; int vision_range; int transport_capacity; int hp; @@ -561,6 +562,14 @@ int transform_time; }; +struct __packet_ruleset_government_special_unit { + int unit_type_id; + + int happy_factor; + int shield_factor; + int food_factor; + int gold_factor; +}; struct packet_ruleset_government { int id; @@ -612,6 +621,10 @@ char name[MAX_LEN_NAME]; char graphic_str[MAX_LEN_NAME]; char graphic_alt[MAX_LEN_NAME]; + + /* instead of a seperate packet these are sent "inline" -SKi */ + int special_unit_count; + struct __packet_ruleset_government_special_unit *special_units; }; struct packet_ruleset_government_ruler_title { int gov; Index: common/unit.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.c,v retrieving revision 1.63 diff -u -w -r1.63 common//unit.c --- cvs/common/unit.c 1999/09/12 16:01:27 1.63 +++ local/common/unit.c 1999/09/19 13:34:37 @@ -495,9 +495,27 @@ /************************************************************************** ... **************************************************************************/ +int utype_shield_factor(struct unit_type *ut, struct government *g) +{ + struct special_unit *g_units = g->special_units; + int i, cost_factor; + cost_factor = g->unit_shield_cost_factor; + for (i=0; g_units[i].unit_type_id != -1; ++i) { + /* Some schmuck decided to remove all forms of unique IDs in struct + * unit_type, this forces me into ugliness. -SKi */ + if (g_units[i].unit_type_id != find_unit_type_by_name(ut->name)) + continue; + cost_factor = g_units[i].shield_factor; + } + return cost_factor; +} + +/************************************************************************** +... +**************************************************************************/ int utype_shield_cost(struct unit_type *ut, struct government *g) { - return ut->shield_cost * g->unit_shield_cost_factor; + return ut->shield_cost * utype_shield_factor(ut,g); } /************************************************************************** Index: common/unit.h =================================================================== RCS file: /home/freeciv/CVS/freeciv/common/unit.h,v retrieving revision 1.37 diff -u -w -r1.37 common//unit.h --- cvs/common/unit.h 1999/09/19 02:48:13 1.37 +++ local/common/unit.h 1999/09/19 13:34:37 @@ -176,6 +176,7 @@ int defense_strength; int move_rate; int tech_requirement; + int gov_build_requirement; int vision_range; int transport_capacity; int hp; Index: data/civ1/units.ruleset =================================================================== RCS file: /home/freeciv/CVS/freeciv/data/civ1/units.ruleset,v retrieving revision 1.9 diff -u -w -r1.9 data/civ1//units.ruleset --- cvs/data/civ1/units.ruleset 1999/09/19 02:54:06 1.9 +++ local/data/civ1/units.ruleset 1999/09/19 13:34:37 @@ -70,6 +70,7 @@ name = _("Settlers") move_type = "Land" tech_req = "None" +gov_build_req = "None" obsolete_by = "None" graphic = "u.settlers" graphic_alt = "-" @@ -108,6 +109,7 @@ name = _("Engineers") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.engineers" graphic_alt = "-" @@ -131,6 +133,7 @@ name = _("Militia") ; Civ2 Warriors move_type = "Land" tech_req = "None" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.warriors" graphic_alt = "-" @@ -158,6 +161,7 @@ name = _("Phalanx") move_type = "Land" tech_req = "Bronze Working" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.phalanx" graphic_alt = "-" @@ -181,6 +185,7 @@ name = _("Archers") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.archers" graphic_alt = "-" @@ -204,6 +209,7 @@ name = _("Legion") move_type = "Land" tech_req = "Iron Working" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.legion" graphic_alt = "-" @@ -227,6 +233,7 @@ name = _("Pikemen") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.pikemen" graphic_alt = "-" @@ -250,6 +257,7 @@ name = _("Musketeers") move_type = "Land" tech_req = "Gunpowder" +gov_build_req = "None" obsolete_by = "Riflemen" graphic = "u.musketeers" graphic_alt = "-" @@ -273,6 +281,8 @@ name = _("Fanatics") move_type = "Land" tech_req = "Never" +gov_build_req = "None" +gov_build_req = "None" obsolete_by = "None" graphic = "u.fanatics" graphic_alt = "-" @@ -296,6 +306,7 @@ name = _("Partisan") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.partisan" graphic_alt = "-" @@ -342,6 +353,7 @@ name = _("Riflemen") move_type = "Land" tech_req = "Conscription" +gov_build_req = "None" obsolete_by = "None" graphic = "u.riflemen" graphic_alt = "-" @@ -365,6 +377,8 @@ name = _("Marines") move_type = "Land" tech_req = "Never" +gov_build_req = "None" +gov_build_req = "None" obsolete_by = "None" graphic = "u.marines" graphic_alt = "-" @@ -411,6 +425,7 @@ name = _("Mech. Inf.") move_type = "Land" tech_req = "Labor Union" +gov_build_req = "None" obsolete_by = "None" graphic = "u.mech_inf" graphic_alt = "-" @@ -439,6 +454,7 @@ name = _("Cavalry") ; Civ2 Horsemen move_type = "Land" tech_req = "Horseback Riding" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.horsemen" graphic_alt = "-" @@ -462,6 +478,7 @@ name = _("Chariot") move_type = "Land" tech_req = "The Wheel" +gov_build_req = "None" obsolete_by = "Knights" graphic = "u.chariot" graphic_alt = "-" @@ -485,6 +502,7 @@ name = _("Elephants") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Crusaders" graphic = "u.elephants" graphic_alt = "-" @@ -508,6 +526,7 @@ name = _("Crusaders") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Dragoons" graphic = "u.crusaders" graphic_alt = "-" @@ -531,6 +550,7 @@ name = _("Knights") move_type = "Land" tech_req = "Chivalry" +gov_build_req = "None" obsolete_by = "Armor" graphic = "u.knights" graphic_alt = "-" @@ -554,6 +574,7 @@ name = _("Dragoons") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Cavalry" graphic = "u.dragoons" graphic_alt = "-" @@ -577,6 +598,7 @@ name = "Civ2-Cavalry" ; no i18n move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Armor" graphic = "u.cavalry" graphic_alt = "-" @@ -600,6 +622,7 @@ name = _("Armor") move_type = "Land" tech_req = "Automobile" +gov_build_req = "None" obsolete_by = "None" graphic = "u.armor" graphic_alt = "-" @@ -623,6 +646,7 @@ name = _("Catapult") move_type = "Land" tech_req = "Mathematics" +gov_build_req = "None" obsolete_by = "Cannon" graphic = "u.catapult" graphic_alt = "-" @@ -646,6 +670,7 @@ name = _("Cannon") move_type = "Land" tech_req = "Metallurgy" +gov_build_req = "None" obsolete_by = "Artillery" graphic = "u.cannon" graphic_alt = "-" @@ -669,6 +694,7 @@ name = "Civ2-Artillery" ; no i18n move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Howitzer" graphic = "u.artillery" graphic_alt = "-" @@ -692,6 +718,7 @@ name = _("Artillery") ; Civ2 Howitzer move_type = "Land" tech_req = "Robotics" +gov_build_req = "None" obsolete_by = "None" graphic = "u.howitzer" graphic_alt = "-" @@ -715,6 +742,7 @@ name = _("Fighter") move_type = "Air" tech_req = "Flight" +gov_build_req = "None" obsolete_by = "None" graphic = "u.fighter" graphic_alt = "-" @@ -738,6 +766,7 @@ name = _("Bomber") move_type = "Air" tech_req = "Advanced Flight" +gov_build_req = "None" obsolete_by = "None" graphic = "u.bomber" graphic_alt = "-" @@ -761,6 +790,8 @@ name = _("Helicopter") move_type = "Heli" tech_req = "Never" +gov_build_req = "None" +gov_build_req = "None" obsolete_by = "None" graphic = "u.helicopter" graphic_alt = "-" @@ -784,6 +815,7 @@ name = _("Stealth Fighter") move_type = "Air" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.stealth_fighter" graphic_alt = "-" @@ -830,6 +862,7 @@ name = _("Trireme") move_type = "Sea" tech_req = "Map Making" +gov_build_req = "None" obsolete_by = "Sail" graphic = "u.trireme" graphic_alt = "-" @@ -853,6 +886,7 @@ name = _("Sail") ; Civ2 Caravel move_type = "Sea" tech_req = "Navigation" +gov_build_req = "None" obsolete_by = "Frigate" graphic = "u.caravel" graphic_alt = "-" @@ -876,6 +910,7 @@ name = _("Galleon") move_type = "Sea" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Transport" graphic = "u.galleon" graphic_alt = "-" @@ -899,6 +934,7 @@ name = _("Frigate") move_type = "Sea" tech_req = "Magnetism" +gov_build_req = "None" obsolete_by = "Transport" graphic = "u.frigate" graphic_alt = "-" @@ -922,6 +958,7 @@ name = _("Ironclad") move_type = "Sea" tech_req = "Steam Engine" +gov_build_req = "None" obsolete_by = "Cruiser" graphic = "u.ironclad" graphic_alt = "-" @@ -945,6 +982,7 @@ name = _("Destroyer") move_type = "Sea" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.destroyer" graphic_alt = "-" @@ -968,6 +1006,7 @@ name = _("Cruiser") move_type = "Sea" tech_req = "Combustion" +gov_build_req = "None" obsolete_by = "None" graphic = "u.cruiser" graphic_alt = "-" @@ -991,6 +1030,7 @@ name = _("AEGIS Cruiser") move_type = "Sea" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.aegis_cruiser" graphic_alt = "-" @@ -1014,6 +1054,7 @@ name = _("Battleship") move_type = "Sea" tech_req = "Steel" +gov_build_req = "None" obsolete_by = "None" graphic = "u.battleship" graphic_alt = "-" @@ -1037,6 +1078,7 @@ name = _("Submarine") move_type = "Sea" tech_req = "Mass Production" +gov_build_req = "None" obsolete_by = "None" graphic = "u.submarine" graphic_alt = "-" @@ -1067,6 +1109,7 @@ name = _("Carrier") move_type = "Sea" tech_req = "Advanced Flight" +gov_build_req = "None" obsolete_by = "None" graphic = "u.carrier" graphic_alt = "-" @@ -1095,6 +1138,7 @@ name = _("Transport") move_type = "Sea" tech_req = "Industrialization" +gov_build_req = "None" obsolete_by = "None" graphic = "u.transport" graphic_alt = "-" @@ -1118,6 +1162,7 @@ name = _("Cruise Missile") move_type = "Air" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.cruise_missile" graphic_alt = "-" @@ -1141,6 +1186,7 @@ name = _("Nuclear") move_type = "Air" tech_req = "Rocketry" +gov_build_req = "None" obsolete_by = "None" graphic = "u.nuclear" graphic_alt = "-" @@ -1183,6 +1229,7 @@ name = _("Diplomat") move_type = "Land" tech_req = "Writing" +gov_build_req = "None" obsolete_by = "None" graphic = "u.diplomat" graphic_alt = "-" @@ -1224,6 +1271,7 @@ name = _("Spy") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.spy" graphic_alt = "-" @@ -1247,6 +1295,7 @@ name = _("Caravan") move_type = "Land" tech_req = "Trade" +gov_build_req = "None" obsolete_by = "None" graphic = "u.caravan" graphic_alt = "-" @@ -1278,6 +1327,7 @@ name = _("Freight") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.freight" graphic_alt = "-" @@ -1301,6 +1351,7 @@ name = _("Explorer") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Partisan" graphic = "u.explorer" graphic_alt = "-" Index: data/civ2/governments.ruleset =================================================================== RCS file: /home/freeciv/CVS/freeciv/data/civ2/governments.ruleset,v retrieving revision 1.6 diff -u -w -r1.6 data/civ2//governments.ruleset --- cvs/data/civ2/governments.ruleset 1999/09/05 02:19:50 1.6 +++ local/data/civ2/governments.ruleset 1999/09/19 13:34:37 @@ -304,8 +304,8 @@ unit_free_unhappy = 0 unit_free_shield = 10 -unit_free_food = 0 -unit_free_gold = 0 +unit_free_food = 10 +unit_free_gold = 10 corruption_level = 100 corruption_modifier = 80 @@ -320,6 +320,10 @@ production_trade_penalty = 0, 0 production_shield_penalty = 0, 0 production_food_penalty = 0, 0 + +special_units = { "unit_type", "unhappy_factor", "shield_factor", "food_factor", "gold_factor" + "Fanatic", "0", "0", "0", "0" +}; ruler_titles = { "nation", "male_title", "female_title" "-", "High Priest", "High Priestess" Index: data/civ2/units.ruleset =================================================================== RCS file: /home/freeciv/CVS/freeciv/data/civ2/units.ruleset,v retrieving revision 1.10 diff -u -w -r1.10 data/civ2//units.ruleset --- cvs/data/civ2/units.ruleset 1999/09/19 02:54:06 1.10 +++ local/data/civ2/units.ruleset 1999/09/19 13:34:38 @@ -61,6 +61,7 @@ name = _("Settlers") move_type = "Land" tech_req = "None" +gov_build_req = "None" obsolete_by = "Engineers" graphic = "u.settlers" graphic_alt = "-" @@ -99,6 +100,7 @@ name = _("Engineers") move_type = "Land" tech_req = "Explosives" +gov_build_req = "None" obsolete_by = "None" graphic = "u.engineers" graphic_alt = "-" @@ -135,6 +137,7 @@ name = _("Warriors") move_type = "Land" tech_req = "None" +gov_build_req = "None" obsolete_by = "Pikemen" graphic = "u.warriors" graphic_alt = "-" @@ -162,6 +165,7 @@ name = _("Phalanx") move_type = "Land" tech_req = "Bronze Working" +gov_build_req = "None" obsolete_by = "Pikemen" graphic = "u.phalanx" graphic_alt = "-" @@ -185,6 +189,7 @@ name = _("Archers") move_type = "Land" tech_req = "Warrior Code" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.archers" graphic_alt = "-" @@ -208,6 +213,7 @@ name = _("Legion") move_type = "Land" tech_req = "Iron Working" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.legion" graphic_alt = "-" @@ -231,6 +237,7 @@ name = _("Pikemen") move_type = "Land" tech_req = "Feudalism" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.pikemen" graphic_alt = "-" @@ -254,6 +261,7 @@ name = _("Musketeers") move_type = "Land" tech_req = "Gunpowder" +gov_build_req = "None" obsolete_by = "Riflemen" graphic = "u.musketeers" graphic_alt = "-" @@ -277,6 +285,7 @@ name = _("Fanatics") move_type = "Land" tech_req = "Never" +gov_build_req = "Fundamentalism" obsolete_by = "None" graphic = "u.fanatics" graphic_alt = "-" @@ -300,6 +309,7 @@ name = _("Partisan") move_type = "Land" tech_req = "Guerilla Warfare" +gov_build_req = "None" obsolete_by = "None" graphic = "u.partisan" graphic_alt = "-" @@ -335,6 +345,7 @@ name = _("Alpine Troops") move_type = "Land" tech_req = "Tactics" +gov_build_req = "None" obsolete_by = "None" graphic = "u.alpine_troops" graphic_alt = "-" @@ -358,6 +369,7 @@ name = _("Riflemen") move_type = "Land" tech_req = "Conscription" +gov_build_req = "None" obsolete_by = "None" graphic = "u.riflemen" graphic_alt = "-" @@ -381,6 +393,7 @@ name = _("Marines") move_type = "Land" tech_req = "Amphibious Warfare" +gov_build_req = "None" obsolete_by = "None" graphic = "u.marines" graphic_alt = "-" @@ -404,6 +417,7 @@ name = _("Paratroopers") move_type = "Land" tech_req = "Combined Arms" +gov_build_req = "None" obsolete_by = "None" graphic = "u.paratroopers" graphic_alt = "-" @@ -429,6 +443,7 @@ name = _("Mech. Inf.") move_type = "Land" tech_req = "Labor Union" +gov_build_req = "None" obsolete_by = "None" graphic = "u.mech_inf" graphic_alt = "-" @@ -457,6 +472,7 @@ name = _("Horsemen") move_type = "Land" tech_req = "Horseback Riding" +gov_build_req = "None" obsolete_by = "Knights" graphic = "u.horsemen" graphic_alt = "-" @@ -480,6 +496,7 @@ name = _("Chariot") move_type = "Land" tech_req = "The Wheel" +gov_build_req = "None" obsolete_by = "Knights" graphic = "u.chariot" graphic_alt = "-" @@ -503,6 +520,7 @@ name = _("Elephants") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Crusaders" graphic = "u.elephants" graphic_alt = "-" @@ -526,6 +544,7 @@ name = _("Crusaders") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Dragoons" graphic = "u.crusaders" graphic_alt = "-" @@ -549,6 +568,7 @@ name = _("Knights") move_type = "Land" tech_req = "Chivalry" +gov_build_req = "None" obsolete_by = "Dragoons" graphic = "u.knights" graphic_alt = "-" @@ -572,6 +592,7 @@ name = _("Dragoons") move_type = "Land" tech_req = "Leadership" +gov_build_req = "None" obsolete_by = "Cavalry" graphic = "u.dragoons" graphic_alt = "-" @@ -595,6 +616,7 @@ name = _("Cavalry") move_type = "Land" tech_req = "Tactics" +gov_build_req = "None" obsolete_by = "Armor" graphic = "u.cavalry" graphic_alt = "-" @@ -618,6 +640,7 @@ name = _("Armor") move_type = "Land" tech_req = "Mobile Warfare" +gov_build_req = "None" obsolete_by = "None" graphic = "u.armor" graphic_alt = "-" @@ -641,6 +664,7 @@ name = _("Catapult") move_type = "Land" tech_req = "Mathematics" +gov_build_req = "None" obsolete_by = "Cannon" graphic = "u.catapult" graphic_alt = "-" @@ -664,6 +688,7 @@ name = _("Cannon") move_type = "Land" tech_req = "Metallurgy" +gov_build_req = "None" obsolete_by = "Artillery" graphic = "u.cannon" graphic_alt = "-" @@ -687,6 +712,7 @@ name = _("Artillery") move_type = "Land" tech_req = "Machine Tools" +gov_build_req = "None" obsolete_by = "Howitzer" graphic = "u.artillery" graphic_alt = "-" @@ -710,6 +736,7 @@ name = _("Howitzer") move_type = "Land" tech_req = "Robotics" +gov_build_req = "None" obsolete_by = "None" graphic = "u.howitzer" graphic_alt = "-" @@ -733,6 +760,7 @@ name = _("Fighter") move_type = "Air" tech_req = "Flight" +gov_build_req = "None" obsolete_by = "Stealth Fighter" graphic = "u.fighter" graphic_alt = "-" @@ -756,6 +784,7 @@ name = _("Bomber") move_type = "Air" tech_req = "Advanced Flight" +gov_build_req = "None" obsolete_by = "Stealth Bomber" graphic = "u.bomber" graphic_alt = "-" @@ -779,6 +808,7 @@ name = _("Helicopter") move_type = "Heli" tech_req = "Combined Arms" +gov_build_req = "None" obsolete_by = "None" graphic = "u.helicopter" graphic_alt = "-" @@ -808,6 +838,8 @@ name = _("Stealth Fighter") move_type = "Air" tech_req = "Stealth" +gov_build_req = "None" +gov_build_req = "None" obsolete_by = "None" graphic = "u.stealth_fighter" graphic_alt = "-" @@ -862,6 +894,7 @@ name = _("Trireme") move_type = "Sea" tech_req = "Map Making" +gov_build_req = "None" obsolete_by = "Caravel" graphic = "u.trireme" graphic_alt = "-" @@ -885,6 +918,7 @@ name = _("Caravel") move_type = "Sea" tech_req = "Navigation" +gov_build_req = "None" obsolete_by = "Galleon" graphic = "u.caravel" graphic_alt = "-" @@ -908,6 +942,7 @@ name = _("Galleon") move_type = "Sea" tech_req = "Magnetism" +gov_build_req = "None" obsolete_by = "Transport" graphic = "u.galleon" graphic_alt = "-" @@ -931,6 +966,7 @@ name = _("Frigate") move_type = "Sea" tech_req = "Magnetism" +gov_build_req = "None" obsolete_by = "Ironclad" graphic = "u.frigate" graphic_alt = "-" @@ -954,6 +990,7 @@ name = _("Ironclad") move_type = "Sea" tech_req = "Steam Engine" +gov_build_req = "None" obsolete_by = "Destroyer" graphic = "u.ironclad" graphic_alt = "-" @@ -977,6 +1014,7 @@ name = _("Destroyer") move_type = "Sea" tech_req = "Electricity" +gov_build_req = "None" obsolete_by = "None" graphic = "u.destroyer" graphic_alt = "-" @@ -1004,6 +1042,7 @@ name = _("Cruiser") move_type = "Sea" tech_req = "Steel" +gov_build_req = "None" obsolete_by = "AEGIS Cruiser" graphic = "u.cruiser" graphic_alt = "-" @@ -1027,6 +1066,7 @@ name = _("AEGIS Cruiser") move_type = "Sea" tech_req = "Rocketry" +gov_build_req = "None" obsolete_by = "None" graphic = "u.aegis_cruiser" graphic_alt = "-" @@ -1050,6 +1090,7 @@ name = _("Battleship") move_type = "Sea" tech_req = "Automobile" +gov_build_req = "None" obsolete_by = "None" graphic = "u.battleship" graphic_alt = "-" @@ -1073,6 +1114,7 @@ name = _("Submarine") move_type = "Sea" tech_req = "Combustion" +gov_build_req = "None" obsolete_by = "None" graphic = "u.submarine" graphic_alt = "-" @@ -1103,6 +1145,7 @@ name = _("Carrier") move_type = "Sea" tech_req = "Advanced Flight" +gov_build_req = "None" obsolete_by = "None" graphic = "u.carrier" graphic_alt = "-" @@ -1131,6 +1174,7 @@ name = _("Transport") move_type = "Sea" tech_req = "Industrialization" +gov_build_req = "None" obsolete_by = "None" graphic = "u.transport" graphic_alt = "-" @@ -1154,6 +1198,7 @@ name = _("Cruise Missile") move_type = "Air" tech_req = "Rocketry" +gov_build_req = "None" obsolete_by = "None" graphic = "u.cruise_missile" graphic_alt = "-" @@ -1181,6 +1226,7 @@ name = _("Nuclear") move_type = "Air" tech_req = "Rocketry" +gov_build_req = "None" obsolete_by = "None" graphic = "u.nuclear" graphic_alt = "-" @@ -1223,6 +1269,7 @@ name = _("Diplomat") move_type = "Land" tech_req = "Writing" +gov_build_req = "None" obsolete_by = "Spy" graphic = "u.diplomat" graphic_alt = "-" @@ -1264,6 +1311,7 @@ name = _("Spy") move_type = "Land" tech_req = "Espionage" +gov_build_req = "None" obsolete_by = "None" graphic = "u.spy" graphic_alt = "-" @@ -1306,6 +1354,7 @@ name = _("Caravan") move_type = "Land" tech_req = "Trade" +gov_build_req = "None" obsolete_by = "Freight" graphic = "u.caravan" graphic_alt = "-" @@ -1337,6 +1386,7 @@ name = _("Freight") move_type = "Land" tech_req = "The Corporation" +gov_build_req = "None" obsolete_by = "None" graphic = "u.freight" graphic_alt = "-" @@ -1363,6 +1413,7 @@ name = _("Explorer") move_type = "Land" tech_req = "Seafaring" +gov_build_req = "None" obsolete_by = "Partisan" graphic = "u.explorer" graphic_alt = "-" Index: data/default/governments.ruleset =================================================================== RCS file: /home/freeciv/CVS/freeciv/data/default/governments.ruleset,v retrieving revision 1.6 diff -u -w -r1.6 data/default//governments.ruleset --- cvs/data/default/governments.ruleset 1999/09/05 02:19:51 1.6 +++ local/data/default/governments.ruleset 1999/09/19 13:34:38 @@ -108,7 +108,8 @@ unit_unhappy_factor = 0 unit_shield_factor = 1 unit_food_factor = 1 -unit_gold_factor = 0 ; ?? +unit_gold_factor = 0 ; under anarchy all money stop moving (no income, no expenses) + ; if I remeber Civ2 correclty -SKi unit_free_unhappy = 0 unit_free_shield = "City_Size" Index: data/default/units.ruleset =================================================================== RCS file: /home/freeciv/CVS/freeciv/data/default/units.ruleset,v retrieving revision 1.13 diff -u -w -r1.13 data/default//units.ruleset --- cvs/data/default/units.ruleset 1999/09/19 02:54:07 1.13 +++ local/data/default/units.ruleset 1999/09/19 13:34:38 @@ -42,6 +42,7 @@ ; for no alternate graphic. ; tech_req = required advance, names from techs.ruleset, or special: ; "None" => available from start; "Never" => never available +; gov_build_req = only form of government that can support this unit, or "None" ; obsolete_by = another unit name ; move_type = "Land" or "Sea" or "Air" or "Heli" ; transport_cap = Number of units (ground, or air/missiles, depending on flags) @@ -61,6 +62,7 @@ name = _("Settlers") move_type = "Land" tech_req = "None" +gov_build_req = "None" obsolete_by = "Engineers" graphic = "u.settlers" graphic_alt = "-" @@ -99,6 +101,7 @@ name = _("Engineers") move_type = "Land" tech_req = "Explosives" +gov_build_req = "None" obsolete_by = "None" graphic = "u.engineers" graphic_alt = "-" @@ -135,6 +138,7 @@ name = _("Warriors") move_type = "Land" tech_req = "None" +gov_build_req = "None" obsolete_by = "Pikemen" graphic = "u.warriors" graphic_alt = "-" @@ -162,6 +166,7 @@ name = _("Phalanx") move_type = "Land" tech_req = "Bronze Working" +gov_build_req = "None" obsolete_by = "Pikemen" graphic = "u.phalanx" graphic_alt = "-" @@ -185,6 +190,7 @@ name = _("Archers") move_type = "Land" tech_req = "Warrior Code" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.archers" graphic_alt = "-" @@ -208,6 +214,7 @@ name = _("Legion") move_type = "Land" tech_req = "Iron Working" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.legion" graphic_alt = "-" @@ -231,6 +238,7 @@ name = _("Pikemen") move_type = "Land" tech_req = "Feudalism" +gov_build_req = "None" obsolete_by = "Musketeers" graphic = "u.pikemen" graphic_alt = "-" @@ -254,6 +262,7 @@ name = _("Musketeers") move_type = "Land" tech_req = "Gunpowder" +gov_build_req = "None" obsolete_by = "Riflemen" graphic = "u.musketeers" graphic_alt = "-" @@ -277,6 +286,7 @@ name = _("Fanatics") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "None" graphic = "u.fanatics" graphic_alt = "-" @@ -300,6 +310,7 @@ name = _("Partisan") move_type = "Land" tech_req = "Guerilla Warfare" +gov_build_req = "None" obsolete_by = "None" graphic = "u.partisan" graphic_alt = "-" @@ -335,6 +346,7 @@ name = _("Alpine Troops") move_type = "Land" tech_req = "Tactics" +gov_build_req = "None" obsolete_by = "None" graphic = "u.alpine_troops" graphic_alt = "-" @@ -358,6 +370,7 @@ name = _("Riflemen") move_type = "Land" tech_req = "Conscription" +gov_build_req = "None" obsolete_by = "None" graphic = "u.riflemen" graphic_alt = "-" @@ -381,6 +394,7 @@ name = _("Marines") move_type = "Land" tech_req = "Amphibious Warfare" +gov_build_req = "None" obsolete_by = "None" graphic = "u.marines" graphic_alt = "-" @@ -404,6 +418,7 @@ name = _("Paratroopers") move_type = "Land" tech_req = "Combined Arms" +gov_build_req = "None" obsolete_by = "None" graphic = "u.paratroopers" graphic_alt = "-" @@ -429,6 +444,7 @@ name = _("Mech. Inf.") move_type = "Land" tech_req = "Labor Union" +gov_build_req = "None" obsolete_by = "None" graphic = "u.mech_inf" graphic_alt = "-" @@ -457,6 +473,7 @@ name = _("Horsemen") move_type = "Land" tech_req = "Horseback Riding" +gov_build_req = "None" obsolete_by = "Knights" graphic = "u.horsemen" graphic_alt = "-" @@ -480,6 +497,7 @@ name = _("Chariot") move_type = "Land" tech_req = "The Wheel" +gov_build_req = "None" obsolete_by = "Knights" graphic = "u.chariot" graphic_alt = "-" @@ -503,6 +521,7 @@ name = _("Elephants") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Crusaders" graphic = "u.elephants" graphic_alt = "-" @@ -526,6 +545,7 @@ name = _("Crusaders") move_type = "Land" tech_req = "Never" +gov_build_req = "None" obsolete_by = "Dragoons" graphic = "u.crusaders" graphic_alt = "-" @@ -549,6 +569,7 @@ name = _("Knights") move_type = "Land" tech_req = "Chivalry" +gov_build_req = "None" obsolete_by = "Dragoons" graphic = "u.knights" graphic_alt = "-" @@ -572,6 +593,7 @@ name = _("Dragoons") move_type = "Land" tech_req = "Leadership" +gov_build_req = "None" obsolete_by = "Cavalry" graphic = "u.dragoons" graphic_alt = "-" @@ -595,6 +617,7 @@ name = _("Cavalry") move_type = "Land" tech_req = "Tactics" +gov_build_req = "None" obsolete_by = "Armor" graphic = "u.cavalry" graphic_alt = "-" @@ -618,6 +641,7 @@ name = _("Armor") move_type = "Land" tech_req = "Mobile Warfare" +gov_build_req = "None" obsolete_by = "None" graphic = "u.armor" graphic_alt = "-" @@ -641,6 +665,7 @@ name = _("Catapult") move_type = "Land" tech_req = "Mathematics" +gov_build_req = "None" obsolete_by = "Cannon" graphic = "u.catapult" graphic_alt = "-" @@ -664,6 +689,7 @@ name = _("Cannon") move_type = "Land" tech_req = "Metallurgy" +gov_build_req = "None" obsolete_by = "Artillery" graphic = "u.cannon" graphic_alt = "-" @@ -687,6 +713,7 @@ name = _("Artillery") move_type = "Land" tech_req = "Machine Tools" +gov_build_req = "None" obsolete_by = "Howitzer" graphic = "u.artillery" graphic_alt = "-" @@ -710,6 +737,7 @@ name = _("Howitzer") move_type = "Land" tech_req = "Robotics" +gov_build_req = "None" obsolete_by = "None" graphic = "u.howitzer" graphic_alt = "-" @@ -733,6 +761,7 @@ name = _("Fighter") move_type = "Air" tech_req = "Flight" +gov_build_req = "None" obsolete_by = "Stealth Fighter" graphic = "u.fighter" graphic_alt = "-" @@ -756,6 +785,7 @@ name = _("Bomber") move_type = "Air" tech_req = "Advanced Flight" +gov_build_req = "None" obsolete_by = "Stealth Bomber" graphic = "u.bomber" graphic_alt = "-" @@ -779,6 +809,7 @@ name = _("Helicopter") move_type = "Heli" tech_req = "Combined Arms" +gov_build_req = "None" obsolete_by = "None" graphic = "u.helicopter" graphic_alt = "-" @@ -808,6 +839,8 @@ name = _("Stealth Fighter") move_type = "Air" tech_req = "Stealth" +gov_build_req = "None" +gov_build_req = "None" obsolete_by = "None" graphic = "u.stealth_fighter" graphic_alt = "-" @@ -862,6 +895,7 @@ name = _("Trireme") move_type = "Sea" tech_req = "Map Making" +gov_build_req = "None" obsolete_by = "Caravel" graphic = "u.trireme" graphic_alt = "-" @@ -885,6 +919,7 @@ name = _("Caravel") move_type = "Sea" tech_req = "Navigation" +gov_build_req = "None" obsolete_by = "Galleon" graphic = "u.caravel" graphic_alt = "-" @@ -908,6 +943,7 @@ name = _("Galleon") move_type = "Sea" tech_req = "Magnetism" +gov_build_req = "None" obsolete_by = "Transport" graphic = "u.galleon" graphic_alt = "-" @@ -931,6 +967,7 @@ name = _("Frigate") move_type = "Sea" tech_req = "Magnetism" +gov_build_req = "None" obsolete_by = "Ironclad" graphic = "u.frigate" graphic_alt = "-" @@ -954,6 +991,7 @@ name = _("Ironclad") move_type = "Sea" tech_req = "Steam Engine" +gov_build_req = "None" obsolete_by = "Destroyer" graphic = "u.ironclad" graphic_alt = "-" @@ -977,6 +1015,7 @@ name = _("Destroyer") move_type = "Sea" tech_req = "Electricity" +gov_build_req = "None" obsolete_by = "None" graphic = "u.destroyer" graphic_alt = "-" @@ -1004,6 +1043,7 @@ name = _("Cruiser") move_type = "Sea" tech_req = "Steel" +gov_build_req = "None" obsolete_by = "AEGIS Cruiser" graphic = "u.cruiser" graphic_alt = "-" @@ -1027,6 +1067,7 @@ name = _("AEGIS Cruiser") move_type = "Sea" tech_req = "Rocketry" +gov_build_req = "None" obsolete_by = "None" graphic = "u.aegis_cruiser" graphic_alt = "-" @@ -1050,6 +1091,7 @@ name = _("Battleship") move_type = "Sea" tech_req = "Automobile" +gov_build_req = "None" obsolete_by = "None" graphic = "u.battleship" graphic_alt = "-" @@ -1073,6 +1115,7 @@ name = _("Submarine") move_type = "Sea" tech_req = "Combustion" +gov_build_req = "None" obsolete_by = "None" graphic = "u.submarine" graphic_alt = "-" @@ -1103,6 +1146,7 @@ name = _("Carrier") move_type = "Sea" tech_req = "Advanced Flight" +gov_build_req = "None" obsolete_by = "None" graphic = "u.carrier" graphic_alt = "-" @@ -1131,6 +1175,7 @@ name = _("Transport") move_type = "Sea" tech_req = "Industrialization" +gov_build_req = "None" obsolete_by = "None" graphic = "u.transport" graphic_alt = "-" @@ -1154,6 +1199,8 @@ name = _("Cruise Missile") move_type = "Air" tech_req = "Rocketry" +gov_build_req = "None" +gov_build_req = "None" obsolete_by = "None" graphic = "u.cruise_missile" graphic_alt = "-" @@ -1223,6 +1270,7 @@ name = _("Diplomat") move_type = "Land" tech_req = "Writing" +gov_build_req = "None" obsolete_by = "Spy" graphic = "u.diplomat" graphic_alt = "-" @@ -1264,6 +1312,7 @@ name = _("Spy") move_type = "Land" tech_req = "Espionage" +gov_build_req = "None" obsolete_by = "None" graphic = "u.spy" graphic_alt = "-" @@ -1306,6 +1355,7 @@ name = _("Caravan") move_type = "Land" tech_req = "Trade" +gov_build_req = "None" obsolete_by = "Freight" graphic = "u.caravan" graphic_alt = "-" @@ -1337,6 +1387,7 @@ name = _("Freight") move_type = "Land" tech_req = "The Corporation" +gov_build_req = "None" obsolete_by = "None" graphic = "u.freight" graphic_alt = "-" @@ -1363,6 +1414,7 @@ name = _("Explorer") move_type = "Land" tech_req = "Seafaring" +gov_build_req = "None" obsolete_by = "Partisan" graphic = "u.explorer" graphic_alt = "-" Index: server/cityturn.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v retrieving revision 1.76 diff -u -w -r1.76 server//cityturn.c --- cvs/server/cityturn.c 1999/09/19 02:52:33 1.76 +++ local/server/cityturn.c 1999/09/19 13:34:38 @@ -444,6 +444,12 @@ * P.S. This list is by no means complete. * --SKi */ + /* + * The special_units per government upkeep is implemented so + * that it completely overrides the other government-specific + * upkeep modifiers (extra_*_cost). + * -SKi + */ /* military units in this city (need _not_ be home city) can make unhappy citizens content Index: server/ruleset.c =================================================================== RCS file: /home/freeciv/CVS/freeciv/server/ruleset.c,v retrieving revision 1.30 diff -u -w -r1.30 server//ruleset.c --- cvs/server/ruleset.c 1999/09/19 02:57:20 1.30 +++ local/server/ruleset.c 1999/09/19 13:34:39 @@ -40,6 +40,9 @@ static int lookup_tech(struct section_file *file, char *prefix, char *entry, int required, char *filename, char *description); +static int lookup_gov(struct section_file *file, char *prefix, + char *entry, int required, char *filename, + char *description); static char *lookup_helptext(struct section_file *file, char *prefix); static enum tile_terrain_type lookup_terrain(char *name, int this); @@ -48,7 +51,8 @@ static void load_ruleset_units(char *ruleset_subdir); static void load_ruleset_buildings(char *ruleset_subdir); static void load_ruleset_terrain(char *ruleset_subdir); -static void load_ruleset_governments(char *ruleset_subdir); +static void load_ruleset_governments_before_units(char *ruleset_subdir); +static void load_ruleset_governments_after_units (char *ruleset_subdir); static void load_ruleset_nations(char *ruleset_subdir); static void send_ruleset_techs(struct player *dest); @@ -301,6 +305,39 @@ return NULL; } +/************************************************************************** + Lookup a string prefix.entry in the file and return the corresponding + advances id. If (!required), return A_LAST if match "None" or can't match. + If (required), die if can't match. + If description is not NULL, it is used in the warning message + instead of prefix (eg pass unit->name instead of prefix="units2.u27") +**************************************************************************/ +static int lookup_gov(struct section_file *file, char *prefix, + char *entry, int required, char *filename, + char *description) +{ + char *sval; + struct government *g; + + sval = secfile_lookup_str(file, "%s.%s", prefix, entry); + if (!required && strcmp(sval, "None")==0) { + return G_NO_GOVERNMENT; + } else { + g = find_government_by_name (sval); + if (g == NULL) { + freelog((required ? LOG_FATAL : LOG_NORMAL), + "for %s %s couldn't match government \"%s\" (%s)", + (description ? description : prefix), entry, sval, filename); + if (required) { + exit(1); + } + } else { + return g->index; + } + } + return G_NO_GOVERNMENT; +} + #ifdef UNUSED /************************************************************************** Return the index of the name in the list, or -1 @@ -512,6 +549,11 @@ } for( i=0; igov_build_requirement = lookup_gov(file, sec[i], "gov_build_req", + 0, filename, u->name); + } + for( i=0; iobsoleted_by = lookup_unit_type(file, sec[i], "obsolete_by", 0, filename, u->name); @@ -916,14 +958,13 @@ /************************************************************************** ... **************************************************************************/ -static void load_ruleset_governments(char *ruleset_subdir) +static void load_ruleset_governments_before_units(char *ruleset_subdir) { struct section_file file; char *filename, *datafile_options; struct government *g = NULL; - int i, j, nval; - char *c; - char **sec, **slist; + int i, nval; + char **sec; filename = openload_ruleset_file(&file, ruleset_subdir, "governments"); datafile_options @@ -959,6 +1000,43 @@ game.government_when_anarchy = lookup_government(&file, "governments.when_anarchy", filename); + section_file_free(&file); +} +static void load_ruleset_governments_after_units (char *ruleset_subdir) +{ + struct section_file file; + char *filename, *datafile_options; + struct government *g = NULL; + int i, j, nval; + char *c; + char **sec, **slist; + + filename = openload_ruleset_file(&file, ruleset_subdir, "governments"); + datafile_options + = check_ruleset_capabilities(&file, "+1.8.2 +tilespec +nontab", filename); + section_file_lookup(&file,"datafile.description"); /* unused */ + + sec = secfile_get_secnames_prefix(&file, "government_", &nval); + if (nval == 0) { + freelog(LOG_FATAL, "No governments!? (%s)", filename); + exit(1); + } else if(nval > G_MAGIC) { + /* upper limit is really about 255 for 8-bit id values, but + use G_MAGIC elsewhere as a sanity check, and should be plenty + big enough --dwp */ + freelog(LOG_FATAL, "Too many governments! (%d, max %d; %s)", + nval, G_MAGIC, filename); + exit(1); + } + + /* touch upon the previously read (in load_ruleset_governments_before_units), + * so section_file_check_unused won't complain. -SKi */ + for(i = 0; i < game.government_count; i++) { + secfile_lookup_str(&file, "%s.name", sec[i]); + } + lookup_government(&file, "governments.default", filename); + lookup_government(&file, "governments.when_anarchy", filename); + /* Because player_init is called before rulesets are loaded we set * all players governments here, if they have not been previously * set (eg by loading game). @@ -1176,6 +1254,39 @@ ai_gov_tech_hints[j].tech = A_LAST; } + /* get special unit abilites -- SKi */ + for (i = 0; i < game.government_count; ++i) { + int special_units = 0; + struct special_unit t_last = { -1, 0, 0, 0, 0 }; + g = &governments[i]; + + j = -1; + while((c = secfile_lookup_str_default(&file, NULL, + "%s.special_units%d.unit_type", + sec[i], ++j))) { + struct special_unit t; + + /* t.unit_type_id */ + if ((t.unit_type_id = find_unit_type_by_name (c)) == U_LAST) { + freelog (LOG_FATAL, "special unit %s has unknown unit_type %s", g->name, c); + exit (1); + } + c = secfile_lookup_str (&file, "%s.special_units%d.unhappy_factor", sec[i], j); + t.happy_factor = atoi (c); + c = secfile_lookup_str (&file, "%s.special_units%d.shield_factor", sec[i], j); + t.shield_factor = atoi (c); + c = secfile_lookup_str (&file, "%s.special_units%d.food_factor", sec[i], j); + t.food_factor = atoi (c); + c = secfile_lookup_str (&file, "%s.special_units%d.gold_factor", sec[i], j); + t.gold_factor = atoi (c); + + g->special_units = fc_realloc (g->special_units, ++special_units * sizeof (struct special_unit)); + g->special_units[special_units-1] = t; + } + g->special_units = fc_realloc (g->special_units, (special_units + 1) * sizeof (struct special_unit)); + g->special_units[special_units] = t_last; + } + section_file_check_unused(&file, filename); section_file_free(&file); } @@ -1413,6 +1524,7 @@ packet.defense_strength = u->defense_strength; packet.move_rate = u->move_rate; packet.tech_requirement = u->tech_requirement; + packet.gov_build_requirement = u->gov_build_requirement; packet.vision_range = u->vision_range; packet.transport_capacity = u->transport_capacity; packet.hp = u->hp / game.firepower_factor; @@ -1572,12 +1684,15 @@ struct government *g; int i, j, to; + bzero ((void *) &gov, sizeof (gov)); for (i = 0; i < game.government_count; ++i) { g = &governments[i]; /* send one packet_government */ gov.id = i; + strcpy (gov.name, g->name); + gov.required_tech = g->required_tech; gov.max_rate = g->max_rate; gov.civil_war = g->civil_war; @@ -1622,6 +1737,9 @@ gov.hints = g->hints; gov.num_ruler_titles = g->num_ruler_titles; + /* FIXME? */ + gov.special_unit_count = 0; + strcpy(gov.name, g->name); strcpy(gov.graphic_str, g->graphic_str); strcpy(gov.graphic_alt, g->graphic_alt); @@ -1689,8 +1807,9 @@ freelog(LOG_NORMAL, "Loading rulesets"); load_ruleset_techs(game.ruleset.techs); load_ruleset_nations(game.ruleset.nations); - load_ruleset_governments(game.ruleset.governments); + load_ruleset_governments_before_units(game.ruleset.governments); load_ruleset_units(game.ruleset.units); + load_ruleset_governments_after_units(game.ruleset.governments); load_ruleset_buildings(game.ruleset.buildings); load_ruleset_terrain(game.ruleset.terrain); init_nation_goals();