mirror of
				https://github.com/thunderbrewhq/thunderbrew
				synced 2025-10-31 08:16:03 +03:00 
			
		
		
		
	feat(glue): make character selection screen available
This commit is contained in:
		
							parent
							
								
									30a78b00b5
								
							
						
					
					
						commit
						fcfe4fca90
					
				| @ -66,6 +66,14 @@ ClientServices* ClientServices::GetInstance() { | ||||
|     return ClientServices::s_instance; | ||||
| } | ||||
| 
 | ||||
| void ClientServices::GetRealmList() { | ||||
|     // TODO
 | ||||
| } | ||||
| 
 | ||||
| void ClientServices::GetCharacterList() { | ||||
|     // TODO
 | ||||
| } | ||||
| 
 | ||||
| REALM_INFO* ClientServices::GetRealmInfoByIndex(int32_t index) { | ||||
|     if (index >= ClientServices::GetInstance()->m_realmList.Count()) { | ||||
|         return nullptr; | ||||
|  | ||||
| @ -33,6 +33,8 @@ class ClientServices : public LoginResponse { | ||||
|         static void ConnectToSelectedServer(); | ||||
|         static ClientConnection* Connection(); | ||||
|         static ClientServices* GetInstance(); | ||||
|         static void GetRealmList(); | ||||
|         static void GetCharacterList(); | ||||
|         static REALM_INFO* GetRealmInfoByIndex(int32_t index); | ||||
|         static const char* GetSelectedRealmName(); | ||||
|         static const REALM_INFO* GetSelectedRealm(); | ||||
|  | ||||
| @ -59,6 +59,7 @@ int32_t CGlueMgr::m_lastLoginResult; | ||||
| int32_t CGlueMgr::m_lastLoginState; | ||||
| int32_t CGlueMgr::m_loginResult; | ||||
| int32_t CGlueMgr::m_loginState; | ||||
| int32_t CGlueMgr::m_matrixChallengeCount; | ||||
| int32_t CGlueMgr::m_matrixRemaining; | ||||
| int32_t CGlueMgr::m_reconnect; | ||||
| int32_t CGlueMgr::m_reload; | ||||
| @ -69,6 +70,13 @@ int32_t CGlueMgr::m_showedDisconnect; | ||||
| CSimpleTop* CGlueMgr::m_simpleTop; | ||||
| int32_t CGlueMgr::m_suspended; | ||||
| 
 | ||||
| int32_t CGlueMgr::m_surveyTimer; | ||||
| int32_t CGlueMgr::m_executedSurvey; | ||||
| int32_t CGlueMgr::m_surveyDownload; | ||||
| int32_t CGlueMgr::m_patchDownload; | ||||
| bool CGlueMgr::m_deleteLocalPatch; | ||||
| 
 | ||||
| 
 | ||||
| float CalculateAspectRatio() { | ||||
|     auto widescreenVar = CVar::Lookup("widescreen"); | ||||
|     auto resolutionVar = CVar::Lookup("gxResolution"); | ||||
| @ -199,6 +207,25 @@ int32_t CGlueMgr::HandleDisplaySizeChanged(const CSizeEvent& event) { | ||||
|     return 1; | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::GetRealmList(bool showProgress) { | ||||
|     CGlueMgr::m_idleState = IDLE_REALM_LIST; | ||||
|     CGlueMgr::m_showedDisconnect = 0; | ||||
|     if (showProgress) { | ||||
|         auto text = FrameScript_GetText("REALM_LIST_IN_PROGRESS", -1, FRAMESCRIPT_GENDER::GENDER_NOT_APPLICABLE); | ||||
|         FrameScript_SignalEvent(3, "%s%s", "CANCEL", text); | ||||
|     } | ||||
|     ClientServices::GetRealmList(); | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::GetCharacterList() { | ||||
|     if (CGlueMgr::m_idleState != IDLE_WORLD_LOGIN) { | ||||
|         CGlueMgr::m_idleState = IDLE_CHARACTER_LIST; | ||||
|         auto text = FrameScript_GetText("CHAR_LIST_RETRIEVING", -1, GENDER_NOT_APPLICABLE); | ||||
|         FrameScript_SignalEvent(3, "%s%s", "CANCEL", text); | ||||
|         ClientServices::GetCharacterList(); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| // TODO a1: const EVENT_DATA_IDLE*
 | ||||
| int32_t CGlueMgr::Idle(const void* a1, void* a2) { | ||||
|     // TODO:
 | ||||
| @ -267,6 +294,25 @@ int32_t CGlueMgr::Idle(const void* a1, void* a2) { | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     case IDLE_CHARACTER_LIST: { | ||||
|         CGlueMgr::PollCharacterList(errorCode, msg, complete, result, op); | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     case IDLE_12: { | ||||
|         if (CGlueMgr::m_patchDownload) { | ||||
|             CGlueMgr::PatchDownloadIdle(); | ||||
|         } else if (CGlueMgr::m_surveyDownload) { | ||||
|             CGlueMgr::SurveyDownloadIdle(); | ||||
|         } | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     case IDLE_13: { | ||||
|         CGlueMgr::PollUserSurvey(); | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     // TODO other idle states
 | ||||
| 
 | ||||
|     default: | ||||
| @ -397,14 +443,15 @@ void CGlueMgr::PollAccountLogin(int32_t errorCode, const char* msg, int32_t comp | ||||
|     if (result == 0) { | ||||
|         if (errorCode != 2) { | ||||
|             // TODO
 | ||||
|             // Select Error Description with or without URL
 | ||||
|         } | ||||
| 
 | ||||
|         CGlueMgr::m_idleState = IDLE_NONE; | ||||
|         CGlueMgr::m_showedDisconnect = 0; | ||||
| 
 | ||||
|         if (errorCode == 2) { | ||||
|             // TODO CGlueMgr::m_disconnectPending = 1;
 | ||||
|             // TODO ClientServices::Connection()->Disconnect();
 | ||||
|             CGlueMgr::m_disconnectPending = 1; | ||||
|             ClientServices::Connection()->Disconnect(); | ||||
|         } | ||||
| 
 | ||||
|         if (errorCode != 13) { | ||||
| @ -414,7 +461,7 @@ void CGlueMgr::PollAccountLogin(int32_t errorCode, const char* msg, int32_t comp | ||||
|                 FrameScript_SignalEvent(5, nullptr); | ||||
|                 CRealmList::UpdateList(); | ||||
|             } else { | ||||
|                 // TODO
 | ||||
|                 CGlueMgr::GetRealmList(true); | ||||
|             } | ||||
| 
 | ||||
|             return; | ||||
| @ -429,10 +476,12 @@ void CGlueMgr::PollAccountLogin(int32_t errorCode, const char* msg, int32_t comp | ||||
|     } | ||||
| 
 | ||||
|     if (op == COP_CONNECT) { | ||||
|         // TODO
 | ||||
| 
 | ||||
|         // TODO: Correct arguments (they're not used inside method)
 | ||||
|         ClientServices::Connection()->AccountLogin("", "", 0, 0); | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     CGlueMgr::SetScreen("charselect"); | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::PollLoginServerLogin() { | ||||
| @ -452,32 +501,53 @@ void CGlueMgr::PollLoginServerLogin() { | ||||
| 
 | ||||
|     switch (CGlueMgr::m_loginState) { | ||||
|     case LOGIN_STATE_FAILED: { | ||||
|         // TODO
 | ||||
| 
 | ||||
|         ClientServices::LoginConnection()->Logoff(); | ||||
|         CGlueMgr::m_idleState = IDLE_NONE; | ||||
|         CGlueMgr::m_showedDisconnect = 0; | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     case LOGIN_STATE_DOWNLOADFILE: { | ||||
|         // TODO
 | ||||
| 
 | ||||
|         // Get String from Server's answer
 | ||||
|         // v14 = (char *)(ClientServices::LoginConnection() + 3928);
 | ||||
|         const char* v14 = ""; | ||||
|         if (!SStrCmpI(v14, "Patch", STORM_MAX_STR)) { | ||||
|             CGlueMgr::PatchDownloadStart(); | ||||
|         } | ||||
|         if (!SStrCmpI(v14, "Survey", STORM_MAX_STR)) { | ||||
|             CGlueMgr::SurveyDownloadStart(); | ||||
|         } | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     case LOGIN_STATE_PIN: { | ||||
|         FrameScript_SignalEvent(5, nullptr); | ||||
|         // TODO
 | ||||
| 
 | ||||
|         // Calling GruntLogin::GetPinInfo
 | ||||
|         // v9 = (unsigned __int8 *)(*(int (__thiscall **)(int))(*(_DWORD *)v8 + 136))(v8);
 | ||||
|         int32_t v9[10] = {}; | ||||
|         FrameScript_SignalEvent(26, "%d%d%d%d%d%d%d%d%d%d", v9[0], v9[1], v9[2], v9[3], v9[4], v9[5], v9[6], v9[7], v9[8], v9[9]); | ||||
|         CGlueMgr::m_loginState = LOGIN_STATE_PIN_WAIT; | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     case LOGIN_STATE_MATRIX: { | ||||
|         // TODO
 | ||||
| 
 | ||||
|         // Calling GruntLogin::GetMatrixInfo
 | ||||
|         // (*(void (__thiscall **)(int, int *, int *, int *, int *, unsigned __int8 *, _DWORD **))(*(_DWORD *)v10 + 160))(v10, &v73, &v69, &v72, &v70, &v77, &v75);
 | ||||
|         CGlueMgr::m_matrixChallengeCount = 0; | ||||
|         CGlueMgr::m_matrixRemaining = 0; | ||||
|         CGlueMgr::m_loginState = LOGIN_STATE_MATRIX_WAIT; | ||||
|         FrameScript_SignalEvent(5, 0); | ||||
|         // TODO: FrameScript_SignalEvent(0x1Cu, "%d%d%d%d%b%d", v73, v69, v72, v70, v77, v75);
 | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
|     case LOGIN_STATE_TOKEN: { | ||||
|         // TODO
 | ||||
| 
 | ||||
|         CGlueMgr::m_loginState = LOGIN_STATE_TOKEN_WAIT; | ||||
|         FrameScript_SignalEvent(5, 0); | ||||
|         FrameScript_SignalEvent(38, 0); | ||||
|         break; | ||||
|     } | ||||
| 
 | ||||
| @ -496,6 +566,59 @@ void CGlueMgr::PollLoginServerLogin() { | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::PollCharacterList(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op) { | ||||
|     FrameScript_SignalEvent(4, "%s", msg); | ||||
| 
 | ||||
|     // TODO: if (CGlueMgr::HandleBattlenetDisconnect())
 | ||||
|     if (false) { | ||||
|         CGlueMgr::m_idleState = IDLE_NONE; | ||||
|         CGlueMgr::m_showedDisconnect = 0; | ||||
|     } | ||||
| 
 | ||||
|     if (!complete) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     if (!result) { | ||||
|         if (errorCode == 2) { | ||||
|             // TODO CCharacterSelection::ClearCharacterList();
 | ||||
|             CGlueMgr::GetRealmList(true); | ||||
|         } else { | ||||
|             FrameScript_SignalEvent(3, "%s%s", "OKAY", msg); | ||||
|             CGlueMgr::m_idleState = IDLE_NONE; | ||||
|             CGlueMgr::m_showedDisconnect = 0; | ||||
|         } | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     CGlueMgr::m_idleState = IDLE_NONE; | ||||
|     CGlueMgr::m_showedDisconnect = 0; | ||||
|     FrameScript_SignalEvent(5, nullptr); | ||||
|     // TODO: sub_4E4610();
 | ||||
|     if (!CGlueMgr::m_accountMsgAvailable) { | ||||
|         return; | ||||
|     } | ||||
| 
 | ||||
|     FrameScript_SignalEvent(34, 0); | ||||
|     CGlueMgr::m_accountMsgAvailable = 0; | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::PollUserSurvey() { | ||||
|     if (CGlueMgr::m_surveyDownload && false /* virtual call */) { | ||||
|         if (CGlueMgr::m_executedSurvey) { | ||||
|             // TODO
 | ||||
|         } else { | ||||
|             CGlueMgr::m_executedSurvey = 1; | ||||
|             if (CGlueMgr::SurveyExecute()) { | ||||
|                 auto text = FrameScript_GetText("LOGIN_STATE_SURVEY", -1, FRAMESCRIPT_GENDER::GENDER_NOT_APPLICABLE); | ||||
|                 FrameScript_SignalEvent(3, "%s%s", "CANCEL", text); | ||||
|                 CGlueMgr::SurveySendResults(); | ||||
|                 // TODO: CGlueMgr::m_surveyTimer = OsGetAsyncTimeMs();
 | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::InitCursor() { | ||||
|     uint32_t width; | ||||
|     uint32_t height; | ||||
| @ -690,13 +813,13 @@ void CGlueMgr::StatusDialogClick() { | ||||
|         } | ||||
| 
 | ||||
|         case IDLE_ACCOUNT_LOGIN: | ||||
|         case IDLE_3: { | ||||
|         case IDLE_CHARACTER_LIST: { | ||||
|             ClientServices::Connection()->Cancel(2); | ||||
| 
 | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
|         case IDLE_4: | ||||
|         case IDLE_REALM_LIST: | ||||
|         case IDLE_5: | ||||
|         case IDLE_6: | ||||
|         case IDLE_10: { | ||||
| @ -717,7 +840,7 @@ void CGlueMgr::StatusDialogClick() { | ||||
|             break; | ||||
|         } | ||||
| 
 | ||||
|         case IDLE_11: { | ||||
|         case IDLE_WORLD_LOGIN: { | ||||
|             CGlueMgr::m_showedDisconnect = 0; | ||||
|             CGlueMgr::m_idleState = IDLE_NONE; | ||||
| 
 | ||||
| @ -770,3 +893,22 @@ void CGlueMgr::UpdateCurrentScreen(const char* screen) { | ||||
| 
 | ||||
|     // TODO
 | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::SurveyDownloadStart() { | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::SurveyDownloadIdle() { | ||||
| } | ||||
| 
 | ||||
| bool CGlueMgr::SurveyExecute() { | ||||
|     return false; | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::SurveySendResults() { | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::PatchDownloadStart() { | ||||
| } | ||||
| 
 | ||||
| void CGlueMgr::PatchDownloadIdle() { | ||||
| } | ||||
|  | ||||
| @ -15,15 +15,15 @@ class CGlueMgr { | ||||
|             IDLE_NONE = 0, | ||||
|             IDLE_LOGIN_SERVER_LOGIN = 1, | ||||
|             IDLE_ACCOUNT_LOGIN = 2, | ||||
|             IDLE_3 = 3, | ||||
|             IDLE_4 = 4, | ||||
|             IDLE_CHARACTER_LIST = 3, | ||||
|             IDLE_REALM_LIST = 4, | ||||
|             IDLE_5 = 5, | ||||
|             IDLE_6 = 6, | ||||
|             IDLE_7 = 7, | ||||
|             IDLE_8 = 8, | ||||
|             IDLE_9 = 9, | ||||
|             IDLE_10 = 10, | ||||
|             IDLE_11 = 11, | ||||
|             IDLE_WORLD_LOGIN = 11, | ||||
|             IDLE_12 = 12, | ||||
|             IDLE_13 = 13 | ||||
|         }; | ||||
| @ -48,6 +48,7 @@ class CGlueMgr { | ||||
|         static int32_t m_lastLoginState; | ||||
|         static int32_t m_loginResult; | ||||
|         static int32_t m_loginState; | ||||
|         static int32_t m_matrixChallengeCount; | ||||
|         static int32_t m_matrixRemaining; | ||||
|         static int32_t m_reconnect; | ||||
|         static int32_t m_reload; | ||||
| @ -58,11 +59,19 @@ class CGlueMgr { | ||||
|         static CSimpleTop* m_simpleTop; | ||||
|         static int32_t m_suspended; | ||||
| 
 | ||||
|         static int32_t m_surveyTimer; | ||||
|         static int32_t m_executedSurvey; | ||||
|         static int32_t m_surveyDownload; | ||||
|         static int32_t m_patchDownload; | ||||
|         static bool m_deleteLocalPatch; | ||||
| 
 | ||||
|         // Static functions
 | ||||
|         static void ChangeRealm(const REALM_INFO* realmInfo); | ||||
|         static void DisplayLoginStatus(); | ||||
|         // TODO a1: const EVENT_DATA_IDLE*
 | ||||
|         static int32_t HandleDisplaySizeChanged(const CSizeEvent& event); | ||||
|         static void GetRealmList(bool showProgress); | ||||
|         static void GetCharacterList(); | ||||
|         static int32_t Idle(const void* a1, void* a2); | ||||
|         static void Initialize(); | ||||
|         static void InitCursor(); | ||||
| @ -70,6 +79,8 @@ class CGlueMgr { | ||||
|         static void QuitGame(); | ||||
|         static void PollAccountLogin(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op); | ||||
|         static void PollLoginServerLogin(); | ||||
|         static void PollCharacterList(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op); | ||||
|         static void PollUserSurvey(); | ||||
|         static void Resume(); | ||||
|         static void SetCurrentAccount(const char* accountName); | ||||
|         static void SetLoginStateAndResult(LOGIN_STATE state, LOGIN_RESULT result, char const* addrStr, char const* stateStr, char const* resultStr, uint8_t flags); | ||||
| @ -78,6 +89,16 @@ class CGlueMgr { | ||||
|         static void Sub4D8BA0(); | ||||
|         static void Suspend(); | ||||
|         static void UpdateCurrentScreen(const char* screen); | ||||
| 
 | ||||
|         // Survey Download System
 | ||||
|         static void SurveyDownloadStart(); | ||||
|         static void SurveyDownloadIdle(); | ||||
|         static bool SurveyExecute(); | ||||
|         static void SurveySendResults(); | ||||
| 
 | ||||
|         // Patch Download System
 | ||||
|         static void PatchDownloadStart(); | ||||
|         static void PatchDownloadIdle(); | ||||
| }; | ||||
| 
 | ||||
| #endif | ||||
|  | ||||
| @ -2,6 +2,7 @@ | ||||
| #include "net/Login.hpp" | ||||
| #include "client/ClientServices.hpp" | ||||
| #include "ui/FrameScript.hpp" | ||||
| #include <storm/Error.hpp> | ||||
| 
 | ||||
| const char* s_errorCodeTokens[] = { | ||||
|     "RESPONSE_SUCCESS", | ||||
| @ -110,6 +111,13 @@ const char* s_errorCodeTokens[] = { | ||||
|     "CHAR_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME", | ||||
| }; | ||||
| 
 | ||||
| void ClientConnection::AccountLogin(const char* name, const char* password, int32_t region, int32_t locale) { | ||||
|     STORM_ASSERT(this->m_statusComplete == 1); | ||||
|     STORM_ASSERT(name); | ||||
|     STORM_ASSERT(password); | ||||
|     this->Initiate(COP_AUTHENTICATE, 11, nullptr); | ||||
| } | ||||
| 
 | ||||
| void ClientConnection::AccountLogin_Finish(int32_t errorCode) { | ||||
|     this->Complete(errorCode == 12, errorCode); | ||||
| } | ||||
|  | ||||
| @ -23,6 +23,7 @@ class ClientConnection : public RealmConnection { | ||||
|         ClientConnection(RealmResponse* realmResponse) | ||||
|             : RealmConnection(realmResponse) | ||||
|             {}; | ||||
|         void AccountLogin(const char* name, const char* password, int32_t region, int32_t locale); | ||||
|         void AccountLogin_Finish(int32_t authResult); | ||||
|         void AccountLogin_Queued(); | ||||
|         void Cancel(int32_t errorCode); | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
| #include "ui/Types.hpp" | ||||
| #include "util/Lua.hpp" | ||||
| #include "util/Unimplemented.hpp" | ||||
| #include <cstdint> | ||||
| #include "glue/CGlueMgr.hpp" | ||||
| 
 | ||||
| int32_t Script_SetCharSelectModelFrame(lua_State* L) { | ||||
|     if (!lua_isstring(L, 1)) { | ||||
| @ -35,7 +35,10 @@ int32_t Script_SetCharSelectBackground(lua_State* L) { | ||||
| } | ||||
| 
 | ||||
| int32_t Script_GetCharacterListUpdate(lua_State* L) { | ||||
|     WHOA_UNIMPLEMENTED(0); | ||||
|     // TODO: CCharSelectInfo::ClearCharacterModel();
 | ||||
|     // TODO: CCharSelectInfo::ClearPetModel();
 | ||||
|     CGlueMgr::GetCharacterList(); | ||||
|     return 0; | ||||
| } | ||||
| 
 | ||||
| int32_t Script_GetNumCharacters(lua_State* L) { | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 VDm
						VDm