3#ifndef __CASCLIB_SELF__
4#define __CASCLIB_SELF__
21 : m_currentCascLocale(CASC_LOCALE_NONE), m_folder(
""), m_openError(ERROR_SUCCESS), hStorage(nullptr)
40 std::map<std::string, int> locales;
41 locales[
"frFR"] = CASC_LOCALE_FRFR;
42 locales[
"deDE"] = CASC_LOCALE_DEDE;
43 locales[
"esES"] = CASC_LOCALE_ESES;
44 locales[
"esMX"] = CASC_LOCALE_ESMX;
45 locales[
"ptBR"] = CASC_LOCALE_PTBR;
46 locales[
"itIT"] = CASC_LOCALE_ITIT;
47 locales[
"ptPT"] = CASC_LOCALE_PTPT;
48 locales[
"enGB"] = CASC_LOCALE_ENGB;
49 locales[
"ruRU"] = CASC_LOCALE_RURU;
50 locales[
"enUS"] = CASC_LOCALE_ENUS;
51 locales[
"enCN"] = CASC_LOCALE_ENCN;
52 locales[
"enTW"] = CASC_LOCALE_ENTW;
53 locales[
"koKR"] = CASC_LOCALE_KOKR;
54 locales[
"zhCN"] = CASC_LOCALE_ZHCN;
55 locales[
"zhTW"] = CASC_LOCALE_ZHTW;
62 if (it != locales.end())
65 LOG_INFO <<
"Loading Game Folder:" << cascParams;
67 if (!CascOpenStorage(std::filesystem::path(cascParams).wstring().c_str(), it->second, &
hStorage))
85 const std::string buildinfofile =
m_folder +
"\\..\\.build.info";
86 LOG_INFO <<
"buildinfofile : " << buildinfofile;
88 std::ifstream file(buildinfofile);
91 LOG_ERROR <<
"Fail to open .build.info to grab game config info";
98 if (!std::getline(file, stdline))
103 int versionIndex = 0;
105 int productIndex = 0;
106 for (
int index = 0; index < static_cast<int>(headers.size()); index++)
111 versionIndex = index;
115 productIndex = index;
119 const std::regex re(R
"(^(\d+).(\d+).(\d+).(\d+)$)");
120 while (std::getline(file, stdline))
126 if (values[activeIndex] ==
"0")
131 if (std::regex_match(values[versionIndex], result, re))
132 version = result[1].str() +
"." + result[2].str() +
"." + result[3].str() +
"." + result[4].str();
135 const std::string product = values[productIndex];
138 auto tagValues =
core::split(values[tagIndex],
':');
139 for (
const auto& value : tagValues)
141 if (value.find(
"text?") != std::string::npos)
145 config.
locale = tags[tags.size() - 2];
154 LOG_INFO <<
"config" << it.locale << it.version;
168 CascCloseFile(dummy);
182 return CascCloseFile(file);
187 std::ifstream tactKeys(
"extraEncryptionKeys.csv");
189 if (tactKeys.is_open())
192 while (std::getline(tactKeys, stdline))
194 if (stdline.starts_with(
"##") || stdline.starts_with(
"\"##"))
199 if (lineData.size() != 2)
201 const std::string& keyName = lineData[0];
202 const std::string& keyValue = lineData[1];
203 if (keyName.empty() || keyValue.empty())
206 const unsigned long long keyNameVal = std::stoull(keyName,
nullptr, 16);
207 const bool ok2 = CascAddStringEncryptionKey(
hStorage, keyNameVal, keyValue.c_str());
209 LOG_ERROR <<
"Failed to add TACT key from file, Name:" << keyName <<
", Value:" << keyValue;
bool setConfig(core::GameConfig config)
void init(const std::string &path)
bool closeFile(HANDLE file)
bool openFile(int id, HANDLE *result)
void addExtraEncryptionKeys()
core::GameConfig m_currentConfig
std::vector< core::GameConfig > m_configs
Describes a detected game installation (locale, version, product).
std::string product
e.g. "wow" or "wow_classic".
std::string version
e.g. "11.0.7.58238".
std::string locale
e.g. "enUS".
std::vector< std::string > split(const std::string &s, char delimiter)
Split a string by a single-character delimiter.
bool containsIgnoreCase(const std::string &s, const std::string &substr)