1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use crate::chunk_discovery::ChunkDiscovery;
/// WMO version based on expansion and chunk patterns
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WmoVersion {
/// Classic/Vanilla (1.12.1) and TBC (2.4.3)
Classic,
/// Wrath of the Lich King (3.3.5)
WotLK,
/// Cataclysm (4.3.4) - introduced MCVP chunk
Cataclysm,
/// Mists of Pandaria (5.4.8)
MoP,
/// Warlords of Draenor (6.2.4) - introduced GFID chunk
Warlords,
/// Legion and later
Legion,
}
/// Detect WMO version based on chunk patterns
///
/// Note: All versions use format version 17, so we detect by chunk presence:
/// - MCVP → Cataclysm or later
/// - GFID → Warlords or later
/// - Otherwise → Classic/TBC/WotLK
pub fn detect_version(discovery: &ChunkDiscovery) -> WmoVersion {
// Collect chunk IDs for pattern matching
let chunk_ids: Vec<&str> = discovery.chunks.iter().map(|c| c.id.as_str()).collect();
// Check for version-specific chunks
if chunk_ids.contains(&"GFID") {
// GFID was introduced in Warlords of Draenor
WmoVersion::Warlords
} else if chunk_ids.contains(&"MCVP") {
// MCVP was introduced in Cataclysm for vertex painting
WmoVersion::Cataclysm
} else {
// No version-specific chunks - likely Classic, TBC, or WotLK
// These can't be distinguished by chunks alone
WmoVersion::Classic
}
}
impl WmoVersion {
/// Check if this version supports a specific feature
pub fn supports_feature(&self, feature: WmoFeature) -> bool {
match feature {
WmoFeature::VertexPainting => {
matches!(
self,
WmoVersion::Cataclysm
| WmoVersion::MoP
| WmoVersion::Warlords
| WmoVersion::Legion
)
}
WmoFeature::FileDataId => {
matches!(self, WmoVersion::Warlords | WmoVersion::Legion)
}
}
}
/// Get the earliest expansion that supports this version
pub fn expansion_name(&self) -> &'static str {
match self {
WmoVersion::Classic => "Classic/TBC",
WmoVersion::WotLK => "Wrath of the Lich King",
WmoVersion::Cataclysm => "Cataclysm",
WmoVersion::MoP => "Mists of Pandaria",
WmoVersion::Warlords => "Warlords of Draenor",
WmoVersion::Legion => "Legion+",
}
}
}
/// WMO feature flags for version compatibility
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WmoFeature {
/// Vertex painting support (Cataclysm+)
VertexPainting,
/// File data ID support (Warlords+)
FileDataId,
}