From b6d8c9c215c7ca1a982b0889524f7ac8fdb349dd Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Sat, 16 Mar 2024 23:28:06 +0800 Subject: [PATCH] [saco] Update `DoProcessStuff()` * Add `CNetGame::Process()` stub * Add `CNetGame::UpdateNetwork()` stub * Implement `GetPacketID(...)` * Implement `HasTimestamps()` --- saco/main.cpp | 12 +++++++++++ saco/net/netgame.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++ saco/net/netgame.h | 4 ++++ 3 files changed, 67 insertions(+) diff --git a/saco/main.cpp b/saco/main.cpp index 0e723a2..f12fd54 100644 --- a/saco/main.cpp +++ b/saco/main.cpp @@ -349,6 +349,18 @@ void DoInitStuff() void DoProcessStuff() { DoInitStuff(); + + SetupD3DFog(TRUE); + + // Process the netgame if it's active. + if(pNetGame) { + //Sleep(0); // This hands the context over to raknet + pNetGame->Process(); + } + + if(pAudioStream) { + pAudioStream->Process(); + } } //---------------------------------------------------- diff --git a/saco/net/netgame.cpp b/saco/net/netgame.cpp index d3db24d..a8693f3 100644 --- a/saco/net/netgame.cpp +++ b/saco/net/netgame.cpp @@ -4,6 +4,34 @@ extern CGame *pGame; extern CChatWindow *pChatWindow; +//---------------------------------------------------- + +BYTE GetPacketID(Packet *p) +{ + if (p==0) return 255; + + if ((unsigned char)p->data[0] == ID_TIMESTAMP) { + assert(p->length > sizeof(unsigned char) + sizeof(unsigned long)); + return (unsigned char) p->data[sizeof(unsigned char) + sizeof(unsigned long)]; + } + else { + return (unsigned char) p->data[0]; + } +} + +//---------------------------------------------------- + +bool HasTimestamps(Packet *p) +{ + if (p==0) return 0; + + if ((unsigned char)p->data[0] == ID_TIMESTAMP) + return true; + return false; +} + +//---------------------------------------------------- + CNetGame::CNetGame(PCHAR szHostOrIp, int iPort, PCHAR szPlayerName, PCHAR szPass) { @@ -32,6 +60,29 @@ CNetGame::CNetGame(PCHAR szHostOrIp, int iPort, //---------------------------------------------------- +void CNetGame::Process() +{ + UpdateNetwork(); + // TODO: CNetGame::Process() +} + +//---------------------------------------------------- +// UPDATE NETWORK +//---------------------------------------------------- + +void CNetGame::UpdateNetwork() +{ +/* Packet* pkt=NULL; + unsigned char packetIdentifier; + + while((pkt = m_pRakClient->Receive())) + { + + }*/ + + // TODO: CNetGame::UpdateNetwork() +} + void CNetGame::InitPools() { m_pPools = (NETGAME_POOLS *)calloc(1, sizeof(NETGAME_POOLS)); diff --git a/saco/net/netgame.h b/saco/net/netgame.h index 0f00401..9797a76 100644 --- a/saco/net/netgame.h +++ b/saco/net/netgame.h @@ -43,6 +43,8 @@ private: RakClientInterface *m_pRakClient; + void UpdateNetwork(); + char _gap4[44]; char m_szHostOrIp[257]; char m_szHostName[257]; @@ -63,6 +65,8 @@ public: CNetGame(char *a2, int a3, char *a4, char *a5); + void Process(); + void InitPools(); DWORD GetTime();