Changeset 177 for trunk/contrib
- Timestamp:
- 11/19/08 13:43:30 (17 years ago)
- Location:
- trunk/contrib/extractor
- Files:
-
- 7 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/contrib/extractor/System.cpp
r2 r177 40 40 int extract = EXTRACT_MAP | EXTRACT_DBC; 41 41 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" }; 43 43 #define LANG_COUNT 12 44 44 … … 168 168 CreateDir(path); 169 169 170 for( int x = 0; x < ADT_RES; ++x)171 { 172 for( int y = 0; y < ADT_RES; ++y)173 { 174 for( int z = 0; z < map_count; ++z)170 for(unsigned int x = 0; x < ADT_RES; ++x) 171 { 172 for(unsigned int y = 0; y < ADT_RES; ++y) 173 { 174 for(unsigned int z = 0; z < map_count; ++z) 175 175 { 176 176 sprintf(mpq_filename,"World\\Maps\\%s\\%s_%u_%u.adt",map_ids[z].name,map_ids[z].name,x,y); … … 190 190 //bool WMO(char* filename); 191 191 192 void ExtractDBCFiles( )192 void ExtractDBCFiles(int locale, bool basicLocale) 193 193 { 194 194 printf("Extracting dbc files...\n"); … … 199 199 for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) 200 200 { 201 vector<string> files = (*i)->GetFileList(); 201 vector<string> files; 202 (*i)->GetFileListTo(files); 202 203 for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter) 203 204 if (iter->rfind(".dbc") == iter->length() - strlen(".dbc")) … … 205 206 } 206 207 207 st d::string path = output_path;208 string path = output_path; 208 209 path += "/dbc/"; 209 210 CreateDir(path); 211 if(!basicLocale) 212 { 213 path += langs[locale]; 214 path += "/"; 215 CreateDir(path); 216 } 210 217 211 218 // extract DBCs … … 213 220 for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) 214 221 { 215 string filename = output_path; 216 filename += "/dbc/"; 222 string filename = path; 217 223 filename += (iter->c_str() + strlen("DBFilesClient\\")); 218 219 //cout << filename << endl;220 224 221 225 FILE *output=fopen(filename.c_str(),"wb"); … … 232 236 ++count; 233 237 } 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 239 293 for (int i = 0; i < LANG_COUNT; i++) 240 294 { … … 244 298 { 245 299 printf("Detected locale: %s\n", langs[i]); 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 312 339 ExtractMapsFromMpq(); 313 340 314 //Close MPQs 315 for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) 316 (*i)->close(); 317 gOpenArchives.clear(); 341 // Close MPQs 342 CloseMPQFiles(); 343 } 318 344 319 345 return 0; -
trunk/contrib/extractor/libmpq/mpq.cpp
r168 r177 200 200 * This function returns some useful file information. 201 201 */ 202 int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int number) {202 int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int unsigned number) { 203 203 int blockindex = number; //-1; 204 204 int i = 0; -
trunk/contrib/extractor/libmpq/mpq.h
r2 r177 199 199 extern int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype); 200 200 //extern int libmpq_file_extract(mpq_archive *mpq_a, const int number); 201 extern int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int number);201 extern int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number); 202 202 extern char *libmpq_file_name(mpq_archive *mpq_a, const int number); 203 203 extern int libmpq_file_number(mpq_archive *mpq_a, const char *name); -
trunk/contrib/extractor/libmpq/parser.cpp
r2 r177 80 80 81 81 /* now search for comment in this line */ 82 for (i = 0; i < strlen(line); i++) {82 for (i = 0; i < int(strlen(line)); i++) { 83 83 if (line[i] == '#') { 84 84 pos = i - 1; -
trunk/contrib/extractor/mpq_libmpq.cpp
r2 r177 72 72 } 73 73 74 intfileno = blockindex;74 uint32 fileno = blockindex; 75 75 76 76 //int fileno = libmpq_file_number(&mpq_a, filename); -
trunk/contrib/extractor/mpq_libmpq.h
r2 r177 52 52 } 53 53 54 vector<string> GetFileList() { 55 vector<string> filelist; 56 54 void GetFileListTo(vector<string>& filelist) { 57 55 mpq_hash hash = GetHashEntry("(listfile)"); 58 56 uint32 blockindex = hash.blockindex; 59 57 60 58 if ((blockindex == 0xFFFFFFFF) || (blockindex == 0)) 61 return filelist;59 return; 62 60 63 61 uint32 size = libmpq_file_info(&mpq_a, LIBMPQ_FILE_UNCOMPRESSED_SIZE, blockindex); … … 80 78 } 81 79 82 delete buffer; 83 return filelist; 80 delete[] buffer; 84 81 } 85 82 };