diff options
| author | KingPin <none@none> | 2008-11-06 08:20:26 -0600 |
|---|---|---|
| committer | KingPin <none@none> | 2008-11-06 08:20:26 -0600 |
| commit | 5746d0e98d8a5c4af96102835d501c47ed370def (patch) | |
| tree | a17851f0bc08626df74b690df53f28754e9e89fe /contrib | |
| parent | c74f9b4a685a899091dc7cb1b5db5c494ed12b9a (diff) | |
[svn] * Avoid access to bag item prototype for getting bag size, use related item
update field instead as more fast source. source mangos.
* Further reduce of DB access in guild handlers.
* Multi-locale DBC extracting - source Foks
*** Devs not responsible if all your player items drop to the ground and get eaten by ants or rabbits.. or some kind of wierd ant-rabbits..
--HG--
branch : trunk
Diffstat (limited to 'contrib')
| -rw-r--r-- | contrib/extractor/System.cpp | 154 | ||||
| -rw-r--r-- | contrib/extractor/ad.exe | bin | 167936 -> 167936 bytes | |||
| -rw-r--r-- | contrib/extractor/libmpq/mpq.cpp | 2 | ||||
| -rw-r--r-- | contrib/extractor/libmpq/mpq.h | 2 | ||||
| -rw-r--r-- | contrib/extractor/libmpq/parser.cpp | 2 | ||||
| -rw-r--r-- | contrib/extractor/mpq_libmpq.cpp | 2 | ||||
| -rw-r--r-- | contrib/extractor/mpq_libmpq.h | 9 |
7 files changed, 97 insertions, 74 deletions
diff --git a/contrib/extractor/System.cpp b/contrib/extractor/System.cpp index 090fc557ed7..b7ece7e766e 100644 --- a/contrib/extractor/System.cpp +++ b/contrib/extractor/System.cpp @@ -39,7 +39,7 @@ enum Extract }; int extract = EXTRACT_MAP | EXTRACT_DBC; -static char* const langs[]={"deDE", "enGB", "enUS", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" }; +static char* const langs[]={"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU" }; #define LANG_COUNT 12 #define ADT_RES 64 @@ -167,11 +167,11 @@ void ExtractMapsFromMpq() path += "/maps/"; CreateDir(path); - for(int x = 0; x < ADT_RES; ++x) + for(unsigned int x = 0; x < ADT_RES; ++x) { - for(int y = 0; y < ADT_RES; ++y) + for(unsigned int y = 0; y < ADT_RES; ++y) { - for(int z = 0; z < map_count; ++z) + for(unsigned int z = 0; z < map_count; ++z) { sprintf(mpq_filename,"World\\Maps\\%s\\%s_%u_%u.adt",map_ids[z].name,map_ids[z].name,x,y); sprintf(output_filename,"%s/maps/%03u%02u%02u.map",output_path,map_ids[z].id,y,x); @@ -189,7 +189,7 @@ void ExtractMapsFromMpq() //bool WMO(char* filename); -void ExtractDBCFiles() +void ExtractDBCFiles(int locale, bool basicLocale) { printf("Extracting dbc files...\n"); @@ -198,26 +198,30 @@ void ExtractDBCFiles() // get DBC file list for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) { - vector<string> files = (*i)->GetFileList(); + vector<string> files; + (*i)->GetFileListTo(files); for (vector<string>::iterator iter = files.begin(); iter != files.end(); ++iter) if (iter->rfind(".dbc") == iter->length() - strlen(".dbc")) dbcfiles.insert(*iter); } - std::string path = output_path; + string path = output_path; path += "/dbc/"; CreateDir(path); + if(!basicLocale) + { + path += langs[locale]; + path += "/"; + CreateDir(path); + } // extract DBCs int count = 0; for (set<string>::iterator iter = dbcfiles.begin(); iter != dbcfiles.end(); ++iter) { - string filename = output_path; - filename += "/dbc/"; + string filename = path; filename += (iter->c_str() + strlen("DBFilesClient\\")); - //cout << filename << endl; - FILE *output=fopen(filename.c_str(),"wb"); if(!output) { @@ -231,27 +235,10 @@ void ExtractDBCFiles() fclose(output); ++count; } - printf("Extracted %u DBC files\n", count); -} - -int GetLocale() -{ - for (int i = 0; i < LANG_COUNT; i++) - { - char tmp1[512]; - sprintf(tmp1, "%s/Data/%s/locale-%s.MPQ", input_path, langs[i], langs[i]); - if (FileExists(tmp1)) - { - printf("Detected locale: %s\n", langs[i]); - return i; - } - } - - printf("Could not detect locale.\n"); - return -1; + printf("Extracted %u DBC files\n\n", count); } -void LoadMPQFiles(int const locale) +void LoadLocaleMPQFiles(int const locale) { char filename[512]; @@ -265,56 +252,95 @@ void LoadMPQFiles(int const locale) sprintf(ext, "-%i", i); sprintf(filename,"%s/Data/%s/patch-%s%s.MPQ",input_path,langs[locale],langs[locale],ext); - if(!FileExists(filename)) - break; - new MPQArchive(filename); + if(FileExists(filename)) + new MPQArchive(filename); } +} + +void LoadCommonMPQFiles() +{ + char filename[512]; - //need those files only if extract maps - if(extract & EXTRACT_MAP) + sprintf(filename,"%s/Data/common.MPQ",input_path); + new MPQArchive(filename); + sprintf(filename,"%s/Data/expansion.MPQ",input_path); + new MPQArchive(filename); + for(int i = 1; i < 5; ++i) { - sprintf(filename,"%s/Data/common.MPQ",input_path); - new MPQArchive(filename); - sprintf(filename,"%s/Data/expansion.MPQ",input_path); - new MPQArchive(filename); - - for(int i = 1; i < 5; ++i) - { - char ext[3] = ""; - if(i > 1) - sprintf(ext, "-%i", i); - - sprintf(filename,"%s/Data/patch%s.MPQ",input_path,ext); - if(!FileExists(filename)) - break; - new MPQArchive(filename); - } + char ext[3] = ""; + if(i > 1) + sprintf(ext, "-%i", i); + if(FileExists(filename)) + new MPQArchive(filename); } } +inline void CloseMPQFiles() +{ + for(ArchiveSet::iterator j = gOpenArchives.begin(); j != gOpenArchives.end();++j) (*j)->close(); + gOpenArchives.clear(); +} + int main(int argc, char * arg[]) { printf("Map & DBC Extractor\n"); - printf("===================\n"); + printf("===================\n\n"); HandleArgs(argc, arg); - int const locale = GetLocale(); - if(locale < 0) - return 1; - - LoadMPQFiles(locale); + int FirstLocale = -1; + + for (int i = 0; i < LANG_COUNT; i++) + { + char tmp1[512]; + sprintf(tmp1, "%s/Data/%s/locale-%s.MPQ", input_path, langs[i], langs[i]); + if (FileExists(tmp1)) + { + printf("Detected locale: %s\n", langs[i]); + + //Open MPQs + LoadLocaleMPQFiles(i); + + if((extract & EXTRACT_DBC) == 0) + { + FirstLocale=i; + break; + } - if(extract & EXTRACT_DBC) - ExtractDBCFiles(); + //Extract DBC files + if(FirstLocale<0) + { + ExtractDBCFiles(i, true); + FirstLocale = i; + } + else + ExtractDBCFiles(i, false); + + //Close MPQs + CloseMPQFiles(); + } + } - if(extract & EXTRACT_MAP) + if(FirstLocale<0) + { + printf("No locales detected\n"); + return 0; + } + + if (extract & EXTRACT_MAP) + { + printf("Using locale: %s\n", langs[FirstLocale]); + + // Open MPQs + LoadLocaleMPQFiles(FirstLocale); + LoadCommonMPQFiles(); + + // Extract maps ExtractMapsFromMpq(); - //Close MPQs - for(ArchiveSet::iterator i = gOpenArchives.begin(); i != gOpenArchives.end();++i) - (*i)->close(); - gOpenArchives.clear(); + // Close MPQs + CloseMPQFiles(); + } return 0; } diff --git a/contrib/extractor/ad.exe b/contrib/extractor/ad.exe Binary files differindex e9606e8e0eb..1f2c45dfc56 100644 --- a/contrib/extractor/ad.exe +++ b/contrib/extractor/ad.exe diff --git a/contrib/extractor/libmpq/mpq.cpp b/contrib/extractor/libmpq/mpq.cpp index 9582b72b560..9d1cd883386 100644 --- a/contrib/extractor/libmpq/mpq.cpp +++ b/contrib/extractor/libmpq/mpq.cpp @@ -199,7 +199,7 @@ int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype) { /* * This function returns some useful file information. */ -int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int number) { +int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int unsigned number) { int blockindex = number; //-1; int i = 0; mpq_block *mpq_b = NULL; diff --git a/contrib/extractor/libmpq/mpq.h b/contrib/extractor/libmpq/mpq.h index 0a136f95f30..55b72ad75a9 100644 --- a/contrib/extractor/libmpq/mpq.h +++ b/contrib/extractor/libmpq/mpq.h @@ -198,7 +198,7 @@ extern int libmpq_archive_open(mpq_archive *mpq_a, unsigned char *mpq_filename); extern int libmpq_archive_close(mpq_archive *mpq_a); extern int libmpq_archive_info(mpq_archive *mpq_a, unsigned int infotype); //extern int libmpq_file_extract(mpq_archive *mpq_a, const int number); -extern int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const int number); +extern int libmpq_file_info(mpq_archive *mpq_a, unsigned int infotype, const unsigned int number); extern char *libmpq_file_name(mpq_archive *mpq_a, const int number); extern int libmpq_file_number(mpq_archive *mpq_a, const char *name); extern int libmpq_file_check(mpq_archive *mpq_a, void *file, int type); diff --git a/contrib/extractor/libmpq/parser.cpp b/contrib/extractor/libmpq/parser.cpp index b7a70400f5a..435395b8767 100644 --- a/contrib/extractor/libmpq/parser.cpp +++ b/contrib/extractor/libmpq/parser.cpp @@ -79,7 +79,7 @@ int libmpq_conf_parse_line(char *line, char *search_value, char *return_value, i } /* now search for comment in this line */ - for (i = 0; i < strlen(line); i++) { + for (i = 0; i < int(strlen(line)); i++) { if (line[i] == '#') { pos = i - 1; break; diff --git a/contrib/extractor/mpq_libmpq.cpp b/contrib/extractor/mpq_libmpq.cpp index 98d114c572f..41253b242b3 100644 --- a/contrib/extractor/mpq_libmpq.cpp +++ b/contrib/extractor/mpq_libmpq.cpp @@ -71,7 +71,7 @@ MPQFile::MPQFile(const char* filename): continue; //file not found } - int fileno = blockindex; + uint32 fileno = blockindex; //int fileno = libmpq_file_number(&mpq_a, filename); //if(fileno == LIBMPQ_EFILE_NOT_FOUND) diff --git a/contrib/extractor/mpq_libmpq.h b/contrib/extractor/mpq_libmpq.h index 542e7b21d17..9b4984a50e4 100644 --- a/contrib/extractor/mpq_libmpq.h +++ b/contrib/extractor/mpq_libmpq.h @@ -51,14 +51,12 @@ public: return nullhash; } - vector<string> GetFileList() { - vector<string> filelist; - + void GetFileListTo(vector<string>& filelist) { mpq_hash hash = GetHashEntry("(listfile)"); uint32 blockindex = hash.blockindex; if ((blockindex == 0xFFFFFFFF) || (blockindex == 0)) - return filelist; + return; uint32 size = libmpq_file_info(&mpq_a, LIBMPQ_FILE_UNCOMPRESSED_SIZE, blockindex); char *buffer = new char[size]; @@ -79,8 +77,7 @@ public: token = strtok(NULL, seps); } - delete buffer; - return filelist; + delete[] buffer; } }; typedef std::deque<MPQArchive*> ArchiveSet; |
