mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Tools/Extractors: Support specifying which wow version to open when installed to the same directory (retail/ptr/other)
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user