feat(glue): implement CGlueMgr::EnterWorld

This commit is contained in:
fallenoak 2025-10-06 21:55:47 -05:00
parent 119fa8996b
commit 78b5637ff9
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
8 changed files with 121 additions and 1 deletions

View File

@ -12,6 +12,7 @@
ClientConnection* g_clientConnection; ClientConnection* g_clientConnection;
char ClientServices::s_accountName[1280]; char ClientServices::s_accountName[1280];
CHARACTER_INFO ClientServices::s_characterInfo;
RealmResponse* ClientServices::s_clientRealmResponse; RealmResponse* ClientServices::s_clientRealmResponse;
ClientConnection* ClientServices::s_currentConnection; ClientConnection* ClientServices::s_currentConnection;
CVar* ClientServices::s_darkPortalVar; CVar* ClientServices::s_darkPortalVar;
@ -266,6 +267,12 @@ void ClientServices::SetAccountName(const char* accountName) {
SStrCopy(ClientServices::s_accountName, accountName, sizeof(ClientServices::s_accountName)); SStrCopy(ClientServices::s_accountName, accountName, sizeof(ClientServices::s_accountName));
} }
void ClientServices::SetCharacterInfo(const CHARACTER_INFO* info) {
STORM_ASSERT(info);
ClientServices::s_characterInfo = *info;
}
void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) { void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) {
STORM_ASSERT(handler); STORM_ASSERT(handler);
STORM_ASSERT(ClientServices::s_currentConnection); STORM_ASSERT(ClientServices::s_currentConnection);

View File

@ -13,6 +13,7 @@ class ClientServices : public LoginResponse {
public: public:
// Static variables // Static variables
static char s_accountName[1280]; static char s_accountName[1280];
static CHARACTER_INFO s_characterInfo;
static RealmResponse* s_clientRealmResponse; static RealmResponse* s_clientRealmResponse;
static ClientConnection* s_currentConnection; static ClientConnection* s_currentConnection;
static CVar* s_darkPortalVar; static CVar* s_darkPortalVar;
@ -42,6 +43,7 @@ class ClientServices : public LoginResponse {
static void Logon(const char* accountName, const char* password); static void Logon(const char* accountName, const char* password);
static void SelectRealm(const char* realmName); static void SelectRealm(const char* realmName);
static void SetAccountName(const char* accountName); static void SetAccountName(const char* accountName);
static void SetCharacterInfo(const CHARACTER_INFO* info);
static void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param); static void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param);
static int32_t SetSelectedRealmInfo(int32_t a1); static int32_t SetSelectedRealmInfo(int32_t a1);

View File

@ -7,6 +7,7 @@
#include "ui/CSimpleModelFFX.hpp" #include "ui/CSimpleModelFFX.hpp"
TSGrowableArray<CharacterSelectionDisplay> CCharacterSelection::s_characterList; TSGrowableArray<CharacterSelectionDisplay> CCharacterSelection::s_characterList;
int32_t CCharacterSelection::s_enterWorldIndex;
CSimpleModelFFX* CCharacterSelection::s_modelFrame; CSimpleModelFFX* CCharacterSelection::s_modelFrame;
uint32_t CCharacterSelection::s_restrictHuman; uint32_t CCharacterSelection::s_restrictHuman;
uint32_t CCharacterSelection::s_restrictDwarf; uint32_t CCharacterSelection::s_restrictDwarf;
@ -35,6 +36,14 @@ void CCharacterSelection::EnumerateCharactersCallback(const CHARACTER_INFO& info
// TODO // TODO
} }
const CharacterSelectionDisplay* CCharacterSelection::GetSelectedCharacter() {
if (CCharacterSelection::s_selectionIndex < 0 || CCharacterSelection::s_selectionIndex >= CCharacterSelection::s_characterList.Count()) {
return nullptr;
}
return &CCharacterSelection::s_characterList[CCharacterSelection::s_selectionIndex];
}
void CCharacterSelection::OnGetCharacterList() { void CCharacterSelection::OnGetCharacterList() {
CCharacterSelection::s_characterList.SetCount(0); CCharacterSelection::s_characterList.SetCount(0);

View File

@ -15,6 +15,7 @@ class CCharacterSelection {
public: public:
// Static variables // Static variables
static TSGrowableArray<CharacterSelectionDisplay> s_characterList; static TSGrowableArray<CharacterSelectionDisplay> s_characterList;
static int32_t s_enterWorldIndex;
static CSimpleModelFFX* s_modelFrame; static CSimpleModelFFX* s_modelFrame;
static uint32_t s_restrictHuman; static uint32_t s_restrictHuman;
static uint32_t s_restrictDwarf; static uint32_t s_restrictDwarf;
@ -32,6 +33,7 @@ class CCharacterSelection {
static void ClearCharacterList(); static void ClearCharacterList();
static void ClearCharacterModel(); static void ClearCharacterModel();
static void EnumerateCharactersCallback(const CHARACTER_INFO& info, void* param); static void EnumerateCharactersCallback(const CHARACTER_INFO& info, void* param);
static const CharacterSelectionDisplay* GetSelectedCharacter();
static void OnGetCharacterList(); static void OnGetCharacterList();
static void RenderPrep(); static void RenderPrep();
static void SetBackgroundModel(const char* modelPath); static void SetBackgroundModel(const char* modelPath);

View File

@ -52,6 +52,7 @@ int32_t CGlueMgr::m_accountMsgAvailable;
char CGlueMgr::m_accountName[1280]; char CGlueMgr::m_accountName[1280];
float CGlueMgr::m_aspect; float CGlueMgr::m_aspect;
bool CGlueMgr::m_authenticated; bool CGlueMgr::m_authenticated;
const CharacterSelectionDisplay* CGlueMgr::m_characterInfo;
char CGlueMgr::m_currentScreen[64]; char CGlueMgr::m_currentScreen[64];
int32_t CGlueMgr::m_disconnectPending; int32_t CGlueMgr::m_disconnectPending;
int32_t CGlueMgr::m_displayingQueueDialog; int32_t CGlueMgr::m_displayingQueueDialog;
@ -112,7 +113,95 @@ void CGlueMgr::ChangeRealm(const REALM_INFO* realmInfo) {
} }
void CGlueMgr::EnterWorld() { void CGlueMgr::EnterWorld() {
// TODO if (!ClientServices::GetSelectedRealm()) {
return;
}
auto character = CCharacterSelection::GetSelectedCharacter();
CGlueMgr::m_characterInfo = character;
if (!character) {
return;
}
CCharacterSelection::s_enterWorldIndex = CCharacterSelection::s_selectionIndex;
if (!ClientServices::Connection()->IsConnected()) {
return;
}
// Validate character flags
auto flags = CGlueMgr::m_characterInfo->info.flags;
if (flags & 0x4) {
// TODO
// auto errorToken = ClientServices::GetErrorToken(84);
// auto errorText = FrameScript_GetText(errorToken, -1, GENDER_NOT_APPLICABLE);
// FrameScript_SignalEvent(3, "%s%s", "OKAY", errorText);
return;
}
if (flags & 0x1000000) {
// TODO
// auto errorToken = ClientServices::GetErrorToken(85);
// auto errorText = FrameScript_GetText(errorToken, -1, GENDER_NOT_APPLICABLE);
// FrameScript_SignalEvent(3, "%s%s", "OKAY", errorText);
return;
}
if (flags & 0x4000) {
FrameScript_SignalEvent(23, "%s", "CHAR_RENAME_DESCRIPTION");
return;
}
if (!(flags & 0x2000000)) {
if (NameNeedsDeclension(CURRENT_LANGUAGE, CGlueMgr::m_characterInfo->info.name)) {
FrameScript_SignalEvent(24, nullptr);
return;
}
}
// Validate expansion
auto raceRec = g_chrRacesDB.GetRecord(character->info.raceID);
auto classRec = g_chrClassesDB.GetRecord(character->info.classID);
if (
!raceRec
|| !classRec
|| ClientServices::Connection()->m_accountExpansion < raceRec->m_requiredExpansion
|| ClientServices::Connection()->m_accountExpansion < classRec->m_requiredExpansion
) {
// TODO
// auto errorToken = ClientServices::GetErrorToken(82);
// auto errorText = FrameScript_GetText(errorToken, -1, GENDER_NOT_APPLICABLE);
// FrameScript_SignalEvent(3, "%s%s", "OKAY", errorText);
return;
}
char indexStr[32];
SStrPrintf(indexStr, sizeof(indexStr), "%d", CCharacterSelection::s_selectionIndex);
// TODO g_lastCharacterIndex->Set(indexStr, 1, 0, 0, 1);
ClientServices::SetAccountName(CGlueMgr::m_accountName);
ClientServices::SetCharacterInfo(&CGlueMgr::m_characterInfo->info);
// TODO game tip
// TODO loading screen
// TODO save all cvars
if (ClientServices::LoginConnection()->GetLoginServerType() == 0) {
ClientServices::LoginConnection()->Logoff();
}
CGlueMgr::m_idleState = IDLE_ENTER_WORLD;
CGlueMgr::m_showedDisconnect = 0;
} }
void CGlueMgr::DisplayLoginStatus() { void CGlueMgr::DisplayLoginStatus() {

View File

@ -7,6 +7,7 @@
class CDataStore; class CDataStore;
class CSimpleTop; class CSimpleTop;
struct CharacterSelectionDisplay;
class CGlueMgr { class CGlueMgr {
public: public:
@ -36,6 +37,7 @@ class CGlueMgr {
static char m_accountName[]; static char m_accountName[];
static float m_aspect; static float m_aspect;
static bool m_authenticated; static bool m_authenticated;
static const CharacterSelectionDisplay* m_characterInfo;
static char m_currentScreen[]; static char m_currentScreen[];
static int32_t m_disconnectPending; static int32_t m_disconnectPending;
static int32_t m_displayingQueueDialog; static int32_t m_displayingQueueDialog;

View File

@ -1,5 +1,11 @@
#include "glue/Character.hpp" #include "glue/Character.hpp"
bool NameNeedsDeclension(WOW_LOCALE locale, const char* name) {
// TODO
return false;
}
void ValidateNameInitialize(int32_t localeMask, int32_t charsetMask) { void ValidateNameInitialize(int32_t localeMask, int32_t charsetMask) {
// TODO // TODO
} }

View File

@ -1,8 +1,11 @@
#ifndef GLUE_CHARACTER_HPP #ifndef GLUE_CHARACTER_HPP
#define GLUE_CHARACTER_HPP #define GLUE_CHARACTER_HPP
#include "util/Locale.hpp"
#include <cstdint> #include <cstdint>
bool NameNeedsDeclension(WOW_LOCALE locale, const char* name);
void ValidateNameInitialize(int32_t localeMask, int32_t charsetMask); void ValidateNameInitialize(int32_t localeMask, int32_t charsetMask);
#endif #endif