| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Freeciv
Revision: 15190
Author: cazfi
Date: 01 Sep 2008 17:39:41
Changes:Made number of base types adjustable. Max number of base types is now 32.
See #40469
Files:| ... | ...@@ -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 |
| ... | ...@@ -2456,7 +2456,7 @@ | |
| 2456 | 2456 | VALIDATE(num_unit_types, U_LAST, "unit types"); |
| 2457 | 2457 | VALIDATE(num_impr_types, B_LAST, "improvements"); |
| 2458 | 2458 | VALIDATE(num_tech_types, A_LAST_REAL, "advances"); |
| 2459 | VALIDATE(num_base_types, BASE_LAST, "bases"); | |
| 2459 | VALIDATE(num_base_types, MAX_BASE_TYPES, "bases"); | |
| 2460 | 2460 | |
| 2461 | 2461 | VALIDATE(government_count, MAX_NUM_ITEMS, "governments"); |
| 2462 | 2462 | 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) |
| ... | ...@@ -1333,7 +1333,7 @@ | |
| 1333 | 1333 | } |
| 1334 | 1334 | |
| 1335 | 1335 | dsend_packet_unit_change_activity(&client.conn, punit->id, act, |
| 1336 | S_LAST, BASE_LAST); | |
| 1336 | S_LAST, -1); | |
| 1337 | 1337 | } |
| 1338 | 1338 | |
| 1339 | 1339 | /************************************************************************** |
| ... | ...@@ -1344,7 +1344,7 @@ | |
| 1344 | 1344 | enum tile_special_type tgt) |
| 1345 | 1345 | { |
| 1346 | 1346 | dsend_packet_unit_change_activity(&client.conn, punit->id, act, tgt, |
| 1347 | BASE_LAST); | |
| 1347 | -1); | |
| 1348 | 1348 | } |
| 1349 | 1349 | |
| 1350 | 1350 | /************************************************************************** |
| ... | ...@@ -1425,7 +1425,7 @@ | |
| 1425 | 1425 | /* Sentry the unit. Don't request_unit_sentry since this can give a |
| 1426 | 1426 | * recursive loop. */ |
| 1427 | 1427 | dsend_packet_unit_change_activity(&client.conn, pcargo->id, |
| 1428 | ACTIVITY_SENTRY, S_LAST, BASE_LAST); | |
| 1428 | ACTIVITY_SENTRY, S_LAST, -1); | |
| 1429 | 1429 | } |
| 1430 | 1430 | } |
| 1431 | 1431 | |
| ... | ...@@ -1445,7 +1445,7 @@ | |
| 1445 | 1445 | |
| 1446 | 1446 | /* Activate the unit. */ |
| 1447 | 1447 | dsend_packet_unit_change_activity(&client.conn, pcargo->id, |
| 1448 | ACTIVITY_IDLE, S_LAST, BASE_LAST); | |
| 1448 | ACTIVITY_IDLE, S_LAST, -1); | |
| 1449 | 1449 | } |
| 1450 | 1450 | } |
| 1451 | 1451 |
| ... | ...@@ -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, |
| ... | ...@@ -3011,7 +3011,7 @@ | |
| 3011 | 3011 | int i; |
| 3012 | 3012 | |
| 3013 | 3013 | /* This is needed when new bases has been added to ruleset, and |
| 3014 | * thus BASE_LAST is greater than, when game was saved. */ | |
| 3014 | * thus game.control.num_base_types is greater than, when game was saved. */ | |
| 3015 | 3015 | for(i = 0; i < map.xsize; i++) { |
| 3016 | 3016 | zeroline[i] = '0'; |
| 3017 | 3017 | } |
| ... | ...@@ -3704,7 +3704,7 @@ | |
| 3704 | 3704 | int l; |
| 3705 | 3705 | |
| 3706 | 3706 | for (l = 0; l < 4; l++) { |
| 3707 | mod[l] = MIN(4 * j + l, BASE_LAST); | |
| 3707 | mod[l] = MAX(4 * j + l, -1); | |
| 3708 | 3708 | } |
| 3709 | 3709 | sprintf (buf, "player%%d.map_b%02d_%%03d", j); |
| 3710 | 3710 | SAVE_PLAYER_MAP_DATA(ptile, file, buf, plrno, |
| ... | ...@@ -4358,7 +4358,7 @@ | |
| 4358 | 4358 | base_order[j] = find_base_type_by_rule_name(modname[j]); |
| 4359 | 4359 | } |
| 4360 | 4360 | free(modname); |
| 4361 | for (; j < BASE_LAST + (4 - (BASE_LAST % 4)); j++) { | |
| 4361 | for (; j < game.control.num_base_types + (4 - (game.control.num_base_types % 4)); j++) { | |
| 4362 | 4362 | base_order[j] = NULL; |
| 4363 | 4363 | } |
| 4364 | 4364 | } |
| ... | ...@@ -4808,13 +4808,13 @@ | |
| 4808 | 4808 | int i = 0; |
| 4809 | 4809 | |
| 4810 | 4810 | /* Save specials order */ |
| 4811 | modname = fc_calloc(BASE_LAST, sizeof(*modname)); | |
| 4811 | modname = fc_calloc(game.control.num_base_types, sizeof(*modname)); | |
| 4812 | 4812 | |
| 4813 | 4813 | base_type_iterate(pbase) { |
| 4814 | 4814 | modname[i++] = base_rule_name(pbase); |
| 4815 | 4815 | } base_type_iterate_end; |
| 4816 | 4816 | |
| 4817 | secfile_insert_str_vec(file, modname, BASE_LAST, | |
| 4817 | secfile_insert_str_vec(file, modname, game.control.num_base_types, | |
| 4818 | 4818 | "savefile.bases"); |
| 4819 | 4819 | free(modname); |
| 4820 | 4820 | } |
| ... | ...@@ -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 |
| ... | ...@@ -704,14 +704,14 @@ | |
| 704 | 704 | { |
| 705 | 705 | enum unit_activity current = punit->activity; |
| 706 | 706 | enum tile_special_type target = punit->activity_target; |
| 707 | enum base_type_id base = punit->activity_base; | |
| 707 | Base_type_id base = punit->activity_base; | |
| 708 | 708 | enum unit_activity current2 = |
| 709 | 709 | (current == ACTIVITY_FORTIFIED) ? ACTIVITY_FORTIFYING : current; |
| 710 | 710 | bool result; |
| 711 | 711 | |
| 712 | 712 | punit->activity = ACTIVITY_IDLE; |
| 713 | 713 | punit->activity_target = S_LAST; |
| 714 | punit->activity_base = BASE_LAST; | |
| 714 | punit->activity_base = -1; | |
| 715 | 715 | |
| 716 | 716 | result = can_unit_do_activity_targeted(punit, current2, target, base); |
| 717 | 717 | |
| ... | ...@@ -732,7 +732,7 @@ | |
| 732 | 732 | bool can_unit_do_activity(const struct unit *punit, |
| 733 | 733 | enum unit_activity activity) |
| 734 | 734 | { |
| 735 | return can_unit_do_activity_targeted(punit, activity, S_LAST, BASE_LAST); | |
| 735 | return can_unit_do_activity_targeted(punit, activity, S_LAST, -1); | |
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | /************************************************************************** |
| ... | ...@@ -740,7 +740,7 @@ | |
| 740 | 740 | current location. |
| 741 | 741 | **************************************************************************/ |
| 742 | 742 | bool can_unit_do_activity_base(const struct unit *punit, |
| 743 | enum base_type_id base) | |
| 743 | Base_type_id base) | |
| 744 | 744 | { |
| 745 | 745 | return can_unit_do_activity_targeted(punit, ACTIVITY_BASE, S_LAST, base); |
| 746 | 746 | } |
| ... | ...@@ -752,7 +752,7 @@ | |
| 752 | 752 | bool can_unit_do_activity_targeted(const struct unit *punit, |
| 753 | 753 | enum unit_activity activity, |
| 754 | 754 | enum tile_special_type target, |
| 755 | enum base_type_id base) | |
| 755 | Base_type_id base) | |
| 756 | 756 | { |
| 757 | 757 | return can_unit_do_activity_targeted_at(punit, activity, target, |
| 758 | 758 | punit->tile, base); |
| ... | ...@@ -770,7 +770,7 @@ | |
| 770 | 770 | enum unit_activity activity, |
| 771 | 771 | enum tile_special_type target, |
| 772 | 772 | const struct tile *ptile, |
| 773 | enum base_type_id base) | |
| 773 | Base_type_id base) | |
| 774 | 774 | { |
| 775 | 775 | struct player *pplayer = unit_owner(punit); |
| 776 | 776 | struct terrain *pterrain = tile_terrain(ptile); |
| ... | ...@@ -972,7 +972,7 @@ | |
| 972 | 972 | punit->activity=new_activity; |
| 973 | 973 | punit->activity_count=0; |
| 974 | 974 | punit->activity_target = S_LAST; |
| 975 | punit->activity_base = BASE_LAST; | |
| 975 | punit->activity_base = -1; | |
| 976 | 976 | if (new_activity == ACTIVITY_IDLE && punit->moves_left > 0) { |
| 977 | 977 | /* No longer done. */ |
| 978 | 978 | punit->done_moving = FALSE; |
| ... | ...@@ -997,7 +997,7 @@ | |
| 997 | 997 | Assign a new base building task to unit |
| 998 | 998 | **************************************************************************/ |
| 999 | 999 | void set_unit_activity_base(struct unit *punit, |
| 1000 | enum base_type_id base) | |
| 1000 | Base_type_id base) | |
| 1001 | 1001 | { |
| 1002 | 1002 | set_unit_activity(punit, ACTIVITY_BASE); |
| 1003 | 1003 | punit->activity_base = base; |
| ... | ...@@ -1110,7 +1110,7 @@ | |
| 1110 | 1110 | BV_CLR_ALL(pset); |
| 1111 | 1111 | BV_SET(pset, punit->activity_target); |
| 1112 | 1112 | BV_CLR_ALL(bases); |
| 1113 | if (punit->activity_base != BASE_LAST) { | |
| 1113 | if (punit->activity_base >= 0) { | |
| 1114 | 1114 | BV_SET(bases, punit->activity_base); |
| 1115 | 1115 | } |
| 1116 | 1116 | my_snprintf(text, sizeof(text), "%s: %s", |
| ... | ...@@ -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, |
| ... | ...@@ -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 |
| ... | ...@@ -112,6 +113,7 @@ | |
| 112 | 113 | typedef int Nation_type_id; |
| 113 | 114 | typedef int Team_type_id; |
| 114 | 115 | typedef int Unit_type_id; |
| 116 | typedef int Base_type_id; | |
| 115 | 117 | |
| 116 | 118 | struct advance; |
| 117 | 119 | struct city; |
| ... | ...@@ -273,12 +275,6 @@ | |
| 273 | 275 | |
| 274 | 276 | struct ai_choice; /* incorporates universals_u */ |
| 275 | 277 | |
| 276 | enum base_type_id { | |
| 277 | BASE_FORTRESS = 0, | |
| 278 | BASE_AIRBASE, | |
| 279 | BASE_LAST | |
| 280 | }; | |
| 281 | ||
| 282 | BV_DEFINE(bv_bases, BASE_LAST); | |
| 278 | BV_DEFINE(bv_bases, MAX_BASE_TYPES); | |
| 283 | 279 | |
| 284 | 280 | #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 |
| ... | ...@@ -132,7 +132,7 @@ | |
| 132 | 132 | struct unit_order { |
| 133 | 133 | enum unit_orders order; |
| 134 | 134 | enum unit_activity activity; /* Only valid for ORDER_ACTIVITY. */ |
| 135 | enum base_type_id base; /* Only valid for activity ACTIVITY_BASE */ | |
| 135 | Base_type_id base; /* Only valid for activity ACTIVITY_BASE */ | |
| 136 | 136 | enum direction8 dir; /* Only valid for ORDER_MOVE. */ |
| 137 | 137 | }; |
| 138 | 138 | |
| ... | ...@@ -158,7 +158,7 @@ | |
| 158 | 158 | int activity_count; |
| 159 | 159 | |
| 160 | 160 | enum tile_special_type activity_target; |
| 161 | enum base_type_id activity_base; | |
| 161 | Base_type_id activity_base; | |
| 162 | 162 | enum unit_focus_status focus_status; |
| 163 | 163 | int ord_map, ord_city; |
| 164 | 164 | /* ord_map and ord_city are the order index of this unit in tile.units |
| ... | ...@@ -249,20 +249,20 @@ | |
| 249 | 249 | bool can_unit_do_activity_targeted(const struct unit *punit, |
| 250 | 250 | enum unit_activity activity, |
| 251 | 251 | enum tile_special_type target, |
| 252 | enum base_type_id base); | |
| 252 | Base_type_id base); | |
| 253 | 253 | bool can_unit_do_activity_targeted_at(const struct unit *punit, |
| 254 | 254 | enum unit_activity activity, |
| 255 | 255 | enum tile_special_type target, |
| 256 | 256 | const struct tile *ptile, |
| 257 | enum base_type_id base); | |
| 257 | Base_type_id base); | |
| 258 | 258 | bool can_unit_do_activity_base(const struct unit *punit, |
| 259 | enum base_type_id base); | |
| 259 | Base_type_id base); | |
| 260 | 260 | void set_unit_activity(struct unit *punit, enum unit_activity new_activity); |
| 261 | 261 | void set_unit_activity_targeted(struct unit *punit, |
| 262 | 262 | enum unit_activity new_activity, |
| 263 | 263 | enum tile_special_type new_target); |
| 264 | 264 | void set_unit_activity_base(struct unit *punit, |
| 265 | enum base_type_id base); | |
| 265 | Base_type_id base); | |
| 266 | 266 | int get_activity_rate(const struct unit *punit); |
| 267 | 267 | int get_activity_rate_this_turn(const struct unit *punit); |
| 268 | 268 | int get_turns_for_activity_at(const struct unit *punit, |
| ... | ...@@ -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 | |
| ... | ...@@ -657,7 +657,7 @@ | |
| 657 | 657 | void handle_unit_change_activity(struct player *pplayer, int unit_id, |
| 658 | 658 | enum unit_activity activity, |
| 659 | 659 | enum tile_special_type activity_target, |
| 660 | enum base_type_id activity_base) | |
| 660 | Base_type_id activity_base) | |
| 661 | 661 | { |
| 662 | 662 | struct unit *punit = player_find_unit_by_id(pplayer, unit_id); |
| 663 | 663 | |
| ... | ...@@ -1751,14 +1751,14 @@ | |
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | 1753 | /************************************************************************** |
| 1754 | ... | |
| 1754 | Handle request for targeted activity. | |
| 1755 | 1755 | **************************************************************************/ |
| 1756 | 1756 | static void unit_activity_handling_targeted(struct unit *punit, |
| 1757 | 1757 | enum unit_activity new_activity, |
| 1758 | 1758 | enum tile_special_type new_target) |
| 1759 | 1759 | { |
| 1760 | 1760 | if (can_unit_do_activity_targeted(punit, new_activity, new_target, |
| 1761 | BASE_LAST)) { | |
| 1761 | -1)) { | |
| 1762 | 1762 | enum unit_activity old_activity = punit->activity; |
| 1763 | 1763 | enum tile_special_type old_target = punit->activity_target; |
| 1764 | 1764 | |
| ... | ...@@ -1770,10 +1770,10 @@ | |
| 1770 | 1770 | } |
| 1771 | 1771 | |
| 1772 | 1772 | /************************************************************************** |
| 1773 | ... | |
| 1773 | Handle request for military base building. | |
| 1774 | 1774 | **************************************************************************/ |
| 1775 | 1775 | static void unit_activity_handling_base(struct unit *punit, |
| 1776 | enum base_type_id base) | |
| 1776 | Base_type_id base) | |
| 1777 | 1777 | { |
| 1778 | 1778 | if (can_unit_do_activity_base(punit, base)) { |
| 1779 | 1779 | enum unit_activity old_activity = punit->activity; |
| ... | ...@@ -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" |
| ... | ...@@ -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 = "-" |