feat(client): register handlers in ClientInitializeGame

This commit is contained in:
fallenoak 2025-09-22 19:59:23 -07:00
parent 667e50bd67
commit ea7fda972e
7 changed files with 94 additions and 7 deletions

View File

@ -1,5 +1,6 @@
#include "client/Client.hpp"
#include "async/AsyncFile.hpp"
#include "client/ClientHandlers.hpp"
#include "client/ClientServices.hpp"
#include "console/CVar.hpp"
#include "console/Client.hpp"
@ -30,6 +31,21 @@ void BaseInitializeGlobal() {
PropInitialize();
}
void ClientInitializeGame(uint32_t mapId, C3Vector position) {
// TODO
ClientServices::SetMessageHandler(SMSG_NOTIFICATION, NotifyHandler, nullptr);
ClientServices::SetMessageHandler(SMSG_PLAYED_TIME, PlayedTimeHandler, nullptr);
ClientServices::SetMessageHandler(SMSG_NEW_WORLD, NewWorldHandler, nullptr);
ClientServices::SetMessageHandler(SMSG_TRANSFER_PENDING, TransferPendingHandler, nullptr);
ClientServices::SetMessageHandler(SMSG_TRANSFER_ABORTED, TransferAbortedHandler, nullptr);
ClientServices::SetMessageHandler(SMSG_LOGIN_VERIFY_WORLD, LoginVerifyWorldHandler, nullptr);
ClientServices::SetMessageHandler(SMSG_KICK_REASON, CGlueMgr::OnKickReasonMsg, nullptr);
// TODO
}
void ClientMiscInitialize() {
// TODO
@ -48,10 +64,6 @@ void ClientMiscInitialize() {
// TODO
}
void ClientInitializeGame(uint32_t mapId, C3Vector position) {
// TODO
}
void ClientPostClose(int32_t a1) {
// TODO s_finalDialog = a1;
EventPostCloseEx(nullptr);

View File

@ -0,0 +1,37 @@
#include "client/ClientHandlers.hpp"
int32_t LoginVerifyWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
}
int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
}
int32_t NotifyHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
}
int32_t PlayedTimeHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
}
int32_t TransferAbortedHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
}
int32_t TransferPendingHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
}

View File

@ -0,0 +1,21 @@
#ifndef CLIENT_CLIENT_HANDLERS_HPP
#define CLIENT_CLIENT_HANDLERS_HPP
#include "net/Types.hpp"
#include <cstdint>
class CDataStore;
int32_t LoginVerifyWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t NotifyHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t PlayedTimeHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t TransferAbortedHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
int32_t TransferPendingHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
#endif

View File

@ -154,6 +154,13 @@ void ClientServices::SetAccountName(const char* accountName) {
SStrCopy(ClientServices::s_accountName, accountName, sizeof(ClientServices::s_accountName));
}
void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) {
STORM_ASSERT(handler);
STORM_ASSERT(ClientServices::s_currentConnection);
ClientServices::s_currentConnection->SetMessageHandler(msgId, handler, param);
}
int32_t ClientServices::SetSelectedRealmInfo(int32_t a1) {
auto instance = ClientServices::GetInstance();

View File

@ -1,6 +1,7 @@
#ifndef CLIENT_CLIENT_SERVICES_HPP
#define CLIENT_CLIENT_SERVICES_HPP
#include "net/connection/NetClient.hpp"
#include "net/login/LoginResponse.hpp"
class ClientConnection;
@ -33,6 +34,7 @@ class ClientServices : public LoginResponse {
static void Logon(const char* accountName, const char* password);
static void SelectRealm(const char* realmName);
static void SetAccountName(const char* accountName);
static void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param);
static int32_t SetSelectedRealmInfo(int32_t a1);
// Virtual member functions

View File

@ -340,8 +340,10 @@ void CGlueMgr::LoginServerLogin(const char* accountName, const char* password) {
memset(const_cast<char*>(password), 0, SStrLen(password));
}
void CGlueMgr::QuitGame() {
ClientPostClose(0);
int32_t CGlueMgr::OnKickReasonMsg(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) {
// TODO
return 0;
}
void CGlueMgr::PollAccountLogin(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op) {
@ -497,6 +499,10 @@ void CGlueMgr::PollLoginServerLogin() {
}
}
void CGlueMgr::QuitGame() {
ClientPostClose(0);
}
void CGlueMgr::Resume() {
// TODO
// CGlueMgr::m_disconnectPending = 0;

View File

@ -5,6 +5,7 @@
#include "net/Types.hpp"
#include <cstdint>
class CDataStore;
class CSimpleTop;
class CGlueMgr {
@ -62,10 +63,11 @@ class CGlueMgr {
static int32_t Idle(const void* a1, void* a2);
static void Initialize();
static void LoginServerLogin(const char* accountName, const char* password);
static void QuitGame();
static int32_t OnKickReasonMsg(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg);
static void PollAccountLogin(int32_t errorCode, const char* msg, int32_t complete, int32_t result, WOWCS_OPS op);
static void PollEnterWorld();
static void PollLoginServerLogin();
static void QuitGame();
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);