1
0
mirror of https://github.com/jummy0/sb2-decomp synced 2025-03-15 04:24:48 +01:00

Network stuff

This commit is contained in:
HMVocaloid 2024-07-02 15:32:32 -04:00
parent db9896ff51
commit 8f92a62b0f
7 changed files with 93 additions and 12 deletions

Binary file not shown.

Binary file not shown.

View File

@ -36,6 +36,41 @@ CNetwork::~CNetwork()
return;
}
BOOL CNetwork::EnumerateCallback(LPGUID lpguidSP, LPSTR lpSTName, DWORD dwMajorVersion, DWORD dwMinorVersion, LPVOID lpContext)
{
HWND hWnd = lpContext;
LPGUID lpGuid;
if (lpContext->nbSessions < 100)
{
}
}
BOOL CNetwork::AllocateSessionList2()
{
NetSessionList* sessionDesc;
HRESULT hr;
FreeSessionList2();
m_pContext = NULL;
sessionDesc = (NetSessionList*)malloc(sizeof(11600));
if (sessionDesc == NULL)
{
return FALSE;
}
hr = DirectPlayEnumerateA(EnumerateCallback, m_pContext);
if (hr != DP_OK)
{
FreeSessionList2;
return FALSE;
}
return TRUE;
}
BOOL CNetwork::IsSessionFree()
{
DPSESSIONDESC sessionDesc;
@ -44,6 +79,42 @@ BOOL CNetwork::IsSessionFree()
m_pUnk4 = 0;
}
int CNetwork::GetSessionSomethingFromIndex(int index)
{
if (m_pContext <= index)
{
return 0;
}
return m_pSessionsDesc->sessions[index].guidSession.Data4 + 4;
}
BOOL CNetwork::CreateDirectPlayInterface(LPGUID lpguidServiceProvider, LPDIRECTPLAY2A* lplpDirectPlay2A)
{
HRESULT hr;
LPDIRECTPLAY lpDirectPlay1 = NULL;
LPDIRECTPLAY2A lpDirectPlay2A = NULL;
if (m_pContext <= index)
{
return TRUE;
}
hr = DirectPlayCreate(lpguidServiceProvider, &lpDirectPlay1, NULL);
if (hr == DP_OK)
{
return TRUE;
}
hr = lpDirectPlay1->QueryInterface(IID IDirectPlay2A, (LPVOID*)&lpDirectPlay2A);
if (hr == DP_OK)
{
return TRUE;
}
if (lpDirectPlay1 != NULL)
{
lpDirectPlay1->Release();
}
return FALSE;
}
void CNetwork::FreeCurrentSession()
{
if (m_pCurrentSession != FALSE)
@ -65,6 +136,11 @@ void CNetwork::FreeSessionList()
m_pSessions = NULL;
}
LPVOID CNetwork::GetContext()
{
return m_pContext;
}
void TraceErrorDP(HRESULT hErr, char *sFile, int nLine)
{
char dperr[256];

View File

@ -1,6 +1,6 @@
#include "dplay.h"
typedef struct
typedef struct NetSessionList
{
int nbSessions;
DPSESSIONDESC sessions[100];
@ -46,21 +46,26 @@ public:
BOOL Create();
BOOL IsSessionFree();
LPVOID GetContext();
BOOL AllocateSessionList2();
void FreeCurrentSession();
void FreeSessionList();
void FreeSessionList2();
void FreeField18();
BOOL EnumerateCallback(LPGUID lpguidSP, LPSTR lpSTName, DWORD dwMajorVersion, DWORD dwMinorVersion, NetSessionList* lpContext);
BOOL EnumerateCallback(LPGUID lpguidSP, LPSTR lpSTName, DWORD dwMajorVersion, DWORD dwMinorVersion, LPVOID lpContext);
int GetSessionSomethingFromIndex(int index);
BOOL CreateDirectPlayInterface(LPGUID lpguidServiceProvider, LPDIRECTPLAY2A* lplpDirectPlay2A);
protected:
IDirectPlay m_pDP;
LPVOID m_pContext;
LPVOID m_pUnk4;
DPSESSIONDESC m_pCurrentSession;
LPVOID m_pUnkC;
addr m_pUnk18;
NetSessionList m_pSessions;
BOOL m_pUnk1C;
DPID m_pDPID;
NetPlayer m_players[4];
IDirectPlay2 m_pDP;
DPID m_pDPID;
LPVOID m_pContext;
LPVOID m_pUnk4;
NetSessionList m_pSessionsDesc;
DPSESSIONDESC m_pCurrentSession;
LPVOID m_pUnkC;
addr m_pUnk18;
NetSessionList m_pSessions;
BOOL m_pUnk1C;
NetPlayer m_players[4];
};