diff options
author | Shauren <shauren.trinity@gmail.com> | 2017-06-13 23:31:41 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2017-06-13 23:31:41 +0200 |
commit | ff1a71d6f72734f32cb83e1a24b159ff655011ad (patch) | |
tree | 65e5714411e93502628d0a63d13d3e3acd652074 | |
parent | 1ec8228d4aec23e0e254a350b5077d7c36ebd31b (diff) |
Tools/Extractors: Improved game build reported by extractors7.2.0/24015
-rw-r--r-- | src/tools/extractor_common/CascHandles.cpp | 17 | ||||
-rw-r--r-- | src/tools/extractor_common/CascHandles.h | 1 | ||||
-rw-r--r-- | src/tools/map_extractor/System.cpp | 49 | ||||
-rw-r--r-- | src/tools/vmap4_extractor/vmapexport.cpp | 47 |
4 files changed, 21 insertions, 93 deletions
diff --git a/src/tools/extractor_common/CascHandles.cpp b/src/tools/extractor_common/CascHandles.cpp index 46f90d8233f..45897c15617 100644 --- a/src/tools/extractor_common/CascHandles.cpp +++ b/src/tools/extractor_common/CascHandles.cpp @@ -70,6 +70,23 @@ CASC::StorageHandle CASC::OpenStorage(boost::filesystem::path const& path, DWORD return StorageHandle(handle); } +DWORD CASC::GetBuildNumber(StorageHandle const& storage) +{ + DWORD buildNumber = 0; + size_t infoDataSizeNeeded = 0; + if (!::CascGetStorageInfo(storage.get(), CascStorageGameBuild, &buildNumber, sizeof(buildNumber), &infoDataSizeNeeded)) + { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + std::unique_ptr<char> buf(new char[infoDataSizeNeeded]); + ::CascGetStorageInfo(storage.get(), CascStorageGameBuild, buf.get(), infoDataSizeNeeded, &infoDataSizeNeeded); + return *reinterpret_cast<DWORD*>(buf.get()); + } + } + + return buildNumber; +} + CASC::FileHandle CASC::OpenFile(StorageHandle const& storage, char const* fileName, DWORD localeMask, bool printErrors /*= false*/) { HANDLE handle = nullptr; diff --git a/src/tools/extractor_common/CascHandles.h b/src/tools/extractor_common/CascHandles.h index ebfd04466ab..583eecbf58f 100644 --- a/src/tools/extractor_common/CascHandles.h +++ b/src/tools/extractor_common/CascHandles.h @@ -49,6 +49,7 @@ namespace CASC char const* HumanReadableCASCError(DWORD error); StorageHandle OpenStorage(boost::filesystem::path const& path, DWORD localeMask); + DWORD GetBuildNumber(StorageHandle const& storage); FileHandle OpenFile(StorageHandle const& storage, char const* fileName, DWORD localeMask, bool printErrors = false); DWORD GetFileSize(FileHandle const& file, PDWORD fileSizeHigh); diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp index d4db0591a30..0bd5064bbfe 100644 --- a/src/tools/map_extractor/System.cpp +++ b/src/tools/map_extractor/System.cpp @@ -325,51 +325,6 @@ void HandleArgs(int argc, char* arg[]) } } -uint32 ReadBuild(int locale) -{ - // include build info file also - std::string filename = Trinity::StringFormat("component.wow-%s.txt", localeNames[locale]); - //printf("Read %s file... ", filename.c_str()); - - CASC::FileHandle dbcFile = CASC::OpenFile(CascStorage, filename.c_str(), CASC_LOCALE_ALL); - if (!dbcFile) - { - printf("Locale %s not installed.\n", localeNames[locale]); - return 0; - } - - char buff[512]; - DWORD readBytes = 0; - CASC::ReadFile(dbcFile, buff, 512, &readBytes); - if (!readBytes) - { - printf("Fatal error: Not found %s file!\n", filename.c_str()); - exit(1); - } - - std::string text = std::string(buff, readBytes); - - size_t pos = text.find("version=\""); - size_t pos1 = pos + strlen("version=\""); - size_t pos2 = text.find("\"", pos1); - if (pos == text.npos || pos2 == text.npos || pos1 >= pos2) - { - printf("Fatal error: Invalid %s file format!\n", filename.c_str()); - exit(1); - } - - std::string build_str = text.substr(pos1,pos2-pos1); - - int build = atoi(build_str.c_str()); - if (build <= 0) - { - printf("Fatal error: Invalid %s file format!\n", filename.c_str()); - exit(1); - } - - return build; -} - void ReadMapDBC() { printf("Read Map.db2 file...\n"); @@ -1384,7 +1339,7 @@ int main(int argc, char * arg[]) if ((CONF_extract & EXTRACT_DBC) == 0) { FirstLocale = i; - build = ReadBuild(i); + build = CASC::GetBuildNumber(CascStorage); if (!build) { CascStorage.reset(); @@ -1396,7 +1351,7 @@ int main(int argc, char * arg[]) } //Extract DBC files - uint32 tempBuild = ReadBuild(i); + uint32 tempBuild = CASC::GetBuildNumber(CascStorage); if (!tempBuild) { CascStorage.reset(); diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp index c493072dffb..cdbe522234c 100644 --- a/src/tools/vmap4_extractor/vmapexport.cpp +++ b/src/tools/vmap4_extractor/vmapexport.cpp @@ -141,51 +141,6 @@ uint32 WowLocaleToCascLocaleFlags[12] = CASC_LOCALE_ITIT, }; -uint32 ReadBuild(int locale) -{ - // include build info file also - std::string filename = std::string("component.wow-") + localeNames[locale] + ".txt"; - //printf("Read %s file... ", filename.c_str()); - - CASC::FileHandle dbcFile = CASC::OpenFile(CascStorage, filename.c_str(), CASC_LOCALE_ALL); - if (!dbcFile) - { - printf("Locale %s not installed.\n", localeNames[locale]); - return 0; - } - - char buff[512]; - DWORD readBytes = 0; - CASC::ReadFile(dbcFile, buff, 512, &readBytes); - if (!readBytes) - { - printf("Fatal error: Not found %s file!\n", filename.c_str()); - exit(1); - } - - std::string text = std::string(buff, readBytes); - - size_t pos = text.find("version=\""); - size_t pos1 = pos + strlen("version=\""); - size_t pos2 = text.find("\"", pos1); - if (pos == text.npos || pos2 == text.npos || pos1 >= pos2) - { - printf("Fatal error: Invalid %s file format!\n", filename.c_str()); - exit(1); - } - - std::string build_str = text.substr(pos1, pos2 - pos1); - - int build = atoi(build_str.c_str()); - if (build <= 0) - { - printf("Fatal error: Invalid %s file format!\n", filename.c_str()); - exit(1); - } - - return build; -} - bool OpenCascStorage(int locale) { try @@ -437,7 +392,7 @@ int main(int argc, char ** argv) continue; FirstLocale = i; - uint32 build = ReadBuild(i); + uint32 build = CASC::GetBuildNumber(CascStorage); if (!build) { CascStorage.reset(); |