diff --git a/src/client/Client.cpp b/src/client/Client.cpp index aefcb3f..f326581 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -6,6 +6,7 @@ #include "console/Client.hpp" #include "console/Device.hpp" #include "console/Screen.hpp" +#include "console/Command.hpp" #include "db/Db.hpp" #include "glue/CGlueMgr.hpp" #include "gx/Screen.hpp" @@ -23,7 +24,15 @@ #include #include + +CVar* Client::g_accountNameVar; CVar* Client::g_accountListVar; +CVar* Client::g_accountUsesTokenVar; +CVar* Client::g_movieVar; +CVar* Client::g_expansionMovieVar; +CVar* Client::g_movieSubtitleVar; + + HEVENTCONTEXT Client::g_clientEventContext; char Client::g_currentLocaleName[5] = {}; @@ -36,6 +45,16 @@ static char* s_localeArray[12] = { }; +int32_t CCommand_ReloadUI(const char*, const char*) { + // TODO: + return 1; +} + +int32_t CCommand_Perf(const char*, const char*) { + return 1; +} + + void AsyncFileInitialize() { // TODO AsyncFileReadInitialize(0, 100); @@ -47,18 +66,20 @@ void BaseInitializeGlobal() { void ClientMiscInitialize() { // TODO +} - Client::g_accountListVar = CVar::Register( - "accountList", - "List of wow accounts for saved Blizzard account", - 0, - "", - nullptr, - 4, - false, - nullptr, - false - ); +void ClientRegisterConsoleCommands() { + ConsoleCommandRegister("reloadUI", &CCommand_ReloadUI, CATEGORY::GRAPHICS, nullptr); + ConsoleCommandRegister("perf", &CCommand_Perf, CATEGORY::DEBUG, nullptr); + + const auto game = CATEGORY::GAME; + + Client::g_accountNameVar = CVar::Register("accountName", "Saved account name", 64, "", nullptr, game); + Client::g_accountListVar = CVar::Register("accountList", "List of wow accounts for saved Blizzard account", 0, "", nullptr, game); + Client::g_accountUsesTokenVar = CVar::Register("g_accountUsesToken", "Saved whether uses authenticator", 0, "0", nullptr, game); + Client::g_movieVar = CVar::Register("movie", "Show movie on startup", 0, "1", nullptr, game); + Client::g_expansionMovieVar = CVar::Register("expansionMovie", "Show expansion movie on startup", 0, "1", nullptr, game); + Client::g_movieSubtitleVar = CVar::Register("movieSubtitle", "Show movie subtitles", 0, "0", nullptr, game); // TODO } @@ -559,7 +580,7 @@ void WowClientInit() { ClientMiscInitialize(); - // sub_401B60(); + ClientRegisterConsoleCommands(); ClientDBInitialize(); @@ -617,27 +638,22 @@ void WowClientInit() { // sub_421630(); // } - // TODO - // if (byte_B2F9E1 != 1) { - // if ((g_playIntroMovie + 48) == 1) { - // CVar::Set(g_playIntroMovie, "0", 1, 0, 0, 1); - // CGlueMgr::SetScreen("movie"); - // } else { - // CGlueMgr::SetScreen("login"); - // } - // } else { - // if ((dword_B2F980 + 48) == 1) { - // CVar::Set(dword_B2F980, "0", 1, 0, 0, 1); - // CVar::Set(g_playIntroMovie, "0", 1, 0, 0, 1); - // CGlueMgr::SetScreen("movie"); - // } else { - // CGlueMgr::SetScreen("login"); - // } - // } - - // TODO - // - temporary until above logic is implemented - CGlueMgr::SetScreen("login"); + if (s_expansionLevel != 1) { + if (Client::g_movieVar->GetInt()) { + Client::g_movieVar->Set("0", true, false, false, true); + CGlueMgr::SetScreen("movie"); + } else { + CGlueMgr::SetScreen("login"); + } + } else { + if (Client::g_expansionMovieVar->GetInt()) { + Client::g_expansionMovieVar->Set("0", true, false, false, true); + Client::g_movieVar->Set("0", true, false, false, true); + CGlueMgr::SetScreen("movie"); + } else { + CGlueMgr::SetScreen("login"); + } + } // TODO // CGlueMgr::m_pendingTimerAlert = dword_B2F9D8; diff --git a/src/client/Client.hpp b/src/client/Client.hpp index 3ad8056..1c580ff 100644 --- a/src/client/Client.hpp +++ b/src/client/Client.hpp @@ -7,7 +7,12 @@ class CVar; namespace Client { + extern CVar* g_accountNameVar; extern CVar* g_accountListVar; + extern CVar* g_accountUsesTokenVar; + extern CVar* g_movieVar; + extern CVar* g_expansionMovieVar; + extern CVar* g_movieSubtitleVar; extern HEVENTCONTEXT g_clientEventContext; extern char g_currentLocaleName[5]; } diff --git a/src/glue/CGlueMgr.cpp b/src/glue/CGlueMgr.cpp index 1061cde..1510361 100644 --- a/src/glue/CGlueMgr.cpp +++ b/src/glue/CGlueMgr.cpp @@ -43,6 +43,8 @@ unsigned char InterfaceKey[256] = { int32_t CGlueMgr::m_acceptedEULA = 1; // TODO int32_t CGlueMgr::m_acceptedTerminationWithoutNotice; int32_t CGlueMgr::m_acceptedTOS = 1; // TODO +int32_t CGlueMgr::m_processServerAlert = 1; +int32_t CGlueMgr::m_pendingTimerAlert; int32_t CGlueMgr::m_accountMsgAvailable; char CGlueMgr::m_accountName[1280]; float CGlueMgr::m_aspect; @@ -199,7 +201,30 @@ int32_t CGlueMgr::HandleDisplaySizeChanged(const CSizeEvent& event) { // TODO a1: const EVENT_DATA_IDLE* int32_t CGlueMgr::Idle(const void* a1, void* a2) { - // TODO + // TODO: + // if (gxDevice->IsStereoEnabled) { + // CGlueMgr::SetUIDepth(gxDevice->StereoGetConvergence); + // } + + auto loginConnection = ClientServices::LoginConnection(); + if (loginConnection) { + // Virtual call (loginConnection + 184) leads to nullsub + // Checked by tracing in debugger + } + + if (CGlueMgr::m_processServerAlert) { + // TODO: + // v2 = SStrLen("SERVERALERT:"); + // FrameScript_SignalEvent(0x15u, "%s", &CGlueMgr::m_serverAlert[(_DWORD)&v2[CGlueMgr::m_serverAlert[0] != -17 ? 0 : 3]]); + CGlueMgr::m_processServerAlert = 0; + } + + if (CGlueMgr::m_pendingTimerAlert) { + FrameScript_SignalEvent(0x21u, "%d", CGlueMgr::m_pendingTimerAlert); + CGlueMgr::m_pendingTimerAlert = 0; + } + + // TODO: CKBPage::UpdateLoadingQueue(); if (CGlueMgr::m_idleState == IDLE_NONE) { if (CGlueMgr::m_reload) { @@ -213,18 +238,17 @@ int32_t CGlueMgr::Idle(const void* a1, void* a2) { CGlueMgr::m_reload = 0; } - // TODO - // if (CGlueMgr::m_accountMsgAvailable) { - // FrameScript_SignalEvent(0x22u, 0); - // CGlueMgr::m_accountMsgAvailable = 0; - // } + if (CGlueMgr::m_accountMsgAvailable) { + FrameScript_SignalEvent(0x22u, 0); + CGlueMgr::m_accountMsgAvailable = 0; + } - // TODO sub_4D84A0(); + // TODO CGlueMgr::HandleBattlenetDisconnect(); return 1; } - // TODO + // TODO: LOOP { ConsoleWrite(GRUNT DEBUG MESSAGE) } WOWCS_OPS op; const char* msg; @@ -366,46 +390,48 @@ void CGlueMgr::PollAccountLogin(int32_t errorCode, const char* msg, int32_t comp FrameScript_SignalEvent(4, "%s", msg); } - if (complete) { - if (result == 0) { - if (errorCode != 2) { + if (!complete) { + return; + } + + if (result == 0) { + if (errorCode != 2) { + // TODO + } + + CGlueMgr::m_idleState = IDLE_NONE; + CGlueMgr::m_showedDisconnect = 0; + + if (errorCode == 2) { + // TODO CGlueMgr::m_disconnectPending = 1; + // TODO ClientServices::Connection()->Disconnect(); + } + + if (errorCode != 13) { + // TODO CCharacterSelection::ClearCharacterList(); + + if (ClientServices::GetInstance()->m_realmList.Count()) { + FrameScript_SignalEvent(5, nullptr); + CRealmList::UpdateList(); + } else { // TODO } - CGlueMgr::m_idleState = IDLE_NONE; - CGlueMgr::m_showedDisconnect = 0; - - if (errorCode == 2) { - // TODO CGlueMgr::m_disconnectPending = 1; - // TODO ClientServices::Connection()->Disconnect(); - } - - if (errorCode != 13) { - // TODO CCharacterSelection::ClearCharacterList(); - - if (ClientServices::GetInstance()->m_realmList.Count()) { - FrameScript_SignalEvent(5, nullptr); - CRealmList::UpdateList(); - } else { - // TODO - } - - return; - } - - if (!SStrCmpI(CGlueMgr::m_currentScreen, "charselect", STORM_MAX_STR)) { - CGlueMgr::SetScreen("login"); - return; - } - return; } - if (op == COP_CONNECT) { - // TODO - + if (!SStrCmpI(CGlueMgr::m_currentScreen, "charselect", STORM_MAX_STR)) { + CGlueMgr::SetScreen("login"); return; } + + return; + } + + if (op == COP_CONNECT) { + // TODO + + return; } } diff --git a/src/glue/CGlueMgr.hpp b/src/glue/CGlueMgr.hpp index a286768..88838ab 100644 --- a/src/glue/CGlueMgr.hpp +++ b/src/glue/CGlueMgr.hpp @@ -32,6 +32,8 @@ class CGlueMgr { static int32_t m_acceptedEULA; static int32_t m_acceptedTerminationWithoutNotice; static int32_t m_acceptedTOS; + static int32_t m_processServerAlert; + static int32_t m_pendingTimerAlert; static int32_t m_accountMsgAvailable; static char m_accountName[]; static float m_aspect;