diff options
| author | Valentin Popov <valentin@popov.link> | 2026-11-14 20:05:43 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-11-14 20:05:43 +0300 |
| commit | 6e18e9f05c1ae92a54dd671b6e47f3e21e299d4f (patch) | |
| tree | f1b7f39fcaf08a3d5beeab8be73aa0a3e3f65fd1 /crates/fparkan-runtime/src/mission_events.rs | |
| parent | 58910ebe71100617abf6523827e2b04351709de9 (diff) | |
| download | fparkan-6e18e9f05c1ae92a54dd671b6e47f3e21e299d4f.tar.xz fparkan-6e18e9f05c1ae92a54dd671b6e47f3e21e299d4f.zip | |
feat(ai): expose clan roster counts to problem scripts
Handler(49) counts free native-format startup slots and Handler(34) reads the live clan roster. The Two Fortresses reaches the research-dependent Handler(65) from every scheduled Problems0 invocation.
Diffstat (limited to 'crates/fparkan-runtime/src/mission_events.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/mission_events.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/fparkan-runtime/src/mission_events.rs b/crates/fparkan-runtime/src/mission_events.rs index 1c900819..b97b154f 100644 --- a/crates/fparkan-runtime/src/mission_events.rs +++ b/crates/fparkan-runtime/src/mission_events.rs @@ -152,6 +152,12 @@ pub(super) struct MissionEvents { } impl MissionEvents { + pub(super) fn count_clan_class(&self, world: &World, owner: OwnerId, class: u32) -> u32 { + clan_object_classes(&self.placed_clan_objects, world, owner) + .filter(|&candidate| candidate == class) + .count() as u32 + } + pub(super) fn set_reservation( &mut self, mission: &super::MissionDocument, @@ -714,13 +720,11 @@ impl LoadedMissionState { ScriptDispatchSelector::Handler(34) => { let class = single_dword(instruction, values) .ok_or("Handler(34) requires one DWORD operand")?; - let count = clan_object_classes( - &mission_events.placed_clan_objects, + let count = mission_events.count_clan_class( world, OwnerId(bundle.clan_index as u16), - ) - .filter(|&candidate| candidate == class) - .count() as u32; + class, + ); Ok(Some(count)) } ScriptDispatchSelector::Handler(52) => { |
