diff --exclude-from=../.diff_ignore -u -r -N freeciv-cvs/common/unit.h freeciv/common/unit.h --- freeciv-cvs/common/unit.h Sun May 2 20:21:08 1999 +++ freeciv/common/unit.h Wed Jun 2 22:41:37 1999 @@ -200,8 +200,14 @@ int firepower; int obsoleted_by; int fuel; + unsigned int flags; unsigned int roles; + + int happy_cost; /* unhappy people in home city */ + int shield_cost; /* normal upkeep cost */ + int food_cost; /* settler food cost */ + int gold_cost; /* gold upkeep (n/a now, maybe later) */ }; diff --exclude-from=../.diff_ignore -u -r -N freeciv-cvs/data/default/units.ruleset freeciv/data/default/units.ruleset --- freeciv-cvs/data/default/units.ruleset Fri Feb 12 19:39:40 1999 +++ freeciv/data/default/units.ruleset Wed Jun 2 23:00:49 1999 @@ -96,7 +96,7 @@ } ; Second table: -u2={ "name","graphics","move_type","build_cost","attack_strength","defense_strength","move_rate","vision_range","transport_capacity","hitpoints","firepower","fuel" +u2={ "name","graphics","move_type","build_cost","attack_strength","defense_strength","move_rate","vision_range","transport_capacity","hitpoints","firepower","fuel","uk_happy","uk_shield","uk_food","uk_gold" ; Name: should be the same as table 1. ; Move_type: 1=land, 2=sea, 3=heli, 4=air @@ -105,63 +105,64 @@ ; Fuel: 0=none, 1=end of turn, 2=end of 2nd turn ; Second table data: -; "Longname unit", g#, T, bc, at, de, mv, v, c, hp, f, u +; - upkeep - +; "Longname unit", g#, T, bc, at, de, mv, v, c, hp, f, u, H, S, F, G -"Settlers", 24, 1, 40, 0, 1, 1, 1, 0, 20, 1, 0 -"Engineers", 42, 1, 40, 0, 2, 2, 1, 0, 20, 1, 0 -"Warriors", 18, 1, 10, 1, 1, 1, 1, 0, 10, 1, 0 -"Phalanx", 21, 1, 20, 1, 2, 1, 1, 0, 10, 1, 0 -"Archers", 28, 1, 30, 3, 2, 1, 1, 0, 10, 1, 0 -"Legion", 16, 1, 40, 4, 2, 1, 1, 0, 10, 1, 0 -"Pikemen", 37, 1, 20, 1, 2, 1, 1, 0, 10, 1, 0 -"Musketeers", 19, 1, 30, 3, 3, 1, 1, 0, 20, 1, 0 -"Fanatics", 49, 1, 20, 4, 4, 1, 1, 0, 20, 1, 0 -"Partisan", 36, 1, 50, 4, 4, 1, 1, 0, 20, 1, 0 -"Alpine Troops", 45, 1, 50, 5, 5, 1, 1, 0, 20, 1, 0 -"Riflemen", 22, 1, 40, 5, 4, 1, 1, 0, 20, 1, 0 -"Marines", 40, 1, 60, 8, 5, 1, 1, 0, 20, 1, 0 -"Paratroopers", 0, 1, 60, 6, 4, 1, 1, 0, 20, 1, 0 -"Mech. Inf.", 17, 1, 50, 6, 6, 3, 1, 0, 30, 1, 0 -"Horsemen", 8, 1, 20, 2, 1, 2, 1, 0, 10, 1, 0 -"Chariot", 9, 1, 30, 3, 1, 2, 1, 0, 10, 1, 0 -"Elephants", 39, 1, 40, 4, 1, 2, 1, 0, 10, 1, 0 -"Crusaders", 38, 1, 40, 5, 1, 2, 1, 0, 10, 1, 0 -"Knights", 15, 1, 40, 4, 2, 2, 1, 0, 10, 1, 0 -"Dragoons", 32, 1, 50, 5, 2, 2, 1, 0, 20, 1, 0 -"Cavalry", 29, 1, 60, 8, 3, 2, 1, 0, 20, 1, 0 -"Armor", 0, 1, 80, 10, 5, 3, 1, 0, 30, 1, 0 -"Catapult", 7, 1, 40, 6, 1, 1, 1, 0, 10, 1, 0 -"Cannon", 4, 1, 40, 8, 1, 1, 1, 0, 20, 1, 0 -"Artillery", 43, 1, 50, 10, 1, 1, 1, 0, 20, 2, 0 -"Howitzer", 1, 1, 70, 12, 2, 2, 1, 0, 30, 2, 0 +"Settlers", 24, 1, 40, 0, 1, 1, 1, 0, 20, 1, 0, 0, 0, 1, 0 +"Engineers", 42, 1, 40, 0, 2, 2, 1, 0, 20, 1, 0, 0, 0, 1, 0 +"Warriors", 18, 1, 10, 1, 1, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Phalanx", 21, 1, 20, 1, 2, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Archers", 28, 1, 30, 3, 2, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Legion", 16, 1, 40, 4, 2, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Pikemen", 37, 1, 20, 1, 2, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Musketeers", 19, 1, 30, 3, 3, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Fanatics", 49, 1, 20, 4, 4, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Partisan", 36, 1, 50, 4, 4, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Alpine Troops", 45, 1, 50, 5, 5, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Riflemen", 22, 1, 40, 5, 4, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Marines", 40, 1, 60, 8, 5, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Paratroopers", 0, 1, 60, 6, 4, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Mech. Inf.", 17, 1, 50, 6, 6, 3, 1, 0, 30, 1, 0, 1, 1, 0, 0 +"Horsemen", 8, 1, 20, 2, 1, 2, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Chariot", 9, 1, 30, 3, 1, 2, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Elephants", 39, 1, 40, 4, 1, 2, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Crusaders", 38, 1, 40, 5, 1, 2, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Knights", 15, 1, 40, 4, 2, 2, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Dragoons", 32, 1, 50, 5, 2, 2, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Cavalry", 29, 1, 60, 8, 3, 2, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Armor", 0, 1, 80, 10, 5, 3, 1, 0, 30, 1, 0, 1, 1, 0, 0 +"Catapult", 7, 1, 40, 6, 1, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Cannon", 4, 1, 40, 8, 1, 1, 1, 0, 20, 1, 0, 1, 1, 0, 0 +"Artillery", 43, 1, 50, 10, 1, 1, 1, 0, 20, 2, 0, 1, 1, 0, 0 +"Howitzer", 1, 1, 70, 12, 2, 2, 1, 0, 30, 2, 0, 1, 1, 0, 0 ; Second table data, continued: ; "Longname unit", g#, T, bc, at, de, mv, v, c, hp, f, u -"Fighter", 12, 4, 60, 4, 3, 10, 2, 0, 20, 2, 1 -"Bomber", 3, 4, 120, 12, 1, 8, 2, 0, 20, 2, 2 -"Helicopter", 44, 3, 100, 10, 3, 6, 2, 0, 20, 2, 0 -"Stealth Fighter", 47, 4, 80, 8, 4, 14, 2, 0, 20, 2, 1 -"Stealth Bomber", 46, 4, 160, 14, 5, 12, 2, 0, 20, 2, 2 -"Trireme", 27, 2, 40, 1, 1, 3, 1, 2, 10, 1, 0 -"Caravel", 23, 2, 40, 2, 1, 3, 1, 3, 10, 1, 0 -"Galleon", 35, 2, 40, 0, 2, 4, 1, 4, 20, 1, 0 -"Frigate", 13, 2, 50, 4, 2, 4, 1, 2, 20, 1, 0 -"Ironclad", 14, 2, 60, 4, 4, 4, 1, 0, 30, 1, 0 -"Destroyer", 31, 2, 60, 4, 4, 6, 2, 0, 30, 1, 0 -"Cruiser", 10, 2, 80, 6, 6, 5, 2, 0, 30, 2, 0 -"AEGIS Cruiser", 48, 2, 100, 8, 8, 5, 2, 0, 30, 2, 0 -"Battleship", 2, 2, 160, 12, 12, 4, 2, 0, 40, 2, 0 -"Submarine", 25, 2, 60, 10, 2, 3, 2, 8, 30, 2, 0 -"Carrier", 6, 2, 160, 1, 9, 5, 2, 8, 40, 2, 0 -"Transport", 26, 2, 50, 0, 3, 5, 2, 8, 30, 1, 0 -"Cruise Missile", 30, 4, 60, 18, 0, 12, 1, 0, 10, 3, 1 -"Nuclear", 20, 4, 160, 99, 0, 16, 1, 0, 10, 1, 1 -"Diplomat", 11, 1, 30, 0, 0, 2, 1, 0, 10, 1, 0 -"Spy", 41, 1, 30, 0, 0, 3, 2, 0, 10, 1, 0 -"Caravan", 5, 1, 50, 0, 1, 1, 1, 0, 10, 1, 0 -"Freight", 34, 1, 50, 0, 1, 2, 1, 0, 10, 1, 0 -"Explorer", 33, 1, 30, 0, 1, 1, 1, 0, 10, 1, 0 +"Fighter", 12, 4, 60, 4, 3, 10, 2, 0, 20, 2, 1, 1, 1, 0, 0 +"Bomber", 3, 4, 120, 12, 1, 8, 2, 0, 20, 2, 2, 1, 1, 0, 0 +"Helicopter", 44, 3, 100, 10, 3, 6, 2, 0, 20, 2, 0, 1, 1, 0, 0 +"Stealth Fighter", 47, 4, 80, 8, 4, 14, 2, 0, 20, 2, 1, 1, 1, 0, 0 +"Stealth Bomber", 46, 4, 160, 14, 5, 12, 2, 0, 20, 2, 2, 1, 1, 0, 0 +"Trireme", 27, 2, 40, 1, 1, 3, 1, 2, 10, 1, 0, 1, 1, 0, 0 +"Caravel", 23, 2, 40, 2, 1, 3, 1, 3, 10, 1, 0, 1, 1, 0, 0 +"Galleon", 35, 2, 40, 0, 2, 4, 1, 4, 20, 1, 0, 1, 1, 0, 0 +"Frigate", 13, 2, 50, 4, 2, 4, 1, 2, 20, 1, 0, 1, 1, 0, 0 +"Ironclad", 14, 2, 60, 4, 4, 4, 1, 0, 30, 1, 0, 1, 1, 0, 0 +"Destroyer", 31, 2, 60, 4, 4, 6, 2, 0, 30, 1, 0, 1, 1, 0, 0 +"Cruiser", 10, 2, 80, 6, 6, 5, 2, 0, 30, 2, 0, 1, 1, 0, 0 +"AEGIS Cruiser", 48, 2, 100, 8, 8, 5, 2, 0, 30, 2, 0, 1, 1, 0, 0 +"Battleship", 2, 2, 160, 12, 12, 4, 2, 0, 40, 2, 0, 1, 1, 0, 0 +"Submarine", 25, 2, 60, 10, 2, 3, 2, 8, 30, 2, 0, 1, 1, 0, 0 +"Carrier", 6, 2, 160, 1, 9, 5, 2, 8, 40, 2, 0, 1, 1, 0, 0 +"Transport", 26, 2, 50, 0, 3, 5, 2, 8, 30, 1, 0, 1, 1, 0, 0 +"Cruise Missile", 30, 4, 60, 18, 0, 12, 1, 0, 10, 3, 1, 1, 1, 0, 0 +"Nuclear", 20, 4, 160, 99, 0, 16, 1, 0, 10, 1, 1, 1, 1, 0, 0 +"Diplomat", 11, 1, 30, 0, 0, 2, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Spy", 41, 1, 30, 0, 0, 3, 2, 0, 10, 1, 0, 1, 1, 0, 0 +"Caravan", 5, 1, 50, 0, 1, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Freight", 34, 1, 50, 0, 1, 2, 1, 0, 10, 1, 0, 1, 1, 0, 0 +"Explorer", 33, 1, 30, 0, 1, 1, 1, 0, 10, 1, 0, 1, 1, 0, 0 ; Second table data above: ; "Longname unit", g#, T, bc, at, de, mv, v, c, hp, f, u diff --exclude-from=../.diff_ignore -u -r -N freeciv-cvs/server/cityturn.c freeciv/server/cityturn.c --- freeciv-cvs/server/cityturn.c Mon May 24 18:56:14 1999 +++ freeciv/server/cityturn.c Fri Jun 4 01:55:47 1999 @@ -38,6 +38,7 @@ #include #include #include +#include extern signed short int minimap[MAP_MAX_WIDTH][MAP_MAX_HEIGHT]; @@ -392,24 +393,6 @@ } /************************************************************************** -... -**************************************************************************/ -void city_settlersupport(struct city *pcity) -{ - unit_list_iterate(pcity->units_supported, punit) { - if (unit_flag(punit->type, F_SETTLERS)) { - pcity->food_surplus--; - punit->upkeep=1; - if (get_government(pcity->owner)>=G_COMMUNISM) { - pcity->food_surplus--; - punit->upkeep=2; - } - } - } - unit_list_iterate_end; -} - -/************************************************************************** An "aggressive" unit is a unit which may cause unhappiness under a Republic or Democracy. A unit is *not* aggressive if one or more of following is true: @@ -436,99 +419,102 @@ /************************************************************************** ... **************************************************************************/ +#define extra_happy_cost governments[gov].extra_happy_cost +#define extra_shield_cost governments[gov].extra_shield_cost +#define extra_food_cost governments[gov].extra_food_cost +#define extra_gold_cost governments[gov].extra_gold_cost void city_support(struct city *pcity) { - int milunits=0; - int city_units=0; - int unhap=0; - int gov=get_government(pcity->owner); - int orig_suffrage_applies = (improvement_variant(B_WOMENS)==1 && - city_got_effect(pcity, B_POLICE)); - happy_copy(pcity, 2); - city_settlersupport(pcity); - unit_list_iterate(map_get_tile(pcity->x, pcity->y)->units, this_unit) { - if (is_military_unit(this_unit)) - city_units++; + int gov = get_government(pcity->owner); + + int content_mod = governments[gov].military_contentment_mod; + + int free_happy = governments[gov].free_happy; + int free_shield = governments[gov].free_shield; + int free_food = governments[gov].free_food; + int free_gold = governments[gov].free_gold; + + /* handle special values of free_* -- SKi */ + if (free_happy == CITY_SIZE_FREE) { + free_happy = pcity->size; } - unit_list_iterate_end; + if (free_shield == CITY_SIZE_FREE) { + free_shield = pcity->size; + } + if (free_food == CITY_SIZE_FREE) { + free_food = pcity->size; + } + if (free_gold == CITY_SIZE_FREE) { + free_gold = pcity->size; + } + + happy_copy(pcity, 2); + + /* loop units, subtracting appropriate amounts of food, shields, gold etc -- SKi */ unit_list_iterate(pcity->units_supported, this_unit) { - this_unit->unhappiness=0; - if (!unit_flag(this_unit->type, F_SETTLERS)) - this_unit->upkeep=0; - if (is_military_unit(this_unit)) { - milunits++; - switch (gov) { - case G_ANARCHY: - case G_DESPOTISM: - if (milunits>pcity->size) { - pcity->shield_surplus--; - this_unit->upkeep=1; - } - break; - case G_MONARCHY: - case G_COMMUNISM: - if (milunits>3) { - pcity->shield_surplus--; - this_unit->upkeep=1; - } - break; - case G_REPUBLIC: - pcity->shield_surplus--; - this_unit->upkeep=1; - if (!orig_suffrage_applies && (unit_being_aggressive(this_unit) - || is_field_unit(this_unit))) { - if (unhap) - this_unit->unhappiness=1; - unhap++; - } - break; - case G_DEMOCRACY: - pcity->shield_surplus--; - this_unit->upkeep=1; - if (unit_being_aggressive(this_unit)) { - this_unit->unhappiness=2; - } else if (is_field_unit(this_unit)) { - this_unit->unhappiness=1; - } - if (this_unit->unhappiness>0 && orig_suffrage_applies) { - this_unit->unhappiness--; - } - unhap += this_unit->unhappiness; - break; - default: - break; + struct unit_type *ut = &unit_types[this_unit->type]; + int happy_cost = extra_happy_cost == NO_UPKEEP ? 0 : ut->happy_cost + extra_happy_cost; + int shield_cost = extra_shield_cost == NO_UPKEEP ? 0 : ut->shield_cost + extra_shield_cost; + int food_cost = extra_food_cost == NO_UPKEEP ? 0 : ut->food_cost + extra_food_cost; + int gold_cost = extra_gold_cost == NO_UPKEEP ? 0 : ut->gold_cost + extra_gold_cost; + + /* no happy_cost for non agressive units -- SKi */ + 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)) { + --happy_cost; + } + /* military units in home city can make unhappy citizens content -- SKi */ + if (content_mod > 0 && pcity->ppl_unhappy[3] > 0 && + this_unit->x == pcity->x && this_unit->y == pcity->y) { + --content_mod; + --pcity->ppl_unhappy[3]; + ++pcity->ppl_content[3]; + } + + if (happy_cost > 0) { + if (free_happy) { + --free_happy; + } else { + citizen_happy_units (pcity, happy_cost); + } + } + if (shield_cost > 0) { + if (free_shield) { + --free_shield; + } else { + pcity->shield_surplus -= shield_cost; + } + } + if (food_cost > 0) { + if (free_food) { + --free_food; + } else { + pcity->food_surplus -= food_cost; + } + } + if (gold_cost > 0) { + if (free_gold) { + --free_gold; + } else { + /* hmmm... */ } - } + } + + this_unit->unhappiness = happy_cost > 0 ? happy_cost : 0; + this_unit->upkeep = shield_cost > 0 ? 1 : 0; } unit_list_iterate_end; - - switch (gov) { - case G_ANARCHY: - case G_DESPOTISM: - city_units = min(city_units, pcity->ppl_unhappy[3]); - pcity->ppl_unhappy[3]-= city_units; - pcity->ppl_content[3]+= city_units; - break; - case G_MONARCHY: - city_units = min(3, city_units); - city_units = min(pcity->ppl_unhappy[3], city_units); - pcity->ppl_unhappy[3]-= city_units; - pcity->ppl_content[3]+= city_units; - break; - case G_COMMUNISM: - city_units = min(3, city_units); - city_units = min(pcity->ppl_unhappy[3], city_units*2); - pcity->ppl_unhappy[3]-= city_units; - pcity->ppl_content[3]+= city_units; - break; - case G_REPUBLIC: - unhap--; - case G_DEMOCRACY: - citizen_happy_units(pcity, unhap); - } - } - +#undef extra_happy_cost +#undef extra_shield_cost +#undef extra_food_cost +#undef extra_gold_cost /************************************************************************** ... diff --exclude-from=../.diff_ignore -u -r -N freeciv-cvs/server/ruleset.c freeciv/server/ruleset.c --- freeciv-cvs/server/ruleset.c Wed Jun 2 22:23:09 1999 +++ freeciv/server/ruleset.c Wed Jun 2 23:04:04 1999 @@ -343,6 +343,11 @@ u->firepower = max_firepower; } u->fuel = secfile_lookup_int(&file,"%s.fuel", prefix); + /* upkeep costs */ + u->happy_cost = secfile_lookup_int (&file, "%s.uk_happy", prefix); + u->shield_cost = secfile_lookup_int (&file, "%s.uk_shield", prefix); + u->food_cost = secfile_lookup_int (&file, "%s.uk_food", prefix); + u->gold_cost = secfile_lookup_int (&file, "%s.uk_gold", prefix); } /* third block: flags */ @@ -429,6 +434,11 @@ u->name, unit_types[u->obsoleted_by].name, filename); u->obsoleted_by = -1; } +#ifdef 1 + if (u->flags & (F_NONMIL)) { + free_log (LOG_NORMAL, "Warning: unit_type %s uses obsolete flag F_NONMIL", u->name); + } +#endif } }