feat(client): implement locale related calls

This commit is contained in:
VDm 2025-03-29 22:51:38 +04:00
parent 6e1f033e83
commit 77f4228abf
5 changed files with 90 additions and 32 deletions

View file

@ -24,6 +24,7 @@
CVar* Client::g_accountListVar; CVar* Client::g_accountListVar;
HEVENTCONTEXT Client::g_clientEventContext; HEVENTCONTEXT Client::g_clientEventContext;
char Client::g_currentLocaleName[5] = {};
void AsyncFileInitialize() { void AsyncFileInitialize() {
// TODO // TODO
@ -158,12 +159,17 @@ void SetPaths() {
OsSetCurrentDirectory(datadir); OsSetCurrentDirectory(datadir);
} }
bool LocaleChangedCallback(CVar*, const char*, const char* value, void*) {
SStrCopy(Client::g_currentLocaleName, value, sizeof(Client::g_currentLocaleName));
return true;
}
int32_t InitializeGlobal() { int32_t InitializeGlobal() {
// TODO
ProcessCommandLine(); ProcessCommandLine();
SetPaths();
// sub_403600("WoW.mfil"); // TODO:
// WowConfigureFileSystem::ReadBuildKeyFromFile("WoW.mfil");
// if (dword_B2FA10 != 2) { // if (dword_B2FA10 != 2) {
// sub_403560(); // sub_403560();
@ -175,42 +181,70 @@ int32_t InitializeGlobal() {
// LOBYTE(v24) = OsDirectoryExists((int)"WTF/Account") == 0; // LOBYTE(v24) = OsDirectoryExists((int)"WTF/Account") == 0;
// } // }
// ClientServices::LoadCDKey(); ClientServices::LoadCDKey();
SetPaths();
OpenArchives();
ConsoleInitializeClientCommand(); ConsoleInitializeClientCommand();
ConsoleInitializeClientCVar("Config.wtf"); ConsoleInitializeClientCVar("Config.wtf");
// TODO: CVar::ArchiveCodeRegisteredOnly();
// TODO
// replace enUS with detected locale
ClientServices::InitLoginServerCVars(1, "enUS");
// sub_7663F0();
// v18 = 0; // v18 = 0;
// v19 = 0; // v19 = 0;
// ptr = 0; // ptr = 0;
// v21 = 0; // v21 = 0;
// sub_406740(&v18, &CVar::Load); // ::ForEveryRunOnceWTF::Execute(&v18, &CVar::Load);
// if (ptr) { // if (ptr) {
// SMemFree(ptr, a_pad, -2, 0); // SMemFree(ptr, a_pad, -2, 0);
// } // }
// CVar::Register("dbCompress", "Database compression", 0, "-1", 0, 5, 0, 0, 0); CVar::Register(
"dbCompress",
"Database compression",
0,
"-1",
nullptr,
CATEGORY::DEFAULT,
false,
nullptr,
false
);
// v2 = CVar::Register("locale", "Set the game locale", 0, "****", &LocaleChangedCallback, 5, 0, 0, 0); CVar* locale = CVar::Register(
"locale",
"Set the game locale",
0,
"****",
&LocaleChangedCallback,
CATEGORY::DEFAULT,
false,
nullptr,
false
);
// if (!SStrCmp(v2->m_stringValue.m_str, "****", 0x7FFFFFFFu)) { if (!SStrCmp(locale->GetString(), "****", STORM_MAX_STR)) {
// CVar::Set(v2, "enUS", 1, 0, 0, 1); locale->Set("enUS", true, false, false, true);
// } }
CVar::Register(
"useEnglishAudio",
"override the locale and use English audio",
0,
"0",
nullptr,
CATEGORY::DEFAULT,
false,
nullptr,
false
);
OpenArchives();
// TODO
// replace enUS with detected locale
ClientServices::InitLoginServerCVars(1, locale->GetString());
// CVar::Register("useEnglishAudio", "override the locale and use English audio", 0, "0", 0, 5, 0, 0, 0);
// if (sub_422140()) { // if (sub_422140()) {
// sub_4036B0(v24, 0, a2, (int)v2, (char)v24); // sub_4036B0(v24, 0, a2, (int)v2, (char)v24);
@ -343,19 +377,36 @@ int32_t InitializeGlobal() {
void CommonMain() { void CommonMain() {
StormInitialize(); StormInitialize();
// TODO // TODO:
// - error log setup // SErrCatchUnhandledExceptions();
// - misc other setup // OsSystemInitialize("Blizzard Entertainment World of Warcraft", 0);
// int option = 1;
// StormSetOption(10, &option, sizeof(option));
// StormSetOption(11, &option, sizeof(option));
// OsSystemEnableCpuLog();
// SetPaths() moved into InitializeGlobal()
// int sendErrorLogs = 1;
// if (!SRegLoadValue("World of Warcraft\\Client", "SendErrorLogs", 0, &sendErrorLogs)) {
// sendErrorLogs = 1;
// SRegSaveValue("World of Warcraft\\Client", "SendErrorLogs", 0, sendErrorLogs);
// }
// SErrSetLogTitleString("World of WarCraft (build 12340)");
// SErrSetLogTitleCallback(WowLogHeader);
// if (sendErrorLogs) {
// SErrRegisterHandler(SendErrorLog);
// }
if (InitializeGlobal()) { if (InitializeGlobal()) {
EventDoMessageLoop(); EventDoMessageLoop();
// TODO: DestroyGlobal();
// TODO
// sub_406B70();
} }
// TODO // TODO:
// - misc cleanup // StormDestroy();
// Misc Cleanup
} }
void BlizzardAssertCallback(const char* a1, const char* a2, const char* a3, uint32_t a4) { void BlizzardAssertCallback(const char* a1, const char* a2, const char* a3, uint32_t a4) {

View file

@ -9,6 +9,7 @@ class CVar;
namespace Client { namespace Client {
extern CVar* g_accountListVar; extern CVar* g_accountListVar;
extern HEVENTCONTEXT g_clientEventContext; extern HEVENTCONTEXT g_clientEventContext;
extern char g_currentLocaleName[5];
} }
void ClientPostClose(int32_t a1); void ClientPostClose(int32_t a1);

View file

@ -264,6 +264,11 @@ const char* ClientServices::GetDefaultPatchListString() {
return "public-test.patch.battle.net:1119/patch"; return "public-test.patch.battle.net:1119/patch";
} }
bool ClientServices::LoadCDKey() {
// TODO
return true;
}
void ClientServices::InitLoginServerCVars(int32_t overwrite, const char* locale) { void ClientServices::InitLoginServerCVars(int32_t overwrite, const char* locale) {
if ((ClientServices::s_realmListBNVar == nullptr || ClientServices::s_realmListVar == nullptr) || overwrite != 0 ) { if ((ClientServices::s_realmListBNVar == nullptr || ClientServices::s_realmListVar == nullptr) || overwrite != 0 ) {
ClientServices::s_decorateAccountName = CVar::Register( ClientServices::s_decorateAccountName = CVar::Register(

View file

@ -45,6 +45,7 @@ class ClientServices : public LoginResponse {
static void InitLoginServerCVars(int32_t overwrite, const char* locale); static void InitLoginServerCVars(int32_t overwrite, const char* locale);
static const char* GetDefaultRealmlistString(); static const char* GetDefaultRealmlistString();
static const char* GetDefaultPatchListString(); static const char* GetDefaultPatchListString();
static bool LoadCDKey();
// Virtual member functions // Virtual member functions
virtual int32_t GetLoginServerType(); virtual int32_t GetLoginServerType();

View file

@ -37,7 +37,7 @@ class CVar : public TSHashObject<CVar, HASHKEY_STRI> {
int32_t GetInt(); int32_t GetInt();
const char* GetString(void); const char* GetString(void);
void InternalSet(const char*, bool, bool, bool, bool); void InternalSet(const char*, bool, bool, bool, bool);
bool Set(const char*, bool, bool, bool, bool); bool Set(const char* value, bool setValue, bool setReset, bool setDefault, bool a6);
bool Reset(); bool Reset();
bool Default(); bool Default();
int32_t Update(); int32_t Update();