aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2019-06-19 20:00:14 +0200
committerShauren <shauren.trinity@gmail.com>2019-06-19 20:00:14 +0200
commit9bb85965e10924554b087eb5ae94e6e4fa970ae9 (patch)
tree42542bc2d382c563f4e72ec8f2b8997b0b89210d /src
parent658a79d94add4f9d639b959b6ac7b57a6a0a30ca (diff)
Tools/Extractors: Support specifying which wow version to open when installed to the same directory (retail/ptr/other)
Diffstat (limited to 'src')
-rw-r--r--src/tools/extractor_common/CascHandles.cpp10
-rw-r--r--src/tools/extractor_common/CascHandles.h2
-rw-r--r--src/tools/map_extractor/System.cpp15
-rw-r--r--src/tools/vmap4_extractor/vmapexport.cpp17
4 files changed, 34 insertions, 10 deletions
diff --git a/src/tools/extractor_common/CascHandles.cpp b/src/tools/extractor_common/CascHandles.cpp
index baed5e61b7a..cfce1c22999 100644
--- a/src/tools/extractor_common/CascHandles.cpp
+++ b/src/tools/extractor_common/CascHandles.cpp
@@ -55,10 +55,16 @@ void CASC::FileDeleter::operator()(HANDLE handle)
::CascCloseFile(handle);
}
-CASC::StorageHandle CASC::OpenStorage(boost::filesystem::path const& path, DWORD localeMask)
+CASC::StorageHandle CASC::OpenStorage(boost::filesystem::path const& path, DWORD localeMask, char const* product)
{
+ std::string strPath = path.string();
+ CASC_OPEN_STORAGE_ARGS args = {};
+ args.Size = sizeof(CASC_OPEN_STORAGE_ARGS);
+ args.szLocalPath = strPath.c_str();
+ args.szCodeName = product;
+ args.dwLocaleMask = localeMask;
HANDLE handle = nullptr;
- if (!::CascOpenStorage(path.string().c_str(), localeMask, &handle))
+ if (!::CascOpenStorageEx(nullptr, &args, false, &handle))
{
DWORD lastError = GetLastError(); // support checking error set by *Open* call, not the next *Close*
printf("Error opening casc storage '%s': %s\n", path.string().c_str(), HumanReadableCASCError(lastError));
diff --git a/src/tools/extractor_common/CascHandles.h b/src/tools/extractor_common/CascHandles.h
index 4f536ce9ecc..008f118c68d 100644
--- a/src/tools/extractor_common/CascHandles.h
+++ b/src/tools/extractor_common/CascHandles.h
@@ -48,7 +48,7 @@ namespace CASC
char const* HumanReadableCASCError(DWORD error);
- StorageHandle OpenStorage(boost::filesystem::path const& path, DWORD localeMask);
+ StorageHandle OpenStorage(boost::filesystem::path const& path, DWORD localeMask, char const* product);
DWORD GetBuildNumber(StorageHandle const& storage);
DWORD GetInstalledLocalesMask(StorageHandle const& storage);
bool HasTactKey(StorageHandle const& storage, ULONGLONG keyLookup);
diff --git a/src/tools/map_extractor/System.cpp b/src/tools/map_extractor/System.cpp
index ff05df3119c..cf5071d829e 100644
--- a/src/tools/map_extractor/System.cpp
+++ b/src/tools/map_extractor/System.cpp
@@ -100,6 +100,8 @@ float CONF_flat_liquid_delta_limit = 0.001f; // If max - min less this value - l
uint32 CONF_Locale = 0;
+char const* CONF_Product = "wow";
+
#define CASC_LOCALES_COUNT 17
char const* CascLocaleNames[CASC_LOCALES_COUNT] =
@@ -151,6 +153,7 @@ void Usage(char const* prg)
"-e extract only MAP(1)/DBC(2)/Camera(4)/gt(8) - standard: all(15)\n"\
"-f height stored as int (less map size but lost some accuracy) 1 by default\n"\
"-l dbc locale\n"\
+ "-p which installed product to open (wow/wowt/wow_beta)\n"\
"Example: %s -f 0 -i \"c:\\games\\game\"\n", prg, prg);
exit(1);
}
@@ -209,6 +212,12 @@ void HandleArgs(int argc, char* arg[])
else
Usage(arg[0]);
break;
+ case 'p':
+ if (c + 1 < argc && strlen(arg[c + 1])) // all ok
+ CONF_Product = arg[++c];
+ else
+ Usage(arg[0]);
+ break;
case 'h':
Usage(arg[0]);
break;
@@ -1214,7 +1223,7 @@ bool ExtractDB2File(uint32 fileDataId, char const* cascFileName, int locale, boo
DB2FileLoader db2;
if (!db2.LoadHeaders(&source, nullptr))
{
- printf("Can't read DB2 headers file size of '%s'\n", cascFileName);
+ printf("Can't read DB2 headers of '%s'\n", cascFileName);
return false;
}
@@ -1414,7 +1423,7 @@ bool OpenCascStorage(int locale)
try
{
boost::filesystem::path const storage_dir(boost::filesystem::canonical(input_path) / "Data");
- CascStorage = CASC::OpenStorage(storage_dir, WowLocaleToCascLocaleFlags[locale]);
+ CascStorage = CASC::OpenStorage(storage_dir, WowLocaleToCascLocaleFlags[locale], CONF_Product);
if (!CascStorage)
{
printf("error opening casc storage '%s' locale %s\n", storage_dir.string().c_str(), localeNames[locale]);
@@ -1435,7 +1444,7 @@ uint32 GetInstalledLocalesMask()
try
{
boost::filesystem::path const storage_dir(boost::filesystem::canonical(input_path) / "Data");
- CASC::StorageHandle storage = CASC::OpenStorage(storage_dir, 0);
+ CASC::StorageHandle storage = CASC::OpenStorage(storage_dir, 0, CONF_Product);
if (!storage)
return false;
diff --git a/src/tools/vmap4_extractor/vmapexport.cpp b/src/tools/vmap4_extractor/vmapexport.cpp
index 7c4c5220259..9ffbfcde80b 100644
--- a/src/tools/vmap4_extractor/vmapexport.cpp
+++ b/src/tools/vmap4_extractor/vmapexport.cpp
@@ -65,6 +65,7 @@ std::map<uint32, MapEntry> map_ids;
std::unordered_set<uint32> maps_that_are_parents;
boost::filesystem::path input_path;
bool preciseVectorData = false;
+char const* CascProduct = "wow";
std::unordered_map<std::string, WMODoodadData> WmoDoodads;
// Constants
@@ -106,7 +107,7 @@ bool OpenCascStorage(int locale)
try
{
boost::filesystem::path const storage_dir(boost::filesystem::canonical(input_path) / "Data");
- CascStorage = CASC::OpenStorage(storage_dir, WowLocaleToCascLocaleFlags[locale]);
+ CascStorage = CASC::OpenStorage(storage_dir, WowLocaleToCascLocaleFlags[locale], CascProduct);
if (!CascStorage)
{
printf("error opening casc storage '%s' locale %s\n", storage_dir.string().c_str(), localeNames[locale]);
@@ -127,7 +128,7 @@ uint32 GetInstalledLocalesMask()
try
{
boost::filesystem::path const storage_dir(boost::filesystem::canonical(input_path) / "Data");
- CASC::StorageHandle storage = CASC::OpenStorage(storage_dir, 0);
+ CASC::StorageHandle storage = CASC::OpenStorage(storage_dir, 0, CascProduct);
if (!storage)
return false;
@@ -330,10 +331,17 @@ bool processArgv(int argc, char ** argv, const char *versionString)
{
result = false;
}
- else if(strcmp("-l",argv[i]) == 0)
+ else if (strcmp("-l", argv[i]) == 0)
{
preciseVectorData = true;
}
+ else if (strcmp("-p", argv[i]) == 0)
+ {
+ if (i + 1 < argc && strlen(argv[i + 1]))
+ CascProduct = argv[++i];
+ else
+ result = false;
+ }
else
{
result = false;
@@ -344,10 +352,11 @@ bool processArgv(int argc, char ** argv, const char *versionString)
if (!result)
{
printf("Extract %s.\n",versionString);
- printf("%s [-?][-s][-l][-d <path>]\n", argv[0]);
+ printf("%s [-?][-s][-l][-d <path>][-p <product>]\n", argv[0]);
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(" -p <product>: which installed product to open (wow/wowt/wow_beta)\n");
printf(" -? : This message.\n");
}