From 1326c896df75879e80f1e280e0d66623c1fc0ada Mon Sep 17 00:00:00 2001 From: VDm Date: Thu, 31 Jul 2025 01:03:23 +0400 Subject: [PATCH] feat(map): add CMap static members --- src/client/ClientServices.cpp | 5 ++ src/client/ClientServices.hpp | 1 + src/glue/CGlueMgr.cpp | 14 +++-- src/net/connection/NetClient.cpp | 5 ++ src/net/connection/NetClient.hpp | 1 + src/world/CWorld.cpp | 2 + src/world/map/CMap.cpp | 92 +++++++++++++++++++++++++++++++- src/world/map/CMap.hpp | 25 ++++++++- src/world/map/Types.hpp | 2 +- 9 files changed, 139 insertions(+), 8 deletions(-) diff --git a/src/client/ClientServices.cpp b/src/client/ClientServices.cpp index 1754ffc..38fb200 100644 --- a/src/client/ClientServices.cpp +++ b/src/client/ClientServices.cpp @@ -189,6 +189,11 @@ void ClientServices::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler s_currentConnection->SetMessageHandler(msgId, handler, param); } +void ClientServices::ClearMessageHandler(NETMESSAGE msgId) { + STORM_ASSERT(ClientServices::s_currentConnection); + s_currentConnection->ClearMessageHandler(msgId); +} + void ClientServices::GetRealmList() { STORM_ASSERT(ClientServices::s_currentConnection); ClientServices::s_currentConnection->Initiate(COP_GET_REALMS, 35, nullptr); diff --git a/src/client/ClientServices.hpp b/src/client/ClientServices.hpp index efb2d3e..3ad1a9b 100644 --- a/src/client/ClientServices.hpp +++ b/src/client/ClientServices.hpp @@ -38,6 +38,7 @@ class ClientServices : public LoginResponse { static ClientConnection* Connection(); static ClientServices* GetInstance(); static void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param); + static void ClearMessageHandler(NETMESSAGE msgId); static void GetRealmList(); static void GetCharacterList(); static void EnumerateCharacters(ENUMERATE_CHARACTERS_CALLBACK fcn, void* param); diff --git a/src/glue/CGlueMgr.cpp b/src/glue/CGlueMgr.cpp index 345ae21..e64431e 100644 --- a/src/glue/CGlueMgr.cpp +++ b/src/glue/CGlueMgr.cpp @@ -1062,8 +1062,12 @@ void CGlueMgr::Suspend() { // TODO FrameXML_FreeHashNodes(); - - // TODO + ClientServices::ClearMessageHandler(SMSG_CHARACTER_RENAME_RESULT); + ClientServices::ClearMessageHandler(SMSG_SET_PLAYER_DECLINED_NAMES_RESULT); + ClientServices::ClearMessageHandler(SMSG_CHAR_CUSTOMIZE); + ClientServices::ClearMessageHandler(SMSG_REALM_SPLIT); + ClientServices::ClearMessageHandler(SMSG_KICK_REASON); + // TODO: ClientServices::ClearMessageHandler(1242); } void CGlueMgr::UpdateCurrentScreen(const char* screen) { @@ -1121,9 +1125,9 @@ void CGlueMgr::PollEnterWorld() { auto info = CGlueMgr::m_characterInfo; - //if (*(_BYTE*)(info + 385)) - // sub_4D9660(*(_BYTE*)(info + 377), (int)v51, *(_BYTE*)(info + 376), (int)&v68); - + if (info->firstLogin) { + // sub_4D9660(info->classID, mapID, info->raceID, info->position); + } CGlueMgr::Suspend(); ClientInitializeGame(info->mapID, info->position); diff --git a/src/net/connection/NetClient.cpp b/src/net/connection/NetClient.cpp index ece9cce..880b101 100644 --- a/src/net/connection/NetClient.cpp +++ b/src/net/connection/NetClient.cpp @@ -554,6 +554,11 @@ void NetClient::SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, voi this->m_handlerParams[msgId] = param; } +void NetClient::ClearMessageHandler(NETMESSAGE msgId) { + this->m_handlers[msgId] = nullptr; + this->m_handlerParams[msgId] = nullptr; +} + void NetClient::WCCantConnect(WowConnection* conn, uint32_t timeStamp, NETCONNADDR* addr) { if (conn == this->m_redirectConnection) { // TODO diff --git a/src/net/connection/NetClient.hpp b/src/net/connection/NetClient.hpp index 7785d59..f71f69d 100644 --- a/src/net/connection/NetClient.hpp +++ b/src/net/connection/NetClient.hpp @@ -85,6 +85,7 @@ class NetClient : public WowConnectionResponse { void SetDelete(); void SetLoginData(LoginData* loginData); void SetMessageHandler(NETMESSAGE msgId, MESSAGE_HANDLER handler, void* param); + void ClearMessageHandler(NETMESSAGE msgId); void DisplayNetworkStats(); void GetNetStats(float& bandwidthIn, float& bandwidthOut, uint32_t& latency); void PushObjMgr(); diff --git a/src/world/CWorld.cpp b/src/world/CWorld.cpp index 4b7fd58..e516db7 100644 --- a/src/world/CWorld.cpp +++ b/src/world/CWorld.cpp @@ -50,6 +50,8 @@ void CWorld::Initialize() { (CWorld::s_enables2 & Enables2::Enable_HwPcf) != 0 ); + CMap::Initialize(); + // TODO } diff --git a/src/world/map/CMap.cpp b/src/world/map/CMap.cpp index a0fe23c..a637999 100644 --- a/src/world/map/CMap.cpp +++ b/src/world/map/CMap.cpp @@ -2,6 +2,10 @@ #include "world/daynight/DayNight.hpp" #include "util/SFile.hpp" #include +#include +#include + +#include @@ -11,9 +15,95 @@ char CMap::wdtFilename[STORM_MAX_PATH]; uint32_t CMap::version; SMMapHeader CMap::header; SMAreaInfo CMap::areaInfo[64 * 64]; -uint32_t CMap::uniqueId; +int32_t CMap::uniqueId; int32_t CMap::bDungeon; +int32_t CMap::counts[11]; +int32_t CMap::freeCounts[11]; +TSGrowableArray CMap::scCollideList; +uint32_t CMap::scCollideCnt; +uint32_t CMap::cCount; +uint32_t* CMap::lightHeap; +uint32_t* CMap::cacheLightHeap; +uint32_t* CMap::mapObjGroupHeap; +uint32_t* CMap::mapObjHeap; +uint32_t* CMap::baseObjLinkHeap; +uint32_t* CMap::areaHeap; +uint32_t* CMap::areaMedHeap; +uint32_t* CMap::areaLowHeap; +uint32_t* CMap::chunkHeap; +uint32_t* CMap::doodadDefHeap; +uint32_t* CMap::entityHeap; +uint32_t* CMap::mapObjDefGroupHeap; +uint32_t* CMap::mapObjDefHeap; +uint32_t* CMap::chunkLiquidHeap; + + + +void CMap::Initialize() { + // TODO + memset(&CMap::counts, 0, sizeof(CMap::counts)); + memset(&CMap::freeCounts, 0, sizeof(CMap::freeCounts)); + memset(&CMap::areaInfo, 0, sizeof(CMap::areaInfo)); + CMap::scCollideList.SetCount(2048); + CMap::scCollideCnt = 0; + CMap::cCount = 0; + CMap::uniqueId = -2; + CMap::bDungeon = 0; + + // TODO + + CMap::MapMemInitialize(); +} + +void CMap::MapMemInitialize() { + CMap::lightHeap = NEW(uint32_t); + *CMap::lightHeap = ObjectAllocAddHeap(212, 128, "WLIGHT", true); + + CMap::cacheLightHeap = NEW(uint32_t); + *CMap::cacheLightHeap = ObjectAllocAddHeap(132, 256, "WCACHELIGHT", true); + + CMap::mapObjGroupHeap = NEW(uint32_t); + *CMap::mapObjGroupHeap = ObjectAllocAddHeap(444, 128, "WMAPOBJGROUP", true); + + CMap::mapObjHeap = NEW(uint32_t); + *CMap::mapObjHeap = ObjectAllocAddHeap(2552, 32, "WMAPOBJ", true); + + CMap::baseObjLinkHeap = NEW(uint32_t); + *CMap::baseObjLinkHeap = ObjectAllocAddHeap(28, 10000, "WBASEOBJLINK", true); + + CMap::areaHeap = NEW(uint32_t); + *CMap::areaHeap = ObjectAllocAddHeap(1212, 16, "WAREA", true); + + CMap::areaMedHeap = NEW(uint32_t); + *CMap::areaMedHeap = ObjectAllocAddHeap(33404, 16, "WAREAMED", true); + + CMap::areaLowHeap = NEW(uint32_t); + *CMap::areaLowHeap = ObjectAllocAddHeap(92, 16, "WAREALOW", true); + + CMap::chunkHeap = NEW(uint32_t); + *CMap::chunkHeap = ObjectAllocAddHeap(344, 256, "WCHUNK", true); + + CMap::doodadDefHeap = NEW(uint32_t); + *CMap::doodadDefHeap = ObjectAllocAddHeap(368, 5000, "WDOODADDEF", true); + + CMap::entityHeap = NEW(uint32_t); + *CMap::entityHeap = ObjectAllocAddHeap(208, 128, "WENTITY", true); + + CMap::mapObjDefGroupHeap = NEW(uint32_t); + *CMap::mapObjDefGroupHeap = ObjectAllocAddHeap(192, 128, "WMAPOBJDEFGROUP", true); + + CMap::mapObjDefHeap = NEW(uint32_t); + *CMap::mapObjDefHeap = ObjectAllocAddHeap(344, 64, "WMAPOBJDEF", true); + + CMap::chunkLiquidHeap = NEW(uint32_t); + *CMap::chunkLiquidHeap = ObjectAllocAddHeap(1092, 64, "WCHUNKLIQUID", true); + + int32_t vendor; + if (OsGetProcessorFeaturesEx(vendor) & 4) { + // TODO: dword_CF08F8 = 1; + } +} void CMap::Load(const char* mapName, int32_t zoneID) { // TODO diff --git a/src/world/map/CMap.hpp b/src/world/map/CMap.hpp index c6f458f..2d23a18 100644 --- a/src/world/map/CMap.hpp +++ b/src/world/map/CMap.hpp @@ -3,6 +3,7 @@ #include "world/map/Types.hpp" #include +#include class CMap { public: @@ -12,10 +13,32 @@ class CMap { static uint32_t version; static SMMapHeader header; static SMAreaInfo areaInfo[64 * 64]; - static uint32_t uniqueId; + static int32_t uniqueId; static int32_t bDungeon; + static int32_t counts[11]; + static int32_t freeCounts[11]; + static TSGrowableArray scCollideList; + static uint32_t scCollideCnt; + static uint32_t cCount; + + static uint32_t* lightHeap; + static uint32_t* cacheLightHeap; + static uint32_t* mapObjGroupHeap; + static uint32_t* mapObjHeap; + static uint32_t* baseObjLinkHeap; + static uint32_t* areaHeap; + static uint32_t* areaMedHeap; + static uint32_t* areaLowHeap; + static uint32_t* chunkHeap; + static uint32_t* doodadDefHeap; + static uint32_t* entityHeap; + static uint32_t* mapObjDefGroupHeap; + static uint32_t* mapObjDefHeap; + static uint32_t* chunkLiquidHeap; + static void Initialize(); + static void MapMemInitialize(); static void Load(const char* mapName, int32_t zoneID); static void LoadWdt(); static void LoadTextureBlob(); diff --git a/src/world/map/Types.hpp b/src/world/map/Types.hpp index 709f563..0028e3e 100644 --- a/src/world/map/Types.hpp +++ b/src/world/map/Types.hpp @@ -23,7 +23,7 @@ struct SMAreaInfo { struct SMMapObjDef { uint32_t nameId; - uint32_t uniqueId; + int32_t uniqueId; C3Vector pos; C3Vector rot; CAaBox extents;