From f2991b61ab407fd0813f6ba367ea5c0652ba8dad Mon Sep 17 00:00:00 2001 From: MechaCat02 Date: Thu, 23 Jul 2026 20:26:35 +0200 Subject: [PATCH] game_data: load_weapons catches variant-schema weapons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The player's Delta Saber missile / special weapons (Weapon_DSaber_P_wep_*) live in variant schemas (439b1f29, 28295901), not the main WEAPON schema, so the schema-only filter missed 10 of them. Match all `Weapon`-shaped records by table name instead (excluding the EnumWeapon name lists), deduped by id: 121 → 131 weapons. Co-Authored-By: Claude Opus 4.8 --- crates/sylpheed-formats/src/game_data.rs | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crates/sylpheed-formats/src/game_data.rs b/crates/sylpheed-formats/src/game_data.rs index 3cdc95c..8b5fb39 100644 --- a/crates/sylpheed-formats/src/game_data.rs +++ b/crates/sylpheed-formats/src/game_data.rs @@ -132,9 +132,27 @@ impl Weapon { } } -/// Load every weapon from a pak (e.g. `GP_MAIN_GAME_E.pak`). +/// Load every weapon from a pak. Catches all `Weapon`-shaped records, not just the +/// main [`schema::WEAPON`] — player special/missile weapons live in variant schemas +/// (e.g. `Weapon_DSaber_P_wep_*` in `GP_HANGAR_ARSENAL.pak`). Deduplicated by id. pub fn load_weapons(pak: &PakArchive) -> Vec { - load_table(pak, schema::WEAPON, Weapon::from_idxd) + let mut seen = std::collections::BTreeSet::new(); + let mut out = Vec::new(); + for e in pak.entries() { + let Ok(b) = pak.read(e) else { continue }; + let Ok(o) = IdxdObject::parse(&b) else { continue }; + // `Weapon`/`QWeapon`/… but not the `EnumWeapon` name lists. + let t0 = o.tokens().first().map(String::as_str).unwrap_or(""); + if !t0.ends_with("Weapon") || t0.contains("Enum") { + continue; + } + if let Some(w) = Weapon::from_idxd(&o) { + if w.id.as_deref().is_some_and(|id| seen.insert(id.to_string())) { + out.push(w); + } + } + } + out } // ── Craft / unit ────────────────────────────────────────────────────────────────