diff options
-rw-r--r-- | src/server/collision/Maps/TileAssembler.cpp | 11 | ||||
-rw-r--r-- | src/tools/map_extractor/System.cpp | 37 | ||||
-rw-r--r-- | src/tools/map_extractor/adt.cpp | 4 | ||||
-rw-r--r-- | src/tools/map_extractor/dbcfile.h | 29 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/adtfile.cpp | 2 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/dbcfile.h | 27 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/mpqfile.cpp | 11 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/mpqfile.h | 2 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/vmapexport.cpp | 79 |
9 files changed, 99 insertions, 103 deletions
diff --git a/src/server/collision/Maps/TileAssembler.cpp b/src/server/collision/Maps/TileAssembler.cpp index aca7c02e79f..90bfe01b561 100644 --- a/src/server/collision/Maps/TileAssembler.cpp +++ b/src/server/collision/Maps/TileAssembler.cpp @@ -345,10 +345,13 @@ namespace VMAP uint32 name_length, displayId; char buff[500]; - while (!feof(model_list)) + while (true) { - if (fread(&displayId, sizeof(uint32), 1, model_list) != 1 - || fread(&name_length, sizeof(uint32), 1, model_list) != 1 + if (fread(&displayId, sizeof(uint32), 1, model_list) != 1) + if (!feof(model_list)) // EOF flag is only set after failed reading attempt + break; + + if (fread(&name_length, sizeof(uint32), 1, model_list) != 1 || name_length >= sizeof(buff) || fread(&buff, sizeof(char), name_length, model_list) != name_length) { @@ -359,7 +362,7 @@ namespace VMAP std::string model_name(buff, name_length); WorldModel_Raw raw_model; - if ( !raw_model.Read((iSrcDir + "/" + model_name).c_str()) ) + if (!raw_model.Read((iSrcDir + "/" + model_name).c_str()) ) continue; spawnedModelFiles.insert(model_name); diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index 7b591ddfc85..7f92cd56564 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -92,8 +92,17 @@ uint32 const Builds[] = {13164, 13205, 13287, 13329, 13596, 13623, 13914, 14007, #define LAST_DBC_IN_DATA_BUILD 13623 // after this build mpqs with dbc are back to locale folder #define NEW_BASE_SET_BUILD 15211 -char* const Locales[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU"}; -TCHAR* const LocalesT[] = +char const* Locales[] = +{ + "enGB", "enUS", + "deDE", "esES", + "frFR", "koKR", + "zhCN", "zhTW", + "enCN", "enTW", + "esMX", "ruRU" +}; + +TCHAR const* LocalesT[] = { _T("enGB"), _T("enUS"), _T("deDE"), _T("esES"), @@ -126,7 +135,7 @@ bool FileExists(TCHAR const* fileName) return false; } -void Usage(char* prg) +void Usage(char const* prg) { printf( "Usage:\n"\ @@ -135,12 +144,12 @@ void Usage(char* prg) "-o set output path\n"\ "-e extract only MAP(1)/DBC(2) - standard: both(3)\n"\ "-f height stored as int (less map size but lost some accuracy) 1 by default\n"\ - "-b target build (default %u)"\ + "-b target build (default %u)\n"\ "Example: %s -f 0 -i \"c:\\games\\game\"", prg, CONF_TargetBuild, prg); exit(1); } -void HandleArgs(int argc, char * arg[]) +void HandleArgs(int argc, char* arg[]) { for (int c = 1; c < argc; ++c) { @@ -268,7 +277,7 @@ uint32 ReadMapDBC() } SFileCloseFile(dbcFile); - printf("Done! (%u maps loaded)\n", map_count); + printf("Done! (%u maps loaded)\n", uint32(map_count)); return map_count; } @@ -297,7 +306,7 @@ void ReadAreaTableDBC() areas[dbc.getRecord(x).getUInt(0)] = dbc.getRecord(x).getUInt(3); SFileCloseFile(dbcFile); - printf("Done! (%u areas loaded)\n", area_count); + printf("Done! (%u areas loaded)\n", uint32(area_count)); } void ReadLiquidTypeTableDBC() @@ -1144,10 +1153,14 @@ bool LoadLocaleMPQFile(int locale) if (!SFileOpenArchive(buff, 0, MPQ_OPEN_READ_ONLY, &LocaleMpq)) { if (GetLastError() != ERROR_PATH_NOT_FOUND) + { + _tprintf(_T("\nLoading %s locale MPQs\n"), LocalesT[locale]); _tprintf(_T("Cannot open archive %s\n"), buff); + } return false; } + _tprintf(_T("\nLoading %s locale MPQs\n"), LocalesT[locale]); char const* prefix = NULL; for (int i = 0; Builds[i] && Builds[i] <= CONF_TargetBuild; ++i) { @@ -1174,8 +1187,11 @@ bool LoadLocaleMPQFile(int locale) _tprintf(_T("Cannot open patch archive %s\n"), buff); continue; } + else + _tprintf(_T("Loaded %s\n"), buff); } + printf("\n"); return true; } @@ -1183,6 +1199,7 @@ void LoadCommonMPQFiles(uint32 build) { TCHAR filename[512]; _stprintf(filename, _T("%s/Data/world.MPQ"), input_path); + _tprintf(_T("Loading common MPQ files\n")); if (!SFileOpenArchive(filename, 0, MPQ_OPEN_READ_ONLY, &WorldMpq)) { if (GetLastError() != ERROR_PATH_NOT_FOUND) @@ -1241,12 +1258,13 @@ void LoadCommonMPQFiles(uint32 build) _tprintf(_T("Loaded %s\n"), filename); } + printf("\n"); } int main(int argc, char * arg[]) { printf("Map & DBC Extractor\n"); - printf("===================\n\n"); + printf("===================\n"); HandleArgs(argc, arg); @@ -1275,6 +1293,7 @@ int main(int argc, char * arg[]) } printf("Detected client build: %u\n", build); + printf("\n"); break; } @@ -1283,10 +1302,12 @@ int main(int argc, char * arg[]) printf("Detected client build %u for locale %s\n", tempBuild, Locales[i]); if (tempBuild > CONF_TargetBuild) { + SFileCloseArchive(LocaleMpq); printf("Base locale-%s.MPQ has build higher than target build (%u > %u), nothing extracted!\n", Locales[i], tempBuild, CONF_TargetBuild); continue; } + printf("\n"); ExtractDBCFiles(i, FirstLocale < 0); ExtractDB2Files(i, FirstLocale < 0); diff --git a/src/tools/map_extractor/adt.cpp b/src/tools/map_extractor/adt.cpp index 2b7c19000cd..b235e2c1638 100644 --- a/src/tools/map_extractor/adt.cpp +++ b/src/tools/map_extractor/adt.cpp @@ -51,7 +51,7 @@ bool ADT_file::prepareLoadedData() return false; // Check and prepare MHDR - a_grid = (adt_MHDR *)(GetData()+8+version->size); + a_grid = (adt_MHDR*)(GetData()+8+version->size); if (!a_grid->prepareLoadedData()) return false; @@ -63,7 +63,7 @@ bool ADT_file::prepareLoadedData() { uint32 header = *(uint32*)ptr; uint32 size = *(uint32*)(ptr + 4); - if (header == 'MCNK') + if (header == MCNKMagic.fcc) { cells[mcnk_count / ADT_CELLS_PER_GRID][mcnk_count % ADT_CELLS_PER_GRID] = (adt_MCNK*)ptr; ++mcnk_count; diff --git a/src/tools/map_extractor/dbcfile.h b/src/tools/map_extractor/dbcfile.h index adb4a34f473..fa8734d9d63 100644 --- a/src/tools/map_extractor/dbcfile.h +++ b/src/tools/map_extractor/dbcfile.h @@ -38,22 +38,22 @@ class DBCFile float getFloat(size_t field) const { assert(field < file._fieldCount); - return *reinterpret_cast<float*>(offset+field*4); + return *reinterpret_cast<float*>(offset + field * 4); } unsigned int getUInt(size_t field) const { assert(field < file._fieldCount); - return *reinterpret_cast<unsigned int*>(offset+field*4); + return *reinterpret_cast<unsigned int*>(offset + field * 4); } int getInt(size_t field) const { assert(field < file._fieldCount); - return *reinterpret_cast<int*>(offset+field*4); + return *reinterpret_cast<int*>(offset + field * 4); } - const char *getString(size_t field) const + char const* getString(size_t field) const { assert(field < file._fieldCount); size_t stringOffset = getUInt(field); @@ -62,9 +62,9 @@ class DBCFile } private: - Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {} - unsigned char *offset; - DBCFile &file; + Record(DBCFile& file, unsigned char* offset): file(file), offset(offset) {} + DBCFile& file; + unsigned char* offset; friend class DBCFile; friend class DBCFile::Iterator; @@ -74,29 +74,30 @@ class DBCFile class Iterator { public: - Iterator(DBCFile &file, unsigned char *offset) : record(file, offset) { } + Iterator(DBCFile &file, unsigned char* offset) : record(file, offset) { } /// Advance (prefix only) - Iterator & operator++() + Iterator& operator++() { record.offset += record.file._recordSize; return *this; } /// Return address of current instance - Record const & operator*() const { return record; } - const Record* operator->() const { return &record; } + Record const& operator*() const { return record; } + Record const* operator->() const { return &record; } /// Comparison - bool operator==(const Iterator &b) const + bool operator==(Iterator const& b) const { return record.offset == b.record.offset; } - bool operator!=(const Iterator &b) const + bool operator!=(Iterator const& b) const { return record.offset != b.record.offset; } + private: Record record; }; @@ -118,7 +119,7 @@ class DBCFile size_t _recordCount; size_t _fieldCount; size_t _stringSize; - unsigned char *_data; + unsigned char* _data; unsigned char* _stringTable; }; diff --git a/src/tools/vmap4_extractor/adtfile.cpp b/src/tools/vmap4_extractor/adtfile.cpp index a5193739440..652b162189b 100644 --- a/src/tools/vmap4_extractor/adtfile.cpp +++ b/src/tools/vmap4_extractor/adtfile.cpp @@ -76,7 +76,7 @@ char* GetExtension(char* FileName) extern HANDLE WorldMpq; -ADTFile::ADTFile(char* filename): ADT(WorldMpq, filename) +ADTFile::ADTFile(char* filename) : ADT(WorldMpq, filename, false) { Adtfilename.append(filename); } diff --git a/src/tools/vmap4_extractor/dbcfile.h b/src/tools/vmap4_extractor/dbcfile.h index 007ccb6cdcb..2c43cb1a808 100644 --- a/src/tools/vmap4_extractor/dbcfile.h +++ b/src/tools/vmap4_extractor/dbcfile.h @@ -56,22 +56,22 @@ class DBCFile float getFloat(size_t field) const { assert(field < file._fieldCount); - return *reinterpret_cast<float*>(offset+field*4); + return *reinterpret_cast<float*>(offset + field * 4); } unsigned int getUInt(size_t field) const { assert(field < file._fieldCount); - return *reinterpret_cast<unsigned int*>(offset+field*4); + return *reinterpret_cast<unsigned int*>(offset + field * 4); } int getInt(size_t field) const { assert(field < file._fieldCount); - return *reinterpret_cast<int*>(offset+field*4); + return *reinterpret_cast<int*>(offset + field * 4); } - const char *getString(size_t field) const + char const* getString(size_t field) const { assert(field < file._fieldCount); size_t stringOffset = getUInt(field); @@ -80,9 +80,9 @@ class DBCFile } private: - Record(DBCFile &file, unsigned char *offset): file(file), offset(offset) {} - unsigned char *offset; - DBCFile &file; + Record(DBCFile& file, unsigned char* offset): file(file), offset(offset) {} + DBCFile& file; + unsigned char* offset; friend class DBCFile; friend class DBCFile::Iterator; @@ -92,29 +92,30 @@ class DBCFile class Iterator { public: - Iterator(DBCFile &file, unsigned char *offset) : record(file, offset) { } + Iterator(DBCFile &file, unsigned char* offset) : record(file, offset) { } /// Advance (prefix only) - Iterator & operator++() + Iterator& operator++() { record.offset += record.file._recordSize; return *this; } /// Return address of current instance - Record const & operator*() const { return record; } - const Record* operator->() const { return &record; } + Record const& operator*() const { return record; } + Record const* operator->() const { return &record; } /// Comparison - bool operator==(const Iterator &b) const + bool operator==(Iterator const& b) const { return record.offset == b.record.offset; } - bool operator!=(const Iterator &b) const + bool operator!=(Iterator const& b) const { return record.offset != b.record.offset; } + private: Record record; }; diff --git a/src/tools/vmap4_extractor/mpqfile.cpp b/src/tools/vmap4_extractor/mpqfile.cpp index 9f019f99f38..4e690aabee3 100644 --- a/src/tools/vmap4_extractor/mpqfile.cpp +++ b/src/tools/vmap4_extractor/mpqfile.cpp @@ -3,7 +3,7 @@ #include <cstdio> #include "StormLib.h" -MPQFile::MPQFile(HANDLE mpq, const char* filename): +MPQFile::MPQFile(HANDLE mpq, const char* filename, bool warnNoExist /*= true*/) : eof(false), buffer(0), pointer(0), @@ -12,7 +12,8 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename): HANDLE file; if (!SFileOpenFileEx(mpq, filename, SFILE_OPEN_PATCHED_FILE, &file)) { - fprintf(stderr, "Can't open %s, err=%u!\n", filename, GetLastError()); + if (warnNoExist || GetLastError() != ERROR_FILE_NOT_FOUND) + fprintf(stderr, "Can't open %s, err=%u!\n", filename, GetLastError()); eof = true; return; } @@ -22,7 +23,7 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename): if (hi) { - fprintf(stderr, "Can't open %s, size[hi] = %u!\n", filename, (uint32)hi); + fprintf(stderr, "Can't open %s, size[hi] = %u!\n", filename, uint32(hi)); SFileCloseFile(file); eof = true; return; @@ -30,7 +31,7 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename): if (size <= 1) { - fprintf(stderr, "Can't open %s, size = %u!\n", filename, size); + fprintf(stderr, "Can't open %s, size = %u!\n", filename, uint32(size)); SFileCloseFile(file); eof = true; return; @@ -40,7 +41,7 @@ MPQFile::MPQFile(HANDLE mpq, const char* filename): buffer = new char[size]; if (!SFileReadFile(file, buffer, size, &read) || size != read) { - fprintf(stderr, "Can't read %s, size=%u read=%u!\n", filename, size, read); + fprintf(stderr, "Can't read %s, size=%u read=%u!\n", filename, uint32(size), uint32(read)); SFileCloseFile(file); eof = true; return; diff --git a/src/tools/vmap4_extractor/mpqfile.h b/src/tools/vmap4_extractor/mpqfile.h index dfd1b713c97..e7379c4f7a0 100644 --- a/src/tools/vmap4_extractor/mpqfile.h +++ b/src/tools/vmap4_extractor/mpqfile.h @@ -54,7 +54,7 @@ class MPQFile void operator=(const MPQFile &f); public: - MPQFile(HANDLE mpq, const char* filename); // filenames are not case sensitive + MPQFile(HANDLE mpq, const char* filename, bool warnNoExist = true); // filenames are not case sensitive ~MPQFile() { close(); } size_t read(void* dest, size_t bytes); size_t getSize() { return size; } diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index bcbd705f834..84390a5fc9a 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -77,8 +77,19 @@ uint32 const Builds[] = {13164, 13205, 13287, 13329, 13596, 13623, 13914, 14007, #define LAST_DBC_IN_DATA_BUILD 13623 // after this build mpqs with dbc are back to locale folder #define NEW_BASE_SET_BUILD 15211 -char* const Locales[] = {"enGB", "enUS", "deDE", "esES", "frFR", "koKR", "zhCN", "zhTW", "enCN", "enTW", "esMX", "ruRU"}; -TCHAR* const LocalesT[] = +#define LOCALES_COUNT 12 + +char const* Locales[LOCALES_COUNT] = +{ + "enGB", "enUS", + "deDE", "esES", + "frFR", "koKR", + "zhCN", "zhTW", + "enCN", "enTW", + "esMX", "ruRU" +}; + +TCHAR const* LocalesT[LOCALES_COUNT] = { _T("enGB"), _T("enUS"), _T("deDE"), _T("esES"), @@ -88,8 +99,6 @@ TCHAR* const LocalesT[] = _T("esMX"), _T("ruRU"), }; -#define LOCALES_COUNT 12 - typedef struct { char name[64]; @@ -117,10 +126,14 @@ bool LoadLocaleMPQFile(int locale) if (!SFileOpenArchive(buff, 0, MPQ_OPEN_READ_ONLY, &LocaleMpq)) { if (GetLastError() != ERROR_PATH_NOT_FOUND) + { + _tprintf(_T("Loading %s locale MPQs\n"), LocalesT[locale]); _tprintf(_T("Cannot open archive %s\n"), buff); + } return false; } + _tprintf(_T("Loading %s locale MPQs\n"), LocalesT[locale]); char const* prefix = NULL; for (int i = 0; Builds[i] && Builds[i] <= CONF_TargetBuild; ++i) { @@ -149,6 +162,7 @@ bool LoadLocaleMPQFile(int locale) } } + printf("\n"); return true; } @@ -156,6 +170,7 @@ void LoadCommonMPQFiles(uint32 build) { TCHAR filename[512]; _stprintf(filename, _T("%sworld.MPQ"), input_path); + _tprintf(_T("Loading common MPQ files\n")); if (!SFileOpenArchive(filename, 0, MPQ_OPEN_READ_ONLY, &WorldMpq)) { if (GetLastError() != ERROR_PATH_NOT_FOUND) @@ -178,29 +193,7 @@ void LoadCommonMPQFiles(uint32 build) _tprintf(_T("Not found %s\n"), filename); } else - { _tprintf(_T("Loaded %s\n"), filename); - - bool found = false; - int count = 0; - SFILE_FIND_DATA data; - HANDLE find = SFileFindFirstFile(WorldMpq, "*.*", &data, NULL); - if (find != NULL) - { - do - { - ++count; - if (data.dwFileFlags & MPQ_FILE_PATCH_FILE) - { - found = true; - break; - } - } - while (SFileFindNextFile(find, &data)); - } - SFileFindClose(find); - printf("Scanned %d files, found patch = %d\n", count, found); - } } char const* prefix = NULL; @@ -232,32 +225,10 @@ void LoadCommonMPQFiles(uint32 build) continue; } else - { _tprintf(_T("Loaded %s\n"), filename); - - - bool found = false; - int count = 0; - SFILE_FIND_DATA data; - HANDLE find = SFileFindFirstFile(WorldMpq, "*.*", &data, NULL); - if (find != NULL) - { - do - { - ++count; - if (data.dwFileFlags & MPQ_FILE_PATCH_FILE) - { - found = true; - break; - } - } - while (SFileFindNextFile(find, &data)); - } - SFileFindClose(find); - printf("Scanned %d files, found patch = %d\n", count, found); - } } + printf("\n"); } @@ -537,7 +508,7 @@ bool processArgv(int argc, char ** argv, const char *versionString) printf(" -s : (default) small size (data size optimization), ~500MB less vmap data.\n"); printf(" -l : large size, ~500MB more vmap data. (might contain more details)\n"); printf(" -d <path>: Path to the vector data source folder.\n"); - printf(" -b : target build (default %u)", CONF_TargetBuild); + printf(" -b : target build (default %u)\n", CONF_TargetBuild); printf(" -? : This message.\n"); } @@ -581,7 +552,7 @@ int main(int argc, char ** argv) } } - printf("Extract %s. Beginning work ....\n",versionString); + printf("Extract %s. Beginning work ....\n\n",versionString); //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // Create the working directory if (mkdir(szWorkDirWmo @@ -593,8 +564,6 @@ int main(int argc, char ** argv) LoadCommonMPQFiles(CONF_TargetBuild); - int FirstLocale = -1; - for (int i = 0; i < LOCALES_COUNT; ++i) { //Open MPQs @@ -605,7 +574,7 @@ int main(int argc, char ** argv) continue; } - printf("Detected and using locale locale: %s\n", Locales[i]); + printf("Detected and using locale: %s\n", Locales[i]); break; } @@ -640,7 +609,7 @@ int main(int argc, char ** argv) ParsMapFiles(); delete [] map_ids; //nError = ERROR_SUCCESS; - // Extract models, listed in DameObjectDisplayInfo.dbc + // Extract models, listed in GameObjectDisplayInfo.dbc ExtractGameobjectModels(); } |