diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-26 18:28:40 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-26 18:28:40 +0300 |
| commit | f3f5054641a3542e3154461f39a7a204cfd095ff (patch) | |
| tree | cf44bfccefa099024756a23bd3c91d114ea607d5 /crates/fparkan-runtime/src/clan_ai_events.rs | |
| parent | e8ee72dd0ad717ed6060fbd6963209d0edec47f4 (diff) | |
| download | fparkan-f3f5054641a3542e3154461f39a7a204cfd095ff.tar.xz fparkan-f3f5054641a3542e3154461f39a7a204cfd095ff.zip | |
fix(ai): rule out unavailable building upgrades
Check the class, initial stage and known research status of the next
BuildDat scheme before treating Handler(58) as unresolved. Keep the
existing coverage stub for candidates that still need full selection
and a builder upgrade order.
The native eligibility and research walks confirm both gates.
The stock Two Fortresses window and 900-second simulation exercise
the no-candidate branch. All 29 missions reach 900 seconds.
Diffstat (limited to 'crates/fparkan-runtime/src/clan_ai_events.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/clan_ai_events.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/crates/fparkan-runtime/src/clan_ai_events.rs b/crates/fparkan-runtime/src/clan_ai_events.rs index 7b663482..ee19f56e 100644 --- a/crates/fparkan-runtime/src/clan_ai_events.rs +++ b/crates/fparkan-runtime/src/clan_ai_events.rs @@ -1223,10 +1223,18 @@ impl LoadedMissionState { ))) } ScriptDispatchSelector::Handler(58) => { - single_dword(&instruction.references, values) + let index = single_dword(&instruction.references, values) .ok_or("Handler(58) requires a DWORD building index")?; - // shortcut: an unavailable upgrade catalog exposes no eligible buildings. - self.clan_ai_events.log_research_stub(clan, 58, &bundle.script_path); + let owner = OwnerId(clan as u16); + let units = self.mission_events.clan_units(world, owner, false); + let research = vfs.zip(self.clan_ai_events.research_catalogs.get(&clan).map(|catalog| &catalog.table)); + if crate::building_upgrade::needs_upgrade_selection( + world, units, &self.object_drafts, &self.build_categories, research, index, + |row| self.free_research.learned.contains(&(owner, row)), + ) { + // shortcut: eligible upgrades still need selection and a builder order. + self.clan_ai_events.log_research_stub(clan, 58, &bundle.script_path); + } Ok(Some(VarSetDefault::Dword(u32::MAX))) } ScriptDispatchSelector::Handler(handler @ (37 | 47 | 67)) => { |
