diff --git a/crates/benilla-app/src/ui_tooltip/spell_feed.rs b/crates/benilla-app/src/ui_tooltip/spell_feed.rs index 66d601863..1dd225791 100644 --- a/crates/benilla-app/src/ui_tooltip/spell_feed.rs +++ b/crates/benilla-app/src/ui_tooltip/spell_feed.rs @@ -361,7 +361,7 @@ pub(super) fn build_view( name: d.name.clone(), rank: d.rank.clone(), // The aura variant's right column (`0x52f8e5`), gated on `SpellDispelType.dbc` `[+0x28]`. - dispel_type: spells.catalog.dispel_name(d).map(str::to_string), + dispel_type: spells.catalog.dispel_label(d).map(str::to_string), cost, range, cast_time, diff --git a/crates/benilla-formats/src/locale_routing.rs b/crates/benilla-formats/src/locale_routing.rs index 32051d3db..b05344d58 100644 --- a/crates/benilla-formats/src/locale_routing.rs +++ b/crates/benilla-formats/src/locale_routing.rs @@ -210,9 +210,10 @@ const PROBES: &[(&str, Probe)] = &[ out }, ), + // The label; the key (`name`) is column 11, English on every locale by design. ("SpellDispelType.Name", |c| { let cat = crate::load_spell_dispel_types(c).unwrap(); - owned((0..10).map(|id| cat.name(id))) + owned((0..10).map(|id| cat.label(id))) }), ("SpellFocusObject.Name", |c| { let cat = crate::load_spell_focus_catalog(c).unwrap(); diff --git a/crates/benilla-formats/src/spells/dispel_types.rs b/crates/benilla-formats/src/spells/dispel_types.rs index 2fccc2714..8681b5aef 100644 --- a/crates/benilla-formats/src/spells/dispel_types.rs +++ b/crates/benilla-formats/src/spells/dispel_types.rs @@ -1,8 +1,9 @@ -//! `SpellDispelType.dbc`: the dispel class name the aura tooltip (`0x52f880`) shows and -//! `UnitDebuff` returns as its `dispelType`, which FrameXML's `DebuffTypeColor` keys the -//! debuff border on. A row is named only when column 10 (`+0x28`) is nonzero (`0x52f906`): on 5875 -//! that is ids 1-4, so Stealth and Invisibility carry names that never print. Column 11 repeats -//! the name on those four rows; the tooltip does not read it. +//! `SpellDispelType.dbc`: the dispel class. A row is named only when column 10 (`+0x28`) is +//! nonzero (`0x52f906`, `0x519a82`): on 5875 that is ids 1-4, so Stealth and Invisibility carry +//! names that never print. Two strings name a class. Column 11 (`+0x2c`), English on every locale, +//! is the `dispelType` `UnitDebuff` returns (`0x519a89`), which FrameXML's `DebuffTypeColor` keys +//! the debuff border on in every locale's FrameXML. The `Name` block (columns 1-8) at the client's +//! locale slot is the word the aura tooltip prints (`0x52f880`): `Magie` on a German install. use std::collections::HashMap; @@ -10,20 +11,28 @@ use crate::Chain; use anyhow::{Context, Result}; use benilla_dbc::{FieldType, Schema, SchemaField}; -use crate::dbc::{loc_str, parse, u32_at}; +use crate::dbc::{loc_str, parse, str_at, u32_at}; /// The named dispel classes by `Spell.dbc` `Dispel` id; a row the gate withholds is absent. #[derive(Default)] pub struct SpellDispelTypes { names: HashMap, + labels: HashMap, } impl SpellDispelTypes { - /// The class name; `None` for no dispel class (0) or one the gate withholds. + /// The class's key, column 11: `Magic` on every locale, as `UnitDebuff` returns it; `None` for + /// no dispel class (0) or one the gate withholds. pub fn name(&self, dispel: u32) -> Option<&str> { self.names.get(&dispel).map(String::as_str) } + /// The class's word at the client's locale slot, which the aura tooltip prints; `None` as for + /// [`Self::name`]. + pub fn label(&self, dispel: u32) -> Option<&str> { + self.labels.get(&dispel).map(String::as_str) + } + pub fn len(&self) -> usize { self.names.len() } @@ -45,21 +54,24 @@ pub fn load_spell_dispel_types(chain: &mut Chain) -> Result { } schema.add_field(SchemaField::new("NameFlags", FieldType::UInt32)); schema.add_field(SchemaField::new("Named", FieldType::UInt32)); - schema.add_field(SchemaField::new("Unknown11", FieldType::String)); + schema.add_field(SchemaField::new("InternalName", FieldType::String)); let set = parse(&bytes, schema, "SpellDispelType.dbc")?; let locale = chain.locale(); - let mut names = HashMap::new(); + let (mut names, mut labels) = (HashMap::new(), HashMap::new()); for r in set.records() { let Some(id) = u32_at(r, 0) else { continue }; // The gate first: a 0 here withholds the name however good the string is (Stealth, id 5). if u32_at(r, 10).unwrap_or(0) == 0 { continue; } - if let Some(name) = loc_str(&set, r, 1, locale).filter(|n| !n.is_empty()) { + if let Some(name) = str_at(&set, r, 11).filter(|n| !n.is_empty()) { names.insert(id, name); } + if let Some(label) = loc_str(&set, r, 1, locale) { + labels.insert(id, label); + } } - Ok(SpellDispelTypes { names }) + Ok(SpellDispelTypes { names, labels }) } #[cfg(test)] @@ -82,4 +94,27 @@ mod tests { assert_eq!(types.name(0), None, "no dispel class"); assert_eq!(types.len(), 4, "exactly the four the gate allows"); } + + /// The key is column 11 on every install, the label the locale slot's word: one and the same + /// on an English install, `Magie` against `Magic` on a German one, where a localized key would + /// miss `DebuffTypeColor` and break `TargetFrame.lua`'s debuff border. + #[test] + fn the_key_is_english_on_every_locale_and_the_label_is_the_locales() { + let data = crate::wow_data_or_skip!(); + let mut chain = crate::open_chain(&data).expect("open chain"); + let types = load_spell_dispel_types(&mut chain).expect("load SpellDispelType"); + for (id, key) in [(1, "Magic"), (2, "Curse"), (3, "Disease"), (4, "Poison")] { + assert_eq!(types.name(id), Some(key)); + let label = types.label(id).expect("a gated row has a label"); + eprintln!("dispel {id}: key {key}, label {label}"); + if chain.locale().index() == 0 { + assert_eq!(label, key, "enUS reads the key's own word"); + } + } + if chain.locale().name() == "deDE" { + assert_eq!(types.label(1), Some("Magie")); + assert_eq!(types.label(4), Some("Gift")); + } + assert_eq!(types.label(5), None, "the gate withholds the label too"); + } } diff --git a/crates/benilla-formats/src/spells/mod.rs b/crates/benilla-formats/src/spells/mod.rs index 35cd96b34..a46eb790c 100644 --- a/crates/benilla-formats/src/spells/mod.rs +++ b/crates/benilla-formats/src/spells/mod.rs @@ -328,12 +328,19 @@ impl SpellCatalog { self.spells.get(&id) } - /// The dispel class's name, for the aura tooltip and the debuff border's `debuffType`; `None` - /// when `SpellDispelType.dbc`'s `[+0x28]` gate withholds it. + /// The dispel class's key, the `debuffType` `UnitDebuff` returns (`0x519a89`) and the debuff + /// border keys `DebuffTypeColor` on: `SpellDispelType.dbc` column 11, English on every locale. + /// `None` when the `[+0x28]` gate withholds it. pub fn dispel_name(&self, display: &SpellDisplay) -> Option<&str> { self.dispel_types.name(display.dispel) } + /// The dispel class's word at the client's locale slot, the aura tooltip's right column + /// (`0x52f880`); `None` as for [`Self::dispel_name`]. + pub fn dispel_label(&self, display: &SpellDisplay) -> Option<&str> { + self.dispel_types.label(display.dispel) + } + /// Every loaded spell, unordered. pub fn iter(&self) -> impl Iterator + '_ { self.spells.iter().map(|(id, s)| (*id, s))