diff --git a/src/client/Client.cpp b/src/client/Client.cpp index eae20a6..2f45ffa 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -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); diff --git a/src/client/ClientHandlers.cpp b/src/client/ClientHandlers.cpp new file mode 100644 index 0000000..cab91c6 --- /dev/null +++ b/src/client/ClientHandlers.cpp @@ -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; +} diff --git a/src/client/ClientHandlers.hpp b/src/client/ClientHandlers.hpp new file mode 100644 index 0000000..4cb756c --- /dev/null +++ b/src/client/ClientHandlers.hpp @@ -0,0 +1,21 @@ +#ifndef CLIENT_CLIENT_HANDLERS_HPP +#define CLIENT_CLIENT_HANDLERS_HPP + +#include "net/Types.hpp" +#include + +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 diff --git a/src/client/ClientServices.cpp b/src/client/ClientServices.cpp index 13e9347..6063188 100644 --- a/src/client/ClientServices.cpp +++ b/src/client/ClientServices.cpp @@ -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(); diff --git a/src/client/ClientServices.hpp b/src/client/ClientServices.hpp index 7b80b60..57ec1b5 100644 --- a/src/client/ClientServices.hpp +++ b/src/client/ClientServices.hpp @@ -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 diff --git a/src/glue/CGlueMgr.cpp b/src/glue/CGlueMgr.cpp index 8251357..a004c00 100644 --- a/src/glue/CGlueMgr.cpp +++ b/src/glue/CGlueMgr.cpp @@ -340,8 +340,10 @@ void CGlueMgr::LoginServerLogin(const char* accountName, const char* password) { memset(const_cast(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; diff --git a/src/glue/CGlueMgr.hpp b/src/glue/CGlueMgr.hpp index 45abeac..aceba1e 100644 --- a/src/glue/CGlueMgr.hpp +++ b/src/glue/CGlueMgr.hpp @@ -5,6 +5,7 @@ #include "net/Types.hpp" #include +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);