wow_wmo/
version.rs

1/// WMO format versions corresponding to different WoW expansions/patches
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Ord, PartialOrd)]
3#[repr(u32)]
4pub enum WmoVersion {
5    /// Classic/Vanilla (1.x)
6    Classic = 17,
7
8    /// The Burning Crusade (2.x)
9    Tbc = 18,
10
11    /// Wrath of the Lich King (3.x)
12    Wotlk = 19,
13
14    /// Cataclysm (4.x)
15    Cataclysm = 20,
16
17    /// Mists of Pandaria (5.x)
18    Mop = 21,
19
20    /// Warlords of Draenor (6.x)
21    Wod = 22,
22
23    /// Legion (7.x)
24    Legion = 23,
25
26    /// Battle for Azeroth (8.x)
27    Bfa = 24,
28
29    /// Shadowlands (9.x)
30    Shadowlands = 25,
31
32    /// Dragonflight (10.x)
33    Dragonflight = 26,
34
35    /// The War Within (11.x)
36    WarWithin = 27,
37}
38
39impl WmoVersion {
40    /// Convert a raw version number to a WmoVersion
41    pub fn from_raw(raw: u32) -> Option<Self> {
42        match raw {
43            17 => Some(Self::Classic),
44            18 => Some(Self::Tbc),
45            19 => Some(Self::Wotlk),
46            20 => Some(Self::Cataclysm),
47            21 => Some(Self::Mop),
48            22 => Some(Self::Wod),
49            23 => Some(Self::Legion),
50            24 => Some(Self::Bfa),
51            25 => Some(Self::Shadowlands),
52            26 => Some(Self::Dragonflight),
53            27 => Some(Self::WarWithin),
54            _ => None,
55        }
56    }
57
58    /// Get the raw version number
59    pub fn to_raw(self) -> u32 {
60        self as u32
61    }
62
63    /// Get the expansion name as a string
64    pub fn expansion_name(self) -> &'static str {
65        match self {
66            Self::Classic => "Classic/Vanilla",
67            Self::Tbc => "The Burning Crusade",
68            Self::Wotlk => "Wrath of the Lich King",
69            Self::Cataclysm => "Cataclysm",
70            Self::Mop => "Mists of Pandaria",
71            Self::Wod => "Warlords of Draenor",
72            Self::Legion => "Legion",
73            Self::Bfa => "Battle for Azeroth",
74            Self::Shadowlands => "Shadowlands",
75            Self::Dragonflight => "Dragonflight",
76            Self::WarWithin => "The War Within",
77        }
78    }
79
80    /// Get the minimum supported version
81    pub fn min_supported() -> Self {
82        Self::Classic
83    }
84
85    /// Get the maximum supported version
86    pub fn max_supported() -> Self {
87        Self::WarWithin
88    }
89
90    /// Check if this version supports a particular feature
91    pub fn supports_feature(self, feature: WmoFeature) -> bool {
92        self >= feature.min_version()
93    }
94}
95
96/// Features introduced in different WMO versions
97#[derive(Debug, Clone, Copy, PartialEq, Eq)]
98pub enum WmoFeature {
99    /// Base WMO features (available in all versions)
100    Base,
101
102    /// Improved lighting introduced in TBC
103    ImprovedLighting,
104
105    /// Skybox references introduced in WotLK
106    SkyboxReferences,
107
108    /// Destructible objects introduced in Cataclysm
109    DestructibleObjects,
110
111    /// Extended materials introduced in MoP
112    ExtendedMaterials,
113
114    /// Liquid data v2 introduced in WoD
115    LiquidV2,
116
117    /// Global ambient color introduced in Legion
118    GlobalAmbientColor,
119
120    /// Particle systems introduced in BfA
121    ParticleSystems,
122
123    /// Shadow batches introduced in Shadowlands
124    ShadowBatches,
125
126    /// Ray-traced shadows introduced in Dragonflight
127    RayTracedShadows,
128
129    /// Enhanced materials introduced in The War Within
130    EnhancedMaterials,
131}
132
133impl WmoFeature {
134    /// Get the minimum version that supports this feature
135    pub fn min_version(self) -> WmoVersion {
136        match self {
137            Self::Base => WmoVersion::Classic,
138            Self::ImprovedLighting => WmoVersion::Tbc,
139            Self::SkyboxReferences => WmoVersion::Wotlk,
140            Self::DestructibleObjects => WmoVersion::Cataclysm,
141            Self::ExtendedMaterials => WmoVersion::Mop,
142            Self::LiquidV2 => WmoVersion::Wod,
143            Self::GlobalAmbientColor => WmoVersion::Legion,
144            Self::ParticleSystems => WmoVersion::Bfa,
145            Self::ShadowBatches => WmoVersion::Shadowlands,
146            Self::RayTracedShadows => WmoVersion::Dragonflight,
147            Self::EnhancedMaterials => WmoVersion::WarWithin,
148        }
149    }
150}