| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Freeciv
Revision: 15189
Author: cazfi
Date: 01 Sep 2008 17:39:22
Changes:Made number of base types adjustable. Max number of base types is now 32.
See #40469
Files:| ... | ...@@ -122,7 +122,7 @@ | |
| 122 | 122 | struct unit_order { |
| 123 | 123 | enum unit_orders order; |
| 124 | 124 | enum unit_activity activity; /* Only valid for ORDER_ACTIVITY. */ |
| 125 | enum base_type_id base; /* Only valid for activity ACTIVITY_BASE */ | |
| 125 | Base_type_id base; /* Only valid for activity ACTIVITY_BASE */ | |
| 126 | 126 | enum direction8 dir; /* Only valid for ORDER_MOVE. */ |
| 127 | 127 | }; |
| 128 | 128 | |
| ... | ...@@ -149,7 +149,7 @@ | |
| 149 | 149 | int activity_count; |
| 150 | 150 | |
| 151 | 151 | enum tile_special_type activity_target; |
| 152 | enum base_type_id activity_base; | |
| 152 | Base_type_id activity_base; | |
| 153 | 153 | enum unit_focus_status focus_status; |
| 154 | 154 | int ord_map, ord_city; |
| 155 | 155 | /* ord_map and ord_city are the order index of this unit in tile.units |
| ... | ...@@ -240,20 +240,20 @@ | |
| 240 | 240 | bool can_unit_do_activity_targeted(const struct unit *punit, |
| 241 | 241 | enum unit_activity activity, |
| 242 | 242 | enum tile_special_type target, |
| 243 | enum base_type_id base); | |
| 243 | Base_type_id base); | |
| 244 | 244 | bool can_unit_do_activity_targeted_at(const struct unit *punit, |
| 245 | 245 | enum unit_activity activity, |
| 246 | 246 | enum tile_special_type target, |
| 247 | 247 | const struct tile *ptile, |
| 248 | enum base_type_id base); | |
| 248 | Base_type_id base); | |
| 249 | 249 | bool can_unit_do_activity_base(const struct unit *punit, |
| 250 | enum base_type_id base); | |
| 250 | Base_type_id base); | |
| 251 | 251 | void set_unit_activity(struct unit *punit, enum unit_activity new_activity); |
| 252 | 252 | void set_unit_activity_targeted(struct unit *punit, |
| 253 | 253 | enum unit_activity new_activity, |
| 254 | 254 | enum tile_special_type new_target); |
| 255 | 255 | void set_unit_activity_base(struct unit *punit, |
| 256 | enum base_type_id base); | |
| 256 | Base_type_id base); | |
| 257 | 257 | int get_activity_rate(const struct unit *punit); |
| 258 | 258 | int get_activity_rate_this_turn(const struct unit *punit); |
| 259 | 259 | int get_turns_for_activity_at(const struct unit *punit, |
| ... | ...@@ -651,8 +651,7 @@ | |
| 651 | 651 | food = 2 |
| 652 | 652 | # arctic (seals => walrus). |
| 653 | 653 | |
| 654 | ; Exactly two base types: | |
| 655 | ; [fortress] and [airbase]. | |
| 654 | ; Base types: | |
| 656 | 655 | ; |
| 657 | 656 | ; name = Name of the base type. |
| 658 | 657 | ; buildable = Can base be built? Defaults to true |
| ... | ...@@ -672,7 +671,7 @@ | |
| 672 | 671 | ; - "DiplomatDefense" = Diplomats inside get bonus to diplomatic defense |
| 673 | 672 | ; - "ParadropFrom" = Paradrop can be initiated from base |
| 674 | 673 | |
| 675 | [fortress] | |
| 674 | [base_fortress] | |
| 676 | 675 | name = _("Fortress") |
| 677 | 676 | graphic = "base.fortress" |
| 678 | 677 | graphic_alt = "-" |
| ... | ...@@ -688,20 +687,3 @@ | |
| 688 | 687 | native_to = "Land" |
| 689 | 688 | flags = "NoAggressive", "DefenseBonus", "ClaimTerritory", |
| 690 | 689 | "NoStackDeath", "DiplomatDefense" |
| 691 | ||
| 692 | [airbase] | |
| 693 | name = _("Airbase") | |
| 694 | buildable = 0 | |
| 695 | graphic = "base.airbase" | |
| 696 | graphic_alt = "-" | |
| 697 | activity_gfx = "unit.airbase" | |
| 698 | reqs = | |
| 699 | { "type", "name", "range" | |
| 700 | "Tech", "Advanced Flight", "Player" | |
| 701 | "TerrainClass", "Land", "Local" | |
| 702 | "UnitFlag", "Airbase", "Local" | |
| 703 | } | |
| 704 | gui_type = "Airbase" | |
| 705 | build_time = 3 | |
| 706 | native_to = "Air", "Missile" | |
| 707 | flags = "NoStackDeath", "DiplomatDefense", "ParadropFrom" |
| ... | ...@@ -65,7 +65,7 @@ | |
| 65 | 65 | enum unit_activity new_activity, |
| 66 | 66 | enum tile_special_type new_target); |
| 67 | 67 | static void unit_activity_handling_base(struct unit *punit, |
| 68 | enum base_type_id base); | |
| 68 | Base_type_id base); | |
| 69 | 69 | static bool base_handle_unit_establish_trade(struct player *pplayer, int unit_id, struct city *pcity_dest); |
| 70 | 70 | static bool unit_bombard(struct unit *punit, struct tile *ptile); |
| 71 | 71 | |
| ... | ...@@ -612,7 +612,7 @@ | |
| 612 | 612 | void handle_unit_change_activity(struct player *pplayer, int unit_id, |
| 613 | 613 | enum unit_activity activity, |
| 614 | 614 | enum tile_special_type activity_target, |
| 615 | enum base_type_id activity_base) | |
| 615 | Base_type_id activity_base) | |
| 616 | 616 | { |
| 617 | 617 | struct unit *punit = player_find_unit_by_id(pplayer, unit_id); |
| 618 | 618 | |
| ... | ...@@ -1705,14 +1705,14 @@ | |
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | /************************************************************************** |
| 1708 | ... | |
| 1708 | Handle request for targeted activity. | |
| 1709 | 1709 | **************************************************************************/ |
| 1710 | 1710 | static void unit_activity_handling_targeted(struct unit *punit, |
| 1711 | 1711 | enum unit_activity new_activity, |
| 1712 | 1712 | enum tile_special_type new_target) |
| 1713 | 1713 | { |
| 1714 | 1714 | if (can_unit_do_activity_targeted(punit, new_activity, new_target, |
| 1715 | BASE_LAST)) { | |
| 1715 | -1)) { | |
| 1716 | 1716 | enum unit_activity old_activity = punit->activity; |
| 1717 | 1717 | enum tile_special_type old_target = punit->activity_target; |
| 1718 | 1718 | |
| ... | ...@@ -1724,10 +1724,10 @@ | |
| 1724 | 1724 | } |
| 1725 | 1725 | |
| 1726 | 1726 | /************************************************************************** |
| 1727 | ... | |
| 1727 | Handle request for military base building. | |
| 1728 | 1728 | **************************************************************************/ |
| 1729 | 1729 | static void unit_activity_handling_base(struct unit *punit, |
| 1730 | enum base_type_id base) | |
| 1730 | Base_type_id base) | |
| 1731 | 1731 | { |
| 1732 | 1732 | if (can_unit_do_activity_base(punit, base)) { |
| 1733 | 1733 | enum unit_activity old_activity = punit->activity; |
| ... | ...@@ -766,8 +766,7 @@ | |
| 766 | 766 | shield = 3 |
| 767 | 767 | # desert-only, special processing, see savegame map_load(). |
| 768 | 768 | |
| 769 | ; Exactly two base types: | |
| 770 | ; [fortress] and [airbase]. | |
| 769 | ; Base types: | |
| 771 | 770 | ; |
| 772 | 771 | ; name = Name of the base type. |
| 773 | 772 | ; buildable = Can base be built? Defaults to true |
| ... | ...@@ -787,7 +786,7 @@ | |
| 787 | 786 | ; - "DiplomatDefense" = Diplomats inside get bonus to diplomatic defense |
| 788 | 787 | ; - "ParadropFrom" = Paradrop can be initiated from base |
| 789 | 788 | |
| 790 | [fortress] | |
| 789 | [base_fortress] | |
| 791 | 790 | name = _("Fortress") |
| 792 | 791 | graphic = "base.fortress" |
| 793 | 792 | graphic_alt = "-" |
| ... | ...@@ -804,7 +803,7 @@ | |
| 804 | 803 | flags = "NoAggressive", "DefenseBonus", "ClaimTerritory", |
| 805 | 804 | "NoStackDeath", "DiplomatDefense" |
| 806 | 805 | |
| 807 | [airbase] | |
| 806 | [base_airbase] | |
| 808 | 807 | name = _("Airbase") |
| 809 | 808 | graphic = "base.airbase" |
| 810 | 809 | graphic_alt = "-" |
| ... | ...@@ -331,7 +331,7 @@ | |
| 331 | 331 | Time to complete the given activity on the given tile. |
| 332 | 332 | ****************************************************************************/ |
| 333 | 333 | int tile_activity_base_time(const struct tile *ptile, |
| 334 | enum base_type_id base) | |
| 334 | Base_type_id base) | |
| 335 | 335 | { |
| 336 | 336 | return base_by_number(base)->build_time * ACTIVITY_FACTOR; |
| 337 | 337 | } |
| ... | ...@@ -256,7 +256,7 @@ | |
| 256 | 256 | Handle a request to change the military base at one or more than one tile. |
| 257 | 257 | ****************************************************************************/ |
| 258 | 258 | void handle_edit_tile_base(struct connection *pc, int x, int y, |
| 259 | enum base_type_id id, bool remove, int size) | |
| 259 | Base_type_id id, bool remove, int size) | |
| 260 | 260 | { |
| 261 | 261 | struct tile *ptile_center; |
| 262 | 262 | struct base_type *pbase; |
| ... | ...@@ -287,7 +287,7 @@ | |
| 287 | 287 | *middleground, |
| 288 | 288 | *foreground, |
| 289 | 289 | *activity; |
| 290 | } bases[BASE_LAST]; | |
| 290 | } bases[MAX_BASE_TYPES]; | |
| 291 | 291 | struct { |
| 292 | 292 | struct sprite |
| 293 | 293 | *main[EDGE_COUNT], |
| ... | ...@@ -5231,7 +5231,7 @@ | |
| 5231 | 5231 | |
| 5232 | 5232 | index = base_index(pbase); |
| 5233 | 5233 | |
| 5234 | if (!(0 <= index && index < BASE_LAST)) { | |
| 5234 | if (!(0 <= index && index < game.control.num_base_types)) { | |
| 5235 | 5235 | return 0; |
| 5236 | 5236 | } |
| 5237 | 5237 |
| ... | ...@@ -2452,7 +2452,7 @@ | |
| 2452 | 2452 | VALIDATE(num_unit_types, U_LAST, "unit types"); |
| 2453 | 2453 | VALIDATE(num_impr_types, B_LAST, "improvements"); |
| 2454 | 2454 | VALIDATE(num_tech_types, A_LAST_REAL, "advances"); |
| 2455 | VALIDATE(num_base_types, BASE_LAST, "bases"); | |
| 2455 | VALIDATE(num_base_types, MAX_BASE_TYPES, "bases"); | |
| 2456 | 2456 | |
| 2457 | 2457 | VALIDATE(government_count, MAX_NUM_ITEMS, "governments"); |
| 2458 | 2458 | VALIDATE(nation_count, MAX_NUM_ITEMS, "nations"); |
| ... | ...@@ -62,6 +62,7 @@ | |
| 62 | 62 | #define NATION_GROUP_SECTION_PREFIX "ngroup" /* without underscore? */ |
| 63 | 63 | #define NATION_SECTION_PREFIX "nation" /* without underscore? */ |
| 64 | 64 | #define RESOURCE_SECTION_PREFIX "resource_" |
| 65 | #define BASE_SECTION_PREFIX "base_" | |
| 65 | 66 | #define SPECIALIST_SECTION_PREFIX "specialist_" |
| 66 | 67 | #define TERRAIN_CAPABILITY "+1.9+2007.Oct.26" |
| 67 | 68 | #define TERRAIN_SECTION_PREFIX "terrain_" |
| ... | ...@@ -83,6 +84,7 @@ | |
| 83 | 84 | (void) loud_strlcpy(dst, src, MAX_SECTION_LABEL, name_too_long) |
| 84 | 85 | static char *resource_sections = NULL; |
| 85 | 86 | static char *terrain_sections = NULL; |
| 87 | static char *base_sections = NULL; | |
| 86 | 88 | |
| 87 | 89 | |
| 88 | 90 | static void openload_ruleset_file(struct section_file *file, |
| ... | ...@@ -1649,39 +1651,31 @@ | |
| 1649 | 1651 | |
| 1650 | 1652 | /* base names */ |
| 1651 | 1653 | |
| 1652 | game.control.num_base_types = BASE_LAST; | |
| 1653 | ||
| 1654 | base_type_iterate(pbase) { | |
| 1655 | char *name; | |
| 1656 | char *section; | |
| 1654 | sec = secfile_get_secnames_prefix(file, BASE_SECTION_PREFIX, &nval); | |
| 1655 | if (nval > MAX_BASE_TYPES) { | |
| 1656 | ruleset_error(LOG_FATAL, "\"%s\": Too many base types (%d, max %d)", | |
| 1657 | filename, | |
| 1658 | nval, | |
| 1659 | MAX_BASE_TYPES); | |
| 1660 | } | |
| 1661 | game.control.num_base_types = nval; | |
| 1657 | 1662 | |
| 1658 | switch (base_number(pbase)) { | |
| 1659 | case BASE_FORTRESS: | |
| 1660 | section = "fortress"; | |
| 1661 | break; | |
| 1662 | case BASE_AIRBASE: | |
| 1663 | section = "airbase"; | |
| 1664 | break; | |
| 1665 | default: | |
| 1666 | ruleset_error(LOG_FATAL, "\"%s\": unhandled base type %d in %s.", | |
| 1667 | filename, | |
| 1668 | base_number(pbase), | |
| 1669 | "load_terrain_names()"); | |
| 1663 | if (base_sections) { | |
| 1664 | free(base_sections); | |
| 1665 | } | |
| 1666 | base_sections = fc_calloc(nval, MAX_SECTION_LABEL); | |
| 1670 | 1667 | |
| 1671 | /* ruleset_error() never returns, since error was marked fatal. | |
| 1672 | * This just makes compiler happy. It is afraid that 'section' is | |
| 1673 | * used uninitialized */ | |
| 1674 | section = "unknown"; | |
| 1675 | } | |
| 1676 | name = secfile_lookup_str(file, "%s.name", section); | |
| 1677 | if (name == NULL) { | |
| 1678 | ruleset_error(LOG_FATAL, "\"%s\" [%s] missing.", | |
| 1679 | filename, section); | |
| 1680 | } | |
| 1668 | base_type_iterate(pbase) { | |
| 1669 | const int i = base_index(pbase); | |
| 1670 | char *name = secfile_lookup_str(file, "%s.name", sec[i]); | |
| 1681 | 1671 | |
| 1682 | 1672 | name_strlcpy(pbase->name.vernacular, name); |
| 1683 | 1673 | pbase->name.translated = NULL; |
| 1674 | ||
| 1675 | section_strlcpy(&base_sections[i * MAX_SECTION_LABEL], sec[i]); | |
| 1684 | 1676 | } base_type_iterate_end; |
| 1677 | ||
| 1678 | free(sec); | |
| 1685 | 1679 | } |
| 1686 | 1680 | |
| 1687 | 1681 | /************************************************************************** |
| ... | ...@@ -1968,31 +1962,12 @@ | |
| 1968 | 1962 | /* base details */ |
| 1969 | 1963 | |
| 1970 | 1964 | base_type_iterate(pbase) { |
| 1965 | const char *section = &base_sections[base_index(pbase) * MAX_SECTION_LABEL]; | |
| 1971 | 1966 | int j; |
| 1972 | 1967 | char **slist; |
| 1973 | char *section; | |
| 1974 | 1968 | struct requirement_vector *reqs; |
| 1975 | 1969 | char *gui_str; |
| 1976 | 1970 | |
| 1977 | switch (base_number(pbase)) { | |
| 1978 | case BASE_FORTRESS: | |
| 1979 | section = "fortress"; | |
| 1980 | break; | |
| 1981 | case BASE_AIRBASE: | |
| 1982 | section = "airbase"; | |
| 1983 | break; | |
| 1984 | default: | |
| 1985 | ruleset_error(LOG_FATAL, "\"%s\": unhandled base type %d in %s.", | |
| 1986 | filename, | |
| 1987 | base_number(pbase), | |
| 1988 | "load_ruleset_terrain()"); | |
| 1989 | ||
| 1990 | /* ruleset_error() never returns, since error was marked fatal. | |
| 1991 | * This just makes compiler happy. It is afraid that 'section' is | |
| 1992 | * used uninitialized */ | |
| 1993 | section = "unknown"; | |
| 1994 | } | |
| 1995 | ||
| 1996 | 1971 | pbase->buildable = secfile_lookup_bool_default(file, TRUE, |
| 1997 | 1972 | "%s.buildable", section); |
| 1998 | 1973 | |
| ... | ...@@ -3655,6 +3630,10 @@ | |
| 3655 | 3630 | |
| 3656 | 3631 | precalc_tech_data(); |
| 3657 | 3632 | |
| 3633 | if (base_sections) { | |
| 3634 | free(base_sections); | |
| 3635 | base_sections = NULL; | |
| 3636 | } | |
| 3658 | 3637 | if (resource_sections) { |
| 3659 | 3638 | free(resource_sections); |
| 3660 | 3639 | resource_sections = NULL; |
| ... | ...@@ -117,7 +117,7 @@ | |
| 117 | 117 | int tile_activity_time(enum unit_activity activity, |
| 118 | 118 | const struct tile *ptile); |
| 119 | 119 | int tile_activity_base_time(const struct tile *ptile, |
| 120 | enum base_type_id base); | |
| 120 | Base_type_id base); | |
| 121 | 121 | |
| 122 | 122 | /* These are higher-level functions that handle side effects on the tile. */ |
| 123 | 123 | void tile_change_terrain(struct tile *ptile, struct terrain *pterrain); |
| ... | ...@@ -192,7 +192,7 @@ | |
| 192 | 192 | type REQ_TYPE = uint8(enum universals_n) |
| 193 | 193 | type REQ_RANGE = uint8(enum req_range) |
| 194 | 194 | type EFFECT_TYPE = uint8(enum effect_type) |
| 195 | type BASE = uint8(enum base_type_id) | |
| 195 | type BASE = uint8(Base_type_id) | |
| 196 | 196 | type BASE_GUI = uint8(enum base_gui_type) |
| 197 | 197 | |
| 198 | 198 | type BV_IMPRS = bitvector(bv_imprs) |
| ... | ...@@ -1319,7 +1319,7 @@ | |
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | dsend_packet_unit_change_activity(&client.conn, punit->id, act, |
| 1322 | S_LAST, BASE_LAST); | |
| 1322 | S_LAST, -1); | |
| 1323 | 1323 | } |
| 1324 | 1324 | |
| 1325 | 1325 | /************************************************************************** |
| ... | ...@@ -1330,7 +1330,7 @@ | |
| 1330 | 1330 | enum tile_special_type tgt) |
| 1331 | 1331 | { |
| 1332 | 1332 | dsend_packet_unit_change_activity(&client.conn, punit->id, act, tgt, |
| 1333 | BASE_LAST); | |
| 1333 | -1); | |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | /************************************************************************** |
| ... | ...@@ -1411,7 +1411,7 @@ | |
| 1411 | 1411 | /* Sentry the unit. Don't request_unit_sentry since this can give a |
| 1412 | 1412 | * recursive loop. */ |
| 1413 | 1413 | dsend_packet_unit_change_activity(&client.conn, pcargo->id, |
| 1414 | ACTIVITY_SENTRY, S_LAST, BASE_LAST); | |
| 1414 | ACTIVITY_SENTRY, S_LAST, -1); | |
| 1415 | 1415 | } |
| 1416 | 1416 | } |
| 1417 | 1417 | |
| ... | ...@@ -1431,7 +1431,7 @@ | |
| 1431 | 1431 | |
| 1432 | 1432 | /* Activate the unit. */ |
| 1433 | 1433 | dsend_packet_unit_change_activity(&client.conn, pcargo->id, |
| 1434 | ACTIVITY_IDLE, S_LAST, BASE_LAST); | |
| 1434 | ACTIVITY_IDLE, S_LAST, -1); | |
| 1435 | 1435 | } |
| 1436 | 1436 | } |
| 1437 | 1437 |
| ... | ...@@ -202,7 +202,7 @@ | |
| 202 | 202 | { \ |
| 203 | 203 | int b; \ |
| 204 | 204 | \ |
| 205 | for(b = 0; 4 * b < BASE_LAST; b++) { | |
| 205 | for(b = 0; 4 * b < game.control.num_base_types; b++) { | |
| 206 | 206 | |
| 207 | 207 | #define bases_halfbyte_iterate_end \ |
| 208 | 208 | } \ |
| ... | ...@@ -873,7 +873,7 @@ | |
| 873 | 873 | for (i = 0; i < 4; i++) { |
| 874 | 874 | int base = index[i]; |
| 875 | 875 | |
| 876 | if (base >= BASE_LAST) { | |
| 876 | if (base < 0) { | |
| 877 | 877 | break; |
| 878 | 878 | } |
| 879 | 879 | if (BV_ISSET(bases, base)) { |
| ... | ...@@ -1036,7 +1036,7 @@ | |
| 1036 | 1036 | int i; |
| 1037 | 1037 | |
| 1038 | 1038 | /* This is needed when new bases has been added to ruleset, and |
| 1039 | * thus BASE_LAST is greater than, when game was saved. */ | |
| 1039 | * thus game.control.num_base_types is greater than, when game was saved. */ | |
| 1040 | 1040 | for (i = 0; i < map.xsize; i++) { |
| 1041 | 1041 | zeroline[i] = '0'; |
| 1042 | 1042 | } |
| ... | ...@@ -1181,7 +1181,7 @@ | |
| 1181 | 1181 | int l; |
| 1182 | 1182 | |
| 1183 | 1183 | for (l = 0; l < 4; l++) { |
| 1184 | mod[l] = MIN(4 * j + l, BASE_LAST); | |
| 1184 | mod[l] = MIN(4 * j + l, -1); | |
| 1185 | 1185 | } |
| 1186 | 1186 | sprintf (buf, "map.b%02d_%%03d", j); |
| 1187 | 1187 | SAVE_NORMAL_MAP_DATA(ptile, file, buf, |
| ... | ...@@ -2985,7 +2985,7 @@ | |
| 2985 | 2985 | int i; |
| 2986 | 2986 | |
| 2987 | 2987 | /* This is needed when new bases has been added to ruleset, and |
| 2988 | * thus BASE_LAST is greater than, when game was saved. */ | |
| 2988 | * thus game.control.num_base_types is greater than, when game was saved. */ | |
| 2989 | 2989 | for(i = 0; i < map.xsize; i++) { |
| 2990 | 2990 | zeroline[i] = '0'; |
| 2991 | 2991 | } |
| ... | ...@@ -3670,7 +3670,7 @@ | |
| 3670 | 3670 | int l; |
| 3671 | 3671 | |
| 3672 | 3672 | for (l = 0; l < 4; l++) { |
| 3673 | mod[l] = MIN(4 * j + l, BASE_LAST); | |
| 3673 | mod[l] = MAX(4 * j + l, -1); | |
| 3674 | 3674 | } |
| 3675 | 3675 | sprintf (buf, "player%%d.map_b%02d_%%03d", j); |
| 3676 | 3676 | SAVE_PLAYER_MAP_DATA(ptile, file, buf, plrno, |
| ... | ...@@ -4324,7 +4324,7 @@ | |
| 4324 | 4324 | base_order[j] = find_base_type_by_rule_name(modname[j]); |
| 4325 | 4325 | } |
| 4326 | 4326 | free(modname); |
| 4327 | for (; j < BASE_LAST + (4 - (BASE_LAST % 4)); j++) { | |
| 4327 | for (; j < game.control.num_base_types + (4 - (game.control.num_base_types % 4)); j++) { | |
| 4328 | 4328 | base_order[j] = NULL; |
| 4329 | 4329 | } |
| 4330 | 4330 | } |
| ... | ...@@ -4774,13 +4774,13 @@ | |
| 4774 | 4774 | int i = 0; |
| 4775 | 4775 | |
| 4776 | 4776 | /* Save specials order */ |
| 4777 | modname = fc_calloc(BASE_LAST, sizeof(*modname)); | |
| 4777 | modname = fc_calloc(game.control.num_base_types, sizeof(*modname)); | |
| 4778 | 4778 | |
| 4779 | 4779 | base_type_iterate(pbase) { |
| 4780 | 4780 | modname[i++] = base_rule_name(pbase); |
| 4781 | 4781 | } base_type_iterate_end; |
| 4782 | 4782 | |
| 4783 | secfile_insert_str_vec(file, modname, BASE_LAST, | |
| 4783 | secfile_insert_str_vec(file, modname, game.control.num_base_types, | |
| 4784 | 4784 | "savefile.bases"); |
| 4785 | 4785 | free(modname); |
| 4786 | 4786 | } |
| ... | ...@@ -886,8 +886,7 @@ | |
| 886 | 886 | shield = 3 |
| 887 | 887 | # desert-only, special processing, see savegame map_load(). |
| 888 | 888 | |
| 889 | ; Exactly two base types: | |
| 890 | ; [fortress] and [airbase]. | |
| 889 | ; Base types: | |
| 891 | 890 | ; |
| 892 | 891 | ; name = Name of the base type. |
| 893 | 892 | ; buildable = Can base be built? Defaults to true |
| ... | ...@@ -907,7 +906,7 @@ | |
| 907 | 906 | ; - "DiplomatDefense" = Diplomats inside get bonus to diplomatic defense |
| 908 | 907 | ; - "ParadropFrom" = Paradrop can be initiated from base |
| 909 | 908 | |
| 910 | [fortress] | |
| 909 | [base_fortress] | |
| 911 | 910 | name = _("Fortress") |
| 912 | 911 | graphic = "base.fortress" |
| 913 | 912 | graphic_alt = "-" |
| ... | ...@@ -924,7 +923,7 @@ | |
| 924 | 923 | flags = "NoAggressive", "DefenseBonus", "ClaimTerritory", |
| 925 | 924 | "NoStackDeath", "DiplomatDefense" |
| 926 | 925 | |
| 927 | [airbase] | |
| 926 | [base_airbase] | |
| 928 | 927 | name = _("Airbase") |
| 929 | 928 | graphic = "base.airbase" |
| 930 | 929 | graphic_alt = "-" |
| ... | ...@@ -28,7 +28,7 @@ | |
| 28 | 28 | |
| 29 | 29 | #include "base.h" |
| 30 | 30 | |
| 31 | static struct base_type base_types[BASE_LAST]; | |
| 31 | static struct base_type base_types[MAX_BASE_TYPES]; | |
| 32 | 32 | |
| 33 | 33 | static const char *base_type_flag_names[] = { |
| 34 | 34 | "NoAggressive", "DefenseBonus", "NoStackDeath", |
| ... | ...@@ -113,7 +113,7 @@ | |
| 113 | 113 | Returns TRUE if any of the units can do the base building activity |
| 114 | 114 | ****************************************************************************/ |
| 115 | 115 | bool can_units_do_base(const struct unit_list *punits, |
| 116 | enum base_type_id base) | |
| 116 | Base_type_id base) | |
| 117 | 117 | { |
| 118 | 118 | unit_list_iterate(punits, punit) { |
| 119 | 119 | if (can_unit_do_activity_base(punit, base)) { |
| ... | ...@@ -583,7 +583,7 @@ | |
| 583 | 583 | Calculate the total amount of base building activity performed by all |
| 584 | 584 | units on a tile for a given base. |
| 585 | 585 | **************************************************************************/ |
| 586 | static int total_activity_base(struct tile *ptile, enum base_type_id base) | |
| 586 | static int total_activity_base(struct tile *ptile, Base_type_id base) | |
| 587 | 587 | { |
| 588 | 588 | int total = 0; |
| 589 | 589 | |
| ... | ...@@ -1875,7 +1875,7 @@ | |
| 1875 | 1875 | if (punit->activity == ACTIVITY_EXPLORE |
| 1876 | 1876 | || punit->activity == ACTIVITY_GOTO) { |
| 1877 | 1877 | packet->activity = ACTIVITY_IDLE; |
| 1878 | packet->activity_base = BASE_LAST; | |
| 1878 | packet->activity_base = -1; | |
| 1879 | 1879 | } else { |
| 1880 | 1880 | packet->activity = punit->activity; |
| 1881 | 1881 | packet->activity_base = punit->activity_base; |
| ... | ...@@ -3024,7 +3024,7 @@ | |
| 3024 | 3024 | struct player *pplayer = unit_owner(punit); |
| 3025 | 3025 | int moves_made = 0; |
| 3026 | 3026 | enum unit_activity activity; |
| 3027 | enum base_type_id base; | |
| 3027 | Base_type_id base; | |
| 3028 | 3028 | |
| 3029 | 3029 | assert(unit_has_orders(punit)); |
| 3030 | 3030 |
| ... | ...@@ -16,8 +16,6 @@ | |
| 16 | 16 | #include "fc_types.h" |
| 17 | 17 | #include "requirements.h" |
| 18 | 18 | |
| 19 | typedef enum base_type_id Base_type_id; | |
| 20 | ||
| 21 | 19 | /* This must correspond to base_gui_type_names[] in base.c */ |
| 22 | 20 | enum base_gui_type { |
| 23 | 21 | BASE_GUI_FORTRESS = 0, |
| ... | ...@@ -691,14 +691,14 @@ | |
| 691 | 691 | { |
| 692 | 692 | enum unit_activity current = punit->activity; |
| 693 | 693 | enum tile_special_type target = punit->activity_target; |
| 694 | enum base_type_id base = punit->activity_base; | |
| 694 | Base_type_id base = punit->activity_base; | |
| 695 | 695 | enum unit_activity current2 = |
| 696 | 696 | (current == ACTIVITY_FORTIFIED) ? ACTIVITY_FORTIFYING : current; |
| 697 | 697 | bool result; |
| 698 | 698 | |
| 699 | 699 | punit->activity = ACTIVITY_IDLE; |
| 700 | 700 | punit->activity_target = S_LAST; |
| 701 | punit->activity_base = BASE_LAST; | |
| 701 | punit->activity_base = -1; | |
| 702 | 702 | |
| 703 | 703 | result = can_unit_do_activity_targeted(punit, current2, target, base); |
| 704 | 704 | |
| ... | ...@@ -719,7 +719,7 @@ | |
| 719 | 719 | bool can_unit_do_activity(const struct unit *punit, |
| 720 | 720 | enum unit_activity activity) |
| 721 | 721 | { |
| 722 | return can_unit_do_activity_targeted(punit, activity, S_LAST, BASE_LAST); | |
| 722 | return can_unit_do_activity_targeted(punit, activity, S_LAST, -1); | |
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /************************************************************************** |
| ... | ...@@ -727,7 +727,7 @@ | |
| 727 | 727 | current location. |
| 728 | 728 | **************************************************************************/ |
| 729 | 729 | bool can_unit_do_activity_base(const struct unit *punit, |
| 730 | enum base_type_id base) | |
| 730 | Base_type_id base) | |
| 731 | 731 | { |
| 732 | 732 | return can_unit_do_activity_targeted(punit, ACTIVITY_BASE, S_LAST, base); |
| 733 | 733 | } |
| ... | ...@@ -739,7 +739,7 @@ | |
| 739 | 739 | bool can_unit_do_activity_targeted(const struct unit *punit, |
| 740 | 740 | enum unit_activity activity, |
| 741 | 741 | enum tile_special_type target, |
| 742 | enum base_type_id base) | |
| 742 | Base_type_id base) | |
| 743 | 743 | { |
| 744 | 744 | return can_unit_do_activity_targeted_at(punit, activity, target, |
| 745 | 745 | punit->tile, base); |
| ... | ...@@ -757,7 +757,7 @@ | |
| 757 | 757 | enum unit_activity activity, |
| 758 | 758 | enum tile_special_type target, |
| 759 | 759 | const struct tile *ptile, |
| 760 | enum base_type_id base) | |
| 760 | Base_type_id base) | |
| 761 | 761 | { |
| 762 | 762 | struct player *pplayer = unit_owner(punit); |
| 763 | 763 | struct terrain *pterrain = tile_terrain(ptile); |
| ... | ...@@ -959,7 +959,7 @@ | |
| 959 | 959 | punit->activity=new_activity; |
| 960 | 960 | punit->activity_count=0; |
| 961 | 961 | punit->activity_target = S_LAST; |
| 962 | punit->activity_base = BASE_LAST; | |
| 962 | punit->activity_base = -1; | |
| 963 | 963 | if (new_activity == ACTIVITY_IDLE && punit->moves_left > 0) { |
| 964 | 964 | /* No longer done. */ |
| 965 | 965 | punit->done_moving = FALSE; |
| ... | ...@@ -984,7 +984,7 @@ | |
| 984 | 984 | Assign a new base building task to unit |
| 985 | 985 | **************************************************************************/ |
| 986 | 986 | void set_unit_activity_base(struct unit *punit, |
| 987 | enum base_type_id base) | |
| 987 | Base_type_id base) | |
| 988 | 988 | { |
| 989 | 989 | set_unit_activity(punit, ACTIVITY_BASE); |
| 990 | 990 | punit->activity_base = base; |
| ... | ...@@ -1097,7 +1097,7 @@ | |
| 1097 | 1097 | BV_CLR_ALL(pset); |
| 1098 | 1098 | BV_SET(pset, punit->activity_target); |
| 1099 | 1099 | BV_CLR_ALL(bases); |
| 1100 | if (punit->activity_base != BASE_LAST) { | |
| 1100 | if (punit->activity_base >= 0) { | |
| 1101 | 1101 | BV_SET(bases, punit->activity_base); |
| 1102 | 1102 | } |
| 1103 | 1103 | my_snprintf(text, sizeof(text), "%s: %s", |
| ... | ...@@ -63,7 +63,7 @@ | |
| 63 | 63 | bool can_units_do_activity(const struct unit_list *punits, |
| 64 | 64 | enum unit_activity activity); |
| 65 | 65 | bool can_units_do_base(const struct unit_list *punits, |
| 66 | enum base_type_id base); | |
| 66 | Base_type_id base); | |
| 67 | 67 | bool can_units_do_base_gui(const struct unit_list *punits, |
| 68 | 68 | enum base_gui_type base_gui); |
| 69 | 69 | bool can_units_do_diplomat_action(const struct unit_list *punits, |
| ... | ...@@ -33,6 +33,7 @@ | |
| 33 | 33 | #define MAX_NUM_BUILDING_LIST 10 |
| 34 | 34 | #define MAX_LEN_VET_SHORT_NAME 8 |
| 35 | 35 | #define MAX_VET_LEVELS 10 |
| 36 | #define MAX_BASE_TYPES 32 | |
| 36 | 37 | |
| 37 | 38 | /* Changing these will probably break network compatability. */ |
| 38 | 39 | #define MAX_LEN_NAME 32 |
| ... | ...@@ -100,6 +101,7 @@ | |
| 100 | 101 | typedef int Nation_type_id; |
| 101 | 102 | typedef int Team_type_id; |
| 102 | 103 | typedef int Unit_type_id; |
| 104 | typedef int Base_type_id; | |
| 103 | 105 | |
| 104 | 106 | struct advance; |
| 105 | 107 | struct city; |
| ... | ...@@ -261,12 +263,6 @@ | |
| 261 | 263 | |
| 262 | 264 | struct ai_choice; /* incorporates universals_u */ |
| 263 | 265 | |
| 264 | enum base_type_id { | |
| 265 | BASE_FORTRESS = 0, | |
| 266 | BASE_AIRBASE, | |
| 267 | BASE_LAST | |
| 268 | }; | |
| 269 | ||
| 270 | BV_DEFINE(bv_bases, BASE_LAST); | |
| 266 | BV_DEFINE(bv_bases, MAX_BASE_TYPES); | |
| 271 | 267 | |
| 272 | 268 | #endif /* FC__FC_TYPES_H */ |
| ... | ...@@ -860,7 +860,7 @@ | |
| 860 | 860 | if (pcity->ai.act_value[act][cx][cy] >= 0 |
| 861 | 861 | && act != ACTIVITY_BASE /* This needs separate implementation */ |
| 862 | 862 | && can_unit_do_activity_targeted_at(punit, act, S_LAST, |
| 863 | ptile, BASE_LAST)) { | |
| 863 | ptile, -1)) { | |
| 864 | 864 | int extra = 0; |
| 865 | 865 | int base_value = pcity->ai.act_value[act][cx][cy]; |
| 866 | 866 |