diff --git a/.vs/Speedy Eggbert 2 Source/v17/.suo b/.vs/Speedy Eggbert 2 Source/v17/.suo index 586ce05..7761108 100644 Binary files a/.vs/Speedy Eggbert 2 Source/v17/.suo and b/.vs/Speedy Eggbert 2 Source/v17/.suo differ diff --git a/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db b/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db index 3a73fa8..72bbd56 100644 Binary files a/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db and b/.vs/Speedy Eggbert 2 Source/v17/Browse.VC.db differ diff --git a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo index 2080c1d..7b43065 100644 Binary files a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo and b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/.wsuo differ diff --git a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db index 621ab74..647eee1 100644 Binary files a/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db and b/.vs/Speedy-Eggbert-2-Source-Code-Decomp/v17/Browse.VC.db differ diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 8237c4b..8bab807 100644 Binary files a/.vs/slnx.sqlite and b/.vs/slnx.sqlite differ diff --git a/network.cpp b/network.cpp index 37e65f8..05cb9a6 100644 --- a/network.cpp +++ b/network.cpp @@ -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]; diff --git a/network.h b/network.h index d1cb485..b1d5768 100644 --- a/network.h +++ b/network.h @@ -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]; }; \ No newline at end of file