wowlab_engine_domain/dbc/game_data/
error.rs1use super::trigger_program::MAX_TRIGGER_DEPTH;
2
3wowlab_engine_macros::define_error! {
4#[derive(Clone, Copy, Debug, Eq, PartialEq)]
5pub struct TriggerResolveError {
6 pub(super) kind: TriggerResolveErrorKind,
7}
8
9#[derive(Clone, Copy, Debug, thiserror::Error, Eq, PartialEq)]
10pub(super) enum TriggerResolveErrorKind {
11 #[error("spell {source_spell_id} effect {effect_index} has no trigger spell")]
12 MissingEdge { source_spell_id: u32, effect_index: u8 },
13 #[error("trigger chain reached spell {spell_id} with no damage or forwarding edge")]
14 MissingDamage { spell_id: u32 },
15 #[error("trigger chain at spell {spell_id} has multiple forwarding edges")]
16 AmbiguousForward { spell_id: u32 },
17 #[error("trigger chain contains a cycle at spell {spell_id}")]
18 Cycle { spell_id: u32 },
19 #[error("trigger chain from spell {source_spell_id} exceeded {MAX_TRIGGER_DEPTH} edges")]
20 DepthExceeded { source_spell_id: u32 },
21 #[error("trigger chain from spell {source_spell_id} reached invalid child spell {spell_id}")]
22 InvalidChildId { source_spell_id: u32, spell_id: u32 },
23 #[error(
24 "trigger child spell {spell_id} effect {effect_index} has unsupported semantics SE{effect_type}/AU{aura_subtype}"
25 )]
26 UnsupportedChildEffect {
27 spell_id: u32,
28 effect_index: u8,
29 effect_type: i32,
30 aura_subtype: i32,
31 },
32 #[error("trigger child spell {spell_id} effect {effect_index} names no aura to remove")]
33 MissingRemovedAura { spell_id: u32, effect_index: u8 },
34 #[error(
35 "trigger child spell {spell_id} effect {effect_index} has invalid cooldown category {category}"
36 )]
37 InvalidCooldownCategory { spell_id: u32, effect_index: u8, category: i32 },
38 #[error(
39 "trigger child spell {spell_id} effect {effect_index} has invalid cooldown amount {amount}"
40 )]
41 InvalidCooldownAmount { spell_id: u32, effect_index: u8, amount: i64 },
42 #[error("spell {spell_id} effect {effect_index} has invalid resource type {resource_type}")]
43 InvalidResourceType { spell_id: u32, effect_index: u8, resource_type: i32 },
44}
45}
46
47impl TriggerResolveError {
48 const fn new(kind: TriggerResolveErrorKind) -> Self {
49 Self { kind }
50 }
51 pub(super) const fn missing_edge(source_spell_id: u32, effect_index: u8) -> Self {
52 Self::new(TriggerResolveErrorKind::MissingEdge {
53 source_spell_id,
54 effect_index,
55 })
56 }
57 pub(super) const fn missing_damage(spell_id: u32) -> Self {
58 Self::new(TriggerResolveErrorKind::MissingDamage { spell_id })
59 }
60 pub(super) const fn ambiguous_forward(spell_id: u32) -> Self {
61 Self::new(TriggerResolveErrorKind::AmbiguousForward { spell_id })
62 }
63 pub(super) const fn cycle(spell_id: u32) -> Self {
64 Self::new(TriggerResolveErrorKind::Cycle { spell_id })
65 }
66 pub(super) const fn depth_exceeded(source_spell_id: u32) -> Self {
67 Self::new(TriggerResolveErrorKind::DepthExceeded { source_spell_id })
68 }
69 pub(super) const fn invalid_child_id(source_spell_id: u32, spell_id: u32) -> Self {
70 Self::new(TriggerResolveErrorKind::InvalidChildId {
71 source_spell_id,
72 spell_id,
73 })
74 }
75 pub(super) const fn unsupported_child_effect(
76 spell_id: u32,
77 effect_index: u8,
78 effect_type: i32,
79 aura_subtype: i32,
80 ) -> Self {
81 Self::new(TriggerResolveErrorKind::UnsupportedChildEffect {
82 spell_id,
83 effect_index,
84 effect_type,
85 aura_subtype,
86 })
87 }
88 pub(super) const fn missing_removed_aura(spell_id: u32, effect_index: u8) -> Self {
89 Self::new(TriggerResolveErrorKind::MissingRemovedAura {
90 spell_id,
91 effect_index,
92 })
93 }
94 pub(super) const fn invalid_cooldown_category(
95 spell_id: u32,
96 effect_index: u8,
97 category: i32,
98 ) -> Self {
99 Self::new(TriggerResolveErrorKind::InvalidCooldownCategory {
100 spell_id,
101 effect_index,
102 category,
103 })
104 }
105 pub(super) const fn invalid_cooldown_amount(
106 spell_id: u32,
107 effect_index: u8,
108 amount: i64,
109 ) -> Self {
110 Self::new(TriggerResolveErrorKind::InvalidCooldownAmount {
111 spell_id,
112 effect_index,
113 amount,
114 })
115 }
116 pub(super) const fn invalid_resource_type(
117 spell_id: u32,
118 effect_index: u8,
119 resource_type: i32,
120 ) -> Self {
121 Self::new(TriggerResolveErrorKind::InvalidResourceType {
122 spell_id,
123 effect_index,
124 resource_type,
125 })
126 }
127}