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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//! Manufacturer and weapon type extraction from game directories
use std::collections::HashMap;
use std::fs;
use std::path::Path;
use super::types::{manufacturer_names, Manufacturer, ManufacturerRef, WeaponType};
/// Extract manufacturers from game files by walking directory structure
pub fn extract_manufacturers(extract_dir: &Path) -> HashMap<String, Manufacturer> {
let mfr_names = manufacturer_names();
let mut manufacturers: HashMap<String, Manufacturer> = HashMap::new();
// Search locations for manufacturer codes
let search_paths = [
"OakGame/Content/Gear/Weapons/_Manufacturer",
"OakGame/Content/Gear/Weapons/_Shared/BalanceData",
"OakGame/Content/Gear/Weapons/_Shared/Materials",
"OakGame/Content/Gear/_Shared/Materials/Materials",
"OakGame/Content/Gear/GrenadeGadgets/Manufacturer",
"OakGame/Content/Gear/shields/Manufacturer",
"OakGame/Content/Gear/Gadgets/Turrets",
];
// Also scan weapon type directories for manufacturer subdirs
let weapon_types_dir = extract_dir.join("OakGame/Content/Gear/Weapons");
if weapon_types_dir.exists() {
if let Ok(entries) = fs::read_dir(&weapon_types_dir) {
for entry in entries.flatten() {
if entry.path().is_dir() {
let dir_name = entry.file_name().to_string_lossy().to_string();
if !dir_name.starts_with('_') {
// Scan for manufacturer subdirs in each weapon type
if let Ok(mfr_entries) = fs::read_dir(entry.path()) {
for mfr_entry in mfr_entries.flatten() {
if mfr_entry.path().is_dir() {
let code = mfr_entry.file_name().to_string_lossy().to_string();
if mfr_names.contains_key(code.as_str()) {
manufacturers.entry(code.clone()).or_insert_with(|| {
Manufacturer {
code: code.clone(),
name: mfr_names
.get(code.as_str())
.unwrap_or(&code.as_str())
.to_string(),
path: None,
balance_data_path: None,
}
});
}
}
}
}
}
}
}
}
}
for search_path in &search_paths {
let search_dir = extract_dir.join(search_path);
if !search_dir.exists() {
continue;
}
if let Ok(entries) = fs::read_dir(&search_dir) {
for entry in entries.flatten() {
if entry.path().is_dir() {
let code = entry.file_name().to_string_lossy().to_string();
// Only include known manufacturer codes
if mfr_names.contains_key(code.as_str()) {
let rel_path = entry
.path()
.strip_prefix(extract_dir)
.map(|p| p.to_string_lossy().to_string())
.ok();
// Determine path type based on search location
let is_balance_data = search_path.contains("BalanceData");
manufacturers
.entry(code.clone())
.and_modify(|m| {
if is_balance_data && m.balance_data_path.is_none() {
m.balance_data_path = rel_path.clone();
} else if !is_balance_data && m.path.is_none() {
m.path = rel_path.clone();
}
})
.or_insert(Manufacturer {
code: code.clone(),
name: mfr_names
.get(code.as_str())
.unwrap_or(&code.as_str())
.to_string(),
path: if is_balance_data {
None
} else {
rel_path.clone()
},
balance_data_path: if is_balance_data { rel_path } else { None },
});
}
}
}
}
}
manufacturers
}
/// Extract weapon type data by walking the weapons directory
pub fn extract_weapon_types(extract_dir: &Path) -> HashMap<String, WeaponType> {
let mfr_names = manufacturer_names();
let mut weapon_types: HashMap<String, WeaponType> = HashMap::new();
let weapons_dir = extract_dir.join("OakGame/Content/Gear/Weapons");
if !weapons_dir.exists() {
return weapon_types;
}
if let Ok(entries) = fs::read_dir(&weapons_dir) {
for entry in entries.flatten() {
if entry.path().is_dir() {
let type_name = entry.file_name().to_string_lossy().to_string();
// Skip internal directories
if type_name.starts_with('_') {
continue;
}
let rel_path = entry
.path()
.strip_prefix(extract_dir)
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_default();
let mut manufacturers = Vec::new();
if let Ok(mfr_entries) = fs::read_dir(entry.path()) {
for mfr_entry in mfr_entries.flatten() {
if mfr_entry.path().is_dir() {
let code = mfr_entry.file_name().to_string_lossy().to_string();
let mfr_rel_path = mfr_entry
.path()
.strip_prefix(extract_dir)
.map(|p| p.to_string_lossy().to_string())
.unwrap_or_default();
manufacturers.push(ManufacturerRef {
code: code.clone(),
name: mfr_names
.get(code.as_str())
.unwrap_or(&code.as_str())
.to_string(),
path: mfr_rel_path,
});
}
}
}
weapon_types.insert(
type_name.clone(),
WeaponType {
name: type_name,
path: rel_path,
manufacturers,
},
);
}
}
}
weapon_types
}