Skip to content

Consolidate district port/aerodrome unit checks and add additional resource & obsolence logic - #62

Open
instafluff0 wants to merge 2 commits into
maxpetul:masterfrom
instafluff0:port-aerodrome-obsolete-units-fix
Open

Consolidate district port/aerodrome unit checks and add additional resource & obsolence logic#62
instafluff0 wants to merge 2 commits into
maxpetul:masterfrom
instafluff0:port-aerodrome-obsolete-units-fix

Conversation

@instafluff0

@instafluff0 instafluff0 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

A user pointed out that ports were enabling obsolete naval units to be built, which I realized also likely was an issue with air units. After reviewing the code, I noticed we also weren't checking for required resources in the given city.

I consolidated the logic a bit and added the resource and upgrade checks, including the special logic for units triggering golden ages from vanilla. Last, I noticed the code that read as:

// Superficially allow the AI to choose the unit for scoring and production.
// If a disallowed air/naval unit is chosen in ai_choose_production, we'll swap it out for a feasible fallback later
// after prioritizing the aerodrome/port to be built
if (! is_human && (
    (type->Unit_Class == UTC_Air || city_can_build_district (this, AERODROME_DISTRICT_ID)) ||
    (type->Unit_Class == UTC_Sea || city_can_build_district (this, PORT_DISTRICT_ID)))
)

... should read as (type->Unit_Class == UTC_Air && city_can_build_district (this, AERODROME_DISTRICT_ID)), not ||.


Edit: it's been pointed out to me that naval and air units can't upgrade currently with ports and aerodromes and the *not_cities flags on. I'll work on that next, please hold off on merging for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant