Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions C3X.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ struct unit_type_limit {
int cities_per;
};

/* ToC-26: Represents a named group of unit types that share a combined build limit.
Stored by pointer in unit_limit_groups (keyed by group name) and in unit_type_to_group
(keyed by unit_type_id). The group struct is owned by unit_limit_groups; unit_type_to_group
holds non-owning pointers into it. */
struct unit_limit_group {
int * unit_type_ids; // Array of unit type IDs belonging to this group
int count; // Number of IDs in the array
struct unit_type_limit limit; // The shared limit value for this group
bool has_limit; // True once a limit has been assigned via unit_limits
}; // END ToC-26

struct work_area_improvement {
short improv_id;
int work_area_radius_limit;
Expand Down Expand Up @@ -320,6 +331,10 @@ struct c3x_config {
struct leader_era_alias_list * leader_era_alias_lists;
int count_leader_era_alias_lists;
struct table unit_limits; // Maps unit type names (strings) to pointers to limit objects (struct unit_type_limit *)
// ToC-26: Group-based unit limits. unit_limit_groups maps group name strings to struct unit_limit_group*.
// unit_type_to_group maps unit_type_id (int) to struct unit_limit_group* for O(1) runtime lookup.
struct table unit_limit_groups;
struct table unit_type_to_group; // END ToC-26
bool allow_upgrades_in_any_city;
bool do_not_generate_volcanos;
bool do_not_pollute_impassable_tiles;
Expand Down Expand Up @@ -392,6 +407,7 @@ struct c3x_config {
bool patch_division_by_zero_in_ai_alliance_eval;
bool patch_empty_army_movement;
bool patch_empty_army_combat_crash;
bool patch_cruise_missile_ignores_lethal_bombard_abilities; // ToC-12 - Allow Missiles to obey normal lethal bombard flag rules
bool delete_off_map_ai_units;
bool fix_overlapping_specialist_yield_icons;
bool patch_premature_truncation_of_found_paths;
Expand Down Expand Up @@ -1921,6 +1937,13 @@ struct injected_state {
int penciled_in_upgrade_count;
int penciled_in_upgrade_capacity;

// ToC-27: Set to true while patch_City_can_build_upgrade_type is running. When true,
// patch_City_can_build_unit skips its unit-type limit check so that upgrades to group-limited
// types are not blocked at the City_can_build level. patch_Unit_can_upgrade re-applies the
// limit with full source-type context, allowing same-group upgrades (net-zero count change)
// while still blocking over-limit production and cross-group upgrade attempts.
bool checking_upgrade_type_eligibility; // END ToC-27

// While in Leader::do_capture_city, the city in question is stored in this var. Otherwise it's NULL.
City * currently_capturing_city;

Expand Down
21 changes: 21 additions & 0 deletions default.c3x_config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ expand_civilopedia_unit_stats = true
; This option also shows 'Moves' for immobile units such as aircraft, which the base game does not
expand_right_click_menu_unit_stats = true



[====================]
[=== OPTIMIZATION ===]
[====================]
Expand Down Expand Up @@ -334,6 +336,13 @@ ai_worker_requirement_percent = 150
; after the unit they're contained in.
; PATCH EMPTY ARMY COMBAT CRASH -- Guards a crash in the army combat selection routine by returning the army unit itself if it has no contained
; units (prevents divide-by-zero in the vanilla selection loop).
; CRUISE MISSILE IGNORES LETHAL BOMBARD ABILITIES -- The game hardcodes lethal bombard as always
; active for Cruise Missile-flagged units, ignoring the Lethal Land Bombardment and Lethal Sea
; Bombardment unit abilities entirely. This means a cruise missile can always kill a unit with on hit
; point remaining, regardless of whether those abilities are checked in the editor. This patch restores normal
; behavior: a cruise missile can only deal a killing blow against a land unit if it has Lethal Land
; Bombardment, and only against a sea unit if it has Lethal Sea Bombardment -- exactly like every
; other unit type in the game.

patch_submarine_bug = true
patch_science_age_bug = true
Expand All @@ -355,6 +364,7 @@ patch_crash_in_leader_unit_ai = true
patch_failure_to_find_new_city_build = true
patch_passengers_out_of_order_on_menu = true
patch_empty_army_combat_crash = true
patch_cruise_missile_ignores_lethal_bombard_abilities = false

; At the beginning of each AI player's turn, deletes any units of theirs that are not on a valid tile. This addresses a rare crash that can occur when
; the unit AI invokes the pathfinder for an off-map unit. I don't know how AI units can end up off the map in the first place.
Expand Down Expand Up @@ -745,8 +755,19 @@ leader_aliases_by_era = []
; The unit limits apply to unit production by players, not all forms of unit creation. Specifically, they apply to city production, upgrading, and
; auto-production from wonders. They do not apply to all other ways units may be created including by being captured, enslaved, spawned from a razed
; city, spawned for barbarians, pre-placed in a scenario, spawned for the AI based on difficulty level, etc.
; Can also add unit_limit_groups here too in order to limit entire unit group to x amount. See "unit_limit_groups".
unit_limits = []

; Unit Limit groups -- All units in the unit limit group count towards the limit. If a unit name does not exist in unit_limits,
; then unit_limits checks unit_limit_groups for group names as well. Groups are separated by commas, and units within are group
; are separated by spaces.
; For instance:
; unit_limit_groups = ["Infantry Units": "Castle Guard" "Guardian",
; "Tanks": "Light Tank" "Heavy Tank" "Panzer"]
; then in unit_limits setting (above), set a limit for the unit group:
; unit_limits = ["Infantry Units": 4, "Tanks": 3 cities-per]
unit_limit_groups = []

; Removes barracks/harbor/airport requirement from upgrades
allow_upgrades_in_any_city = false

Expand Down
Loading