feat(net): push and pop obj mgr in NetClient handlers

This commit is contained in:
fallenoak 2026-01-06 19:12:49 -06:00
parent eee2986220
commit b88f694285
No known key found for this signature in database
GPG Key ID: 7628F8E61AEA070D
2 changed files with 29 additions and 14 deletions

View File

@ -1,14 +1,15 @@
#include "net/connection/NetClient.hpp"
#include "net/connection/WowConnection.hpp"
#include "glue/CGlueMgr.hpp"
#include <cstdlib>
#include <cstring>
#include <new>
#include "net/connection/WowConnection.hpp"
#include "object/Client.hpp"
#include <common/DataStore.hpp>
#include <common/Prop.hpp>
#include <common/Time.hpp>
#include <storm/Error.hpp>
#include <storm/String.hpp>
#include <cstdlib>
#include <cstring>
#include <new>
HPROPCONTEXT s_propContext;
@ -245,29 +246,29 @@ int32_t NetClient::HandleCantConnect() {
}
int32_t NetClient::HandleConnect() {
// TODO push obj mgr
this->PushObjMgr();
this->m_netState = NS_CONNECTED;
// TODO pop obj mgr
this->PopObjMgr();
return 1;
}
int32_t NetClient::HandleData(uint32_t timeReceived, void* data, int32_t size) {
// TODO push obj mgr
this->PushObjMgr();
CDataStore msg = CDataStore(static_cast<uint8_t*>(data), size);
this->ProcessMessage(timeReceived, &msg, 0);
// TODO pop obj mgr
this->PopObjMgr();
return 1;
}
int32_t NetClient::HandleDisconnect() {
// TODO push obj mgr
this->PushObjMgr();
this->m_netState = NS_INITIALIZED;
@ -275,7 +276,7 @@ int32_t NetClient::HandleDisconnect() {
CGlueMgr::NetDisconnectHandler(this, nullptr);
// TODO pop obj mgr
this->PopObjMgr();
return 1;
}
@ -321,6 +322,10 @@ void NetClient::PongHandler(WowConnection* conn, CDataStore* msg) {
// TODO
}
void NetClient::PopObjMgr() {
ClntObjMgrPop();
}
void NetClient::ProcessMessage(uint32_t timeReceived, CDataStore* msg, int32_t a4) {
// TODO s_stats.messagesReceived++
@ -342,6 +347,12 @@ void NetClient::ProcessMessage(uint32_t timeReceived, CDataStore* msg, int32_t a
);
}
void NetClient::PushObjMgr() {
if (this->m_objMgr) {
ClntObjMgrPush(this->m_objMgr);
}
}
void NetClient::Send(CDataStore* msg) {
if (this->m_netState != NS_CONNECTED) {
return;

View File

@ -50,7 +50,7 @@ class NETEVENTQUEUE {
class NetClient : public WowConnectionResponse {
public:
// Virtual member functions
// Public virtual member functions
virtual void WCMessageReady(WowConnection* conn, uint32_t timeStamp, CDataStore* msg);
virtual void WCConnected(WowConnection* conn, WowConnection* inbound, uint32_t timeStamp, const NETCONNADDR* addr);
virtual void WCCantConnect(WowConnection* conn, uint32_t timeStamp, NETCONNADDR* addr);
@ -61,7 +61,7 @@ class NetClient : public WowConnectionResponse {
virtual int32_t HandleDisconnect();
virtual int32_t HandleCantConnect();
// Member functions
// Public member functions
void AddRef();
void AuthChallengeHandler(WowConnection* conn, CDataStore* msg);
void Connect(const char* addrStr);
@ -84,10 +84,10 @@ class NetClient : public WowConnectionResponse {
void SetObjMgr(ClntObjMgr* objMgr);
private:
// Static variables
// Private static variables
static int32_t s_clientCount;
// Member variables
// Private member variables
LoginData m_loginData;
NETSTATE m_netState = NS_UNINITIALIZED;
bool m_suspended = false;
@ -108,6 +108,10 @@ class NetClient : public WowConnectionResponse {
uint32_t m_connectedTimestamp = 0;
SCritSect m_pingLock;
ClntObjMgr* m_objMgr = nullptr;
// Private member functions
void PopObjMgr();
void PushObjMgr();
};
#endif