Skip to main content

wowlab_engine_combat/state/program/
indexes.rs

1use super::CombatProgram;
2#[cfg(any(test, feature = "test-support"))]
3use crate::state::LocalAuraIdx;
4use crate::state::{LocalRppmIdx, LocalSpellIdx};
5
6impl CombatProgram {
7    #[cfg(feature = "test-support")]
8    #[doc(hidden)]
9    #[must_use]
10    pub fn diagnostic_spell_local(&self, spell_id: u32) -> Option<LocalSpellIdx> {
11        self.lookup_spell_local(spell_id)
12    }
13
14    #[cfg(feature = "test-support")]
15    #[doc(hidden)]
16    #[must_use]
17    pub fn diagnostic_aura_local(&self, aura_id: u32) -> Option<LocalAuraIdx> {
18        self.lookup_aura_local(aura_id)
19    }
20
21    #[cfg(feature = "test-support")]
22    #[doc(hidden)]
23    #[must_use]
24    pub fn diagnostic_item_rppm_local(&self, item_id: u32) -> Option<LocalRppmIdx> {
25        self.lookup_item_rppm_local(item_id)
26    }
27
28    #[cfg(feature = "test-support")]
29    #[doc(hidden)]
30    #[must_use]
31    pub fn diagnostic_enchant_rppm_local(&self, enchantment_id: u32) -> Option<LocalRppmIdx> {
32        self.lookup_enchant_rppm_local(enchantment_id)
33    }
34
35    #[cfg(feature = "test-support")]
36    #[doc(hidden)]
37    #[must_use]
38    pub fn diagnostic_enchant_buff_spell_id(&self, enchantment_id: u32) -> Option<u32> {
39        self.lookup_enchant_buff_spell_id(enchantment_id)
40    }
41
42    pub(crate) fn spell_local(&self, spell_id: u32) -> Option<LocalSpellIdx> {
43        self.lookup_spell_local(spell_id)
44    }
45
46    #[cfg(any(test, feature = "test-support"))]
47    pub(crate) fn aura_local(&self, aura_id: u32) -> Option<LocalAuraIdx> {
48        self.lookup_aura_local(aura_id)
49    }
50
51    #[expect(dead_code, reason = "test-support diagnostic")]
52    pub(crate) fn item_rppm_local(&self, item_id: u32) -> Option<LocalRppmIdx> {
53        self.lookup_item_rppm_local(item_id)
54    }
55
56    #[cfg_attr(not(test), expect(dead_code, reason = "crate test oracle"))]
57    pub(crate) fn system_rppm_local(&self, driver_spell_id: u32) -> Option<LocalRppmIdx> {
58        wowlab_types::bench_metrics::record_keyed_lookup();
59
60        self.system_rppm_indices.get(&driver_spell_id).copied()
61    }
62
63    #[expect(dead_code, reason = "test-support diagnostic")]
64    pub(crate) fn enchant_rppm_local(&self, enchantment_id: u32) -> Option<LocalRppmIdx> {
65        self.lookup_enchant_rppm_local(enchantment_id)
66    }
67
68    #[expect(dead_code, reason = "test-support diagnostic")]
69    pub(crate) fn enchant_buff_spell_id(&self, enchantment_id: u32) -> Option<u32> {
70        self.lookup_enchant_buff_spell_id(enchantment_id)
71    }
72
73    /// Deliberately keyed reference path used to prove the finalized candidate path avoids it.
74    #[cfg(all(test, feature = "bench-metrics"))]
75    pub(crate) fn reference_spell_local(&self, spell_id: u32) -> Option<LocalSpellIdx> {
76        self.spell_local(spell_id)
77    }
78
79    /// Deliberately keyed reference path used to prove exact aura coordinates avoid it.
80    #[cfg(all(test, feature = "bench-metrics"))]
81    pub(crate) fn reference_aura_local(&self, aura_id: u32) -> Option<LocalAuraIdx> {
82        self.aura_local(aura_id)
83    }
84
85    /// Deliberately old form-definition scan retained only as a differential oracle.
86    #[cfg(all(test, feature = "bench-metrics"))]
87    pub(crate) fn reference_shapeshift_form_flags(
88        &self,
89        form: u8,
90    ) -> wowlab_engine_domain::dbc::SpellShapeshiftFormFlags {
91        self.auras
92            .iter()
93            .find_map(|aura| {
94                wowlab_types::bench_metrics::record_scanned_aura_definitions(1);
95
96                (aura.shapeshift_form == i32::from(form)).then(|| {
97                    wowlab_engine_domain::dbc::SpellShapeshiftFormFlags::from_bits_retain(
98                        aura.shapeshift_form_flags,
99                    )
100                })
101            })
102            .unwrap_or_else(wowlab_engine_domain::dbc::SpellShapeshiftFormFlags::empty)
103    }
104
105    fn lookup_spell_local(&self, spell_id: u32) -> Option<LocalSpellIdx> {
106        wowlab_types::bench_metrics::record_keyed_lookup();
107
108        self.spell_by_id.get(&spell_id).copied()
109    }
110
111    #[cfg(any(test, feature = "test-support"))]
112    fn lookup_aura_local(&self, aura_id: u32) -> Option<LocalAuraIdx> {
113        wowlab_types::bench_metrics::record_keyed_lookup();
114
115        self.aura_by_id.get(&aura_id).copied()
116    }
117
118    fn lookup_item_rppm_local(&self, item_id: u32) -> Option<LocalRppmIdx> {
119        wowlab_types::bench_metrics::record_keyed_lookup();
120
121        self.item_rppm_indices.get(&item_id).copied()
122    }
123
124    fn lookup_enchant_rppm_local(&self, enchantment_id: u32) -> Option<LocalRppmIdx> {
125        wowlab_types::bench_metrics::record_keyed_lookup();
126
127        self.enchant_rppm_indices.get(&enchantment_id).copied()
128    }
129
130    fn lookup_enchant_buff_spell_id(&self, enchantment_id: u32) -> Option<u32> {
131        wowlab_types::bench_metrics::record_keyed_lookup();
132
133        self.enchant_buff_spell_ids.get(&enchantment_id).copied()
134    }
135}