UnitDebuff's dispelType is SpellDispelType's column 11 on every locale, as 1.12.1 returns it (#1975)
UnitDebuff (0x5198f0) reads the class's record at [0xc0d83c], gates on [+0x28] and returns [+0x2c], column 11: Magic, Curse, Disease, Poison on every install (0x519a89). FrameXML keys DebuffTypeColor on those words in every locale. benilla returned the Name block at the locale slot instead, Magie on a German install, so DebuffTypeColor[debuffType] was nil and TargetFrame.lua:303 raised "attempt to index local `color'" on every frame a debuff with a dispel class sat on the target. The aura tooltip (0x52f880) keeps the locale's word: SpellDispelTypes now holds both, name (column 11) and label (the Name block), and the tooltip reads dispel_label. locale_routing probes the label, the localized string. Verified: on a German install real_dispel_types_name_only_what_the_gate_allows failed before (Magie for Magic) and passes now, and the new the_key_is_english_on_every_locale_and_the_label_is_the_locales passes on German and English data; benilla-formats lib tests 487/487 on English data; on German data the 55 failures left are the existing English-name expectations, none new. cargo test -p benilla-app --lib, fmt, clippy -D warnings green. Built on macOS only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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<u32, String>,
|
||||
labels: HashMap<u32, String>,
|
||||
}
|
||||
|
||||
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<SpellDispelTypes> {
|
||||
}
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Item = (u32, &SpellDisplay)> + '_ {
|
||||
self.spells.iter().map(|(id, s)| (*id, s))
|
||||
|
||||
Reference in New Issue
Block a user