diff --git a/src/client/Client.cpp b/src/client/Client.cpp index 467e246..e92484c 100644 --- a/src/client/Client.cpp +++ b/src/client/Client.cpp @@ -2,6 +2,7 @@ #include "async/AsyncFile.hpp" #include "client/ClientServices.hpp" #include "client/CmdLine.hpp" +#include "client/ClientHandlers.hpp" #include "console/CVar.hpp" #include "console/Client.hpp" #include "console/Device.hpp" @@ -667,5 +668,9 @@ void WowClientInit() { void ClientInitializeGame(int32_t continentID, const C3Vector& position) { // TODO CGGameUI::InitializeGame(); + + ClientServices::SetMessageHandler(SMSG_NEW_WORLD, &NewWorldHandler, nullptr); + ClientServices::SetMessageHandler(SMSG_LOGIN_VERIFY_WORLD, &LoginVerifyWorldHandler, nullptr); + // TODO } diff --git a/src/client/ClientHandlers.cpp b/src/client/ClientHandlers.cpp new file mode 100644 index 0000000..bd37c0c --- /dev/null +++ b/src/client/ClientHandlers.cpp @@ -0,0 +1,60 @@ +#include "client/ClientHandlers.hpp" + +#include +#include + +#include "console/Line.hpp" + + +uint32_t s_newZoneID = 0; +C3Vector s_newPosition; +float s_newFacing = 0.0f; +const char* s_newMapname = nullptr; + + +int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + STORM_ASSERT(msgId == SMSG_NEW_WORLD); + + msg->Get(s_newZoneID); + msg->Get(s_newPosition.x); + msg->Get(s_newPosition.y); + msg->Get(s_newPosition.z); + msg->Get(s_newFacing); + + if (msg->IsRead()) { + // TODO + return 1; + } else { + ConsoleWrite("Bad SMSG_NEW_WORLD\n", DEFAULT_COLOR); + msg->Reset(); + return 1; + } +} + +int32_t LoginVerifyWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg) { + STORM_ASSERT(msgId == SMSG_LOGIN_VERIFY_WORLD); + + uint32_t zoneID; + msg->Get(zoneID); + + C3Vector position; + msg->Get(position.x); + msg->Get(position.y); + msg->Get(position.z); + + float facing; + msg->Get(facing); + // zoneID != ClntObjMgrGetMapID() + if (false) { + s_newFacing = facing; + s_newPosition = position; + s_newZoneID = zoneID; + //if (zoneID < dword_AD4170 || zoneID > dword_AD416C || (v0 = *(_DWORD*)(dword_AD4180 + 4 * (zoneID - dword_AD4170))) == 0) { + // ConsoleWrite("Bad SMSG_NEW_WORLD zoneID\n", 0); + // return 0; + //} + //s_newMapname = *(_DWORD*)(v0 + 4); + //LoadNewWorld(0, 0); + } + return 1; +} diff --git a/src/client/ClientHandlers.hpp b/src/client/ClientHandlers.hpp new file mode 100644 index 0000000..7bc3510 --- /dev/null +++ b/src/client/ClientHandlers.hpp @@ -0,0 +1,13 @@ +#ifndef CLIENT_CLIENTHANDLERS_HPP +#define CLIENT_CLIENTHANDLERS_HPP + +#include "net/Types.hpp" + +class CDataStore; + + +int32_t NewWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); +int32_t LoginVerifyWorldHandler(void* param, NETMESSAGE msgId, uint32_t time, CDataStore* msg); + + +#endif // CLIENT_CLIENTHANDLERS_HPP diff --git a/src/client/ClientServices.cpp b/src/client/ClientServices.cpp index 76a5502..c5c52ac 100644 --- a/src/client/ClientServices.cpp +++ b/src/client/ClientServices.cpp @@ -65,6 +65,12 @@ ClientServices* ClientServices::GetInstance() { return ClientServices::s_instance; } +void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param) { + STORM_ASSERT(ClientServices::s_currentConnection); + STORM_ASSERT(handler); + s_currentConnection->SetMessageHandler(msgId, handler, param); +} + void ClientServices::GetRealmList() { // TODO diff --git a/src/client/ClientServices.hpp b/src/client/ClientServices.hpp index e767685..4cc7b1f 100644 --- a/src/client/ClientServices.hpp +++ b/src/client/ClientServices.hpp @@ -2,6 +2,7 @@ #define CLIENT_CLIENT_SERVICES_HPP #include "net/login/LoginResponse.hpp" +#include "net/connection/NetClient.hpp" #include class ClientConnection; @@ -34,6 +35,7 @@ class ClientServices : public LoginResponse { static void ConnectToSelectedServer(); static ClientConnection* Connection(); static ClientServices* GetInstance(); + static void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param); static void GetRealmList(); static void GetCharacterList(); static void CharacterLogin(uint64_t id, const C3Vector& position);