diff --git a/src/client/ClientServices.cpp b/src/client/ClientServices.cpp index 6063188..07b8d2b 100644 --- a/src/client/ClientServices.cpp +++ b/src/client/ClientServices.cpp @@ -1,9 +1,10 @@ #include "client/ClientServices.hpp" #include "client/ClientRealmResponseAdapter.hpp" +#include "console/CVar.hpp" +#include "console/Command.hpp" #include "glue/CGlueMgr.hpp" #include "net/Connection.hpp" #include "net/Login.hpp" -#include "console/CVar.hpp" #include #include #include @@ -13,12 +14,17 @@ ClientConnection* g_clientConnection; char ClientServices::s_accountName[1280]; RealmResponse* ClientServices::s_clientRealmResponse; ClientConnection* ClientServices::s_currentConnection; +CVar* ClientServices::s_darkPortalVar; +CVar* ClientServices::s_decorateAccountName; ClientServices* ClientServices::s_instance; Login* ClientServices::s_loginObj; bool ClientServices::s_newLogin; +CVar* ClientServices::s_realmListVar; +CVar* ClientServices::s_realmListBNVar; CVar* ClientServices::s_realmNameVar; REALM_INFO ClientServices::s_selectRealmInfo; bool ClientServices::s_selectRealmInfoValid; +CVar* ClientServices::s_serverAlertVar; void ClientServices::ConnectToSelectedServer() { if (!ClientServices::s_selectRealmInfoValid && !ClientServices::SetSelectedRealmInfo(0)) { @@ -104,6 +110,99 @@ void ClientServices::Initialize() { // TODO ConsoleCommandRegister("logout", &Sub6B2030, 5, nullptr); } +void ClientServices::InitLoginServerCVars(int32_t force, const char* locale) { + if (!ClientServices::s_realmListBNVar || !ClientServices::s_realmListVar || force) { + ClientServices::s_decorateAccountName = CVar::Register( + "decorateAccountName", + "", + 0x0, + "0", + nullptr, + NET, + false, + nullptr, + false + ); + } + + char dataPath[STORM_MAX_PATH]; + if (locale && *locale) { + SStrPrintf(dataPath, sizeof(dataPath), "data\\%s\\", locale); + } else { + dataPath[0] = '\0'; + } + + if (!ClientServices::s_realmListBNVar || force) { + ClientServices::s_realmListBNVar = CVar::Register( + "realmListbn", + "Address of Battle.net server", + 0x0, + "", + nullptr, + NET, + false, + nullptr, + false + ); + + char realmListPath[STORM_MAX_PATH]; + SStrPrintf(realmListPath, sizeof(realmListPath), "%srealmlistbn.wtf", dataPath); + + if (!CVar::Load(realmListPath)) { + CVar::Load("realmlistbn.wtf"); + } + } + + if (!ClientServices::s_darkPortalVar || force) { + ClientServices::s_darkPortalVar = CVar::Register( + "portal", + "Name of Battle.net portal to use", + 0x0, + "", + nullptr, + NET, + false, + nullptr, + false + ); + } + + if (!ClientServices::s_serverAlertVar || force) { + ClientServices::s_serverAlertVar = CVar::Register( + "serverAlert", + "Get the glue-string tag for the URL", + 0x0, + "SERVER_ALERT_URL", + nullptr, + NET, + false, + nullptr, + false + ); + } + + if (!ClientServices::s_realmListVar || force) { + ClientServices::s_realmListVar = CVar::Register( + "realmList", + "Address of realm list server", + 0x0, + "us.logon.worldofwarcraft.com:3724", + nullptr, + NET, + false, + nullptr, + false + ); + + char realmListPath[STORM_MAX_PATH]; + SStrPrintf(realmListPath, sizeof(realmListPath), "%srealmlist.wtf", dataPath); + + if (!CVar::Load(realmListPath)) { + CVar::Load("realmlist.wtf"); + } + } +} + Login* ClientServices::LoginConnection() { return ClientServices::s_loginObj; } diff --git a/src/client/ClientServices.hpp b/src/client/ClientServices.hpp index 57ec1b5..1ef7fca 100644 --- a/src/client/ClientServices.hpp +++ b/src/client/ClientServices.hpp @@ -15,12 +15,17 @@ class ClientServices : public LoginResponse { static char s_accountName[1280]; static RealmResponse* s_clientRealmResponse; static ClientConnection* s_currentConnection; + static CVar* s_darkPortalVar; + static CVar* s_decorateAccountName; static ClientServices* s_instance; static Login* s_loginObj; static bool s_newLogin; + static CVar* s_realmListVar; + static CVar* s_realmListBNVar; static CVar* s_realmNameVar; static REALM_INFO s_selectRealmInfo; static bool s_selectRealmInfoValid; + static CVar* s_serverAlertVar; // Static functions static void ConnectToSelectedServer(); @@ -30,6 +35,7 @@ class ClientServices : public LoginResponse { static const char* GetSelectedRealmName(); static const REALM_INFO* GetSelectedRealm(); static void Initialize(); + static void InitLoginServerCVars(int32_t force, const char* locale); static Login* LoginConnection(); static void Logon(const char* accountName, const char* password); static void SelectRealm(const char* realmName);