42 | | static char* const langs[]={"deDE", "enGB", "enUS", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" }; |
| 42 | static char* const langs[]={"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" }; |
234 | | printf("Extracted %u DBC files\n", count); |
235 | | } |
236 | | |
237 | | int GetLocale() |
238 | | { |
| 238 | printf("Extracted %u DBC files\n\n", count); |
| 239 | } |
| 240 | |
| 241 | void LoadLocaleMPQFiles(int const locale) |
| 242 | { |
| 243 | char filename[512]; |
| 244 | |
| 245 | sprintf(filename,"%s/Data/%s/locale-%s.MPQ",input_path,langs[locale],langs[locale]); |
| 246 | new MPQArchive(filename); |
| 247 | |
| 248 | for(int i = 1; i < 5; ++i) |
| 249 | { |
| 250 | char ext[3] = ""; |
| 251 | if(i > 1) |
| 252 | sprintf(ext, "-%i", i); |
| 253 | |
| 254 | sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ",input_path,langs[locale],langs[locale],ext); |
| 255 | if(FileExists(filename)) |
| 256 | new MPQArchive(filename); |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | void LoadCommonMPQFiles() |
| 261 | { |
| 262 | char filename[512]; |
| 263 | |
| 264 | sprintf(filename,"%s/Data/common.MPQ",input_path); |
| 265 | new MPQArchive(filename); |
| 266 | sprintf(filename,"%s/Data/expansion.MPQ",input_path); |
| 267 | new MPQArchive(filename); |
| 268 | for(int i = 1; i < 5; ++i) |
| 269 | { |
| 270 | char ext[3] = ""; |
| 271 | if(i > 1) |
| 272 | sprintf(ext, "-%i", i); |
| 273 | if(FileExists(filename)) |
| 274 | new MPQArchive(filename); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | inline void CloseMPQFiles() |
| 279 | { |
| 280 | for(ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end();++j) (*j)->close(); |
| 281 | gOpenArchives.clear(); |
| 282 | } |
| 283 | |
| 284 | int main(int argc, char * arg[]) |
| 285 | { |
| 286 | printf("Map & DBC Extractor\n"); |
| 287 | printf("===================\n\n"); |
| 288 | |
| 289 | HandleArgs(argc, arg); |
| 290 | |
| 291 | int FirstLocale = -1; |
| 292 | |
246 | | return i; |
247 | | } |
248 | | } |
249 | | |
250 | | printf("Could not detect locale.\n"); |
251 | | return -1; |
252 | | } |
253 | | |
254 | | void LoadMPQFiles(int const locale) |
255 | | { |
256 | | char filename[512]; |
257 | | |
258 | | sprintf(filename,"%s/Data/%s/locale-%s.MPQ",input_path,langs[locale],langs[locale]); |
259 | | new MPQArchive(filename); |
260 | | |
261 | | for(int i = 1; i < 5; ++i) |
262 | | { |
263 | | char ext[3] = ""; |
264 | | if(i > 1) |
265 | | sprintf(ext, "-%i", i); |
266 | | |
267 | | sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ",input_path,langs[locale],langs[locale],ext); |
268 | | if(!FileExists(filename)) |
269 | | break; |
270 | | new MPQArchive(filename); |
271 | | } |
272 | | |
273 | | //need those files only if extract maps |
274 | | if(extract & EXTRACT_MAP) |
275 | | { |
276 | | sprintf(filename,"%s/Data/common.MPQ",input_path); |
277 | | new MPQArchive(filename); |
278 | | sprintf(filename,"%s/Data/expansion.MPQ",input_path); |
279 | | new MPQArchive(filename); |
280 | | |
281 | | for(int i = 1; i < 5; ++i) |
282 | | { |
283 | | char ext[3] = ""; |
284 | | if(i > 1) |
285 | | sprintf(ext, "-%i", i); |
286 | | |
287 | | sprintf(filename,"%s/Data/patch%s.MPQ",input_path,ext); |
288 | | if(!FileExists(filename)) |
289 | | break; |
290 | | new MPQArchive(filename); |
291 | | } |
292 | | } |
293 | | } |
294 | | |
295 | | int main(int argc, char * arg[]) |
296 | | { |
297 | | printf("Map & DBC Extractor\n"); |
298 | | printf("===================\n"); |
299 | | |
300 | | HandleArgs(argc, arg); |
301 | | |
302 | | int const locale = GetLocale(); |
303 | | if(locale < 0) |
304 | | return 1; |
305 | | |
306 | | LoadMPQFiles(locale); |
307 | | |
308 | | if(extract & EXTRACT_DBC) |
309 | | ExtractDBCFiles(); |
310 | | |
311 | | if(extract & EXTRACT_MAP) |
| 300 | |
| 301 | //Open MPQs |
| 302 | LoadLocaleMPQFiles(i); |
| 303 | |
| 304 | if((extract & EXTRACT_DBC) == 0) |
| 305 | { |
| 306 | FirstLocale=i; |
| 307 | break; |
| 308 | } |
| 309 | |
| 310 | //Extract DBC files |
| 311 | if(FirstLocale<0) |
| 312 | { |
| 313 | ExtractDBCFiles(i, true); |
| 314 | FirstLocale = i; |
| 315 | } |
| 316 | else |
| 317 | ExtractDBCFiles(i, false); |
| 318 | |
| 319 | //Close MPQs |
| 320 | CloseMPQFiles(); |
| 321 | } |
| 322 | } |
| 323 | |
| 324 | if(FirstLocale<0) |
| 325 | { |
| 326 | printf("No locales detected\n"); |
| 327 | return 0; |
| 328 | } |
| 329 | |
| 330 | if (extract & EXTRACT_MAP) |
| 331 | { |
| 332 | printf("Using locale: %s\n", langs[FirstLocale]); |
| 333 | |
| 334 | // Open MPQs |
| 335 | LoadLocaleMPQFiles(FirstLocale); |
| 336 | LoadCommonMPQFiles(); |
| 337 | |
| 338 | // Extract maps |