HRESULT bld_enum_sessions(LPDIRECTPLAY4A dp_interface) { HRESULT hr; DPSESSIONDESC2 session_desc; if (dp_interface == NULL) return DPERR_INVALIDOBJECT; gbl_num_sessions = 0; ZeroMemory(&session_desc, sizeof(DPSESSIONDESC2)); session_desc.dwSize = sizeof(DPSESSIONDESC2); session_desc.guidApplication = AppGUID; hr = dp_interface->EnumSessions( &session_desc, 0, bld_enum_sessions_cb, NULL, DPENUMSESSIONS_AVAILABLE ); return hr; }
//----------------------------------------------------------------------------- // Name: // Desc: //----------------------------------------------------------------------------- BOOL Network_GetSessionsStats(NM_SESSIONS_STATS* pStats) { if (pStats == NULL) return FALSE; DPSESSIONDESC2 dpsd; HRESULT hRet; memset(&dpsd, 0, sizeof(dpsd)); dpsd.dwSize = sizeof(dpsd); dpsd.guidApplication = PXAPP_GUID; pStats->iRealSize = 0; hRet = g_pDPlay->EnumSessions(&dpsd, 0, DPConnect_EnumStatsCallback, pStats, DPENUMSESSIONS_ALL); if (FAILED(hRet)) return FALSE; return TRUE; }
//----------------------------------------------------------------------------- // Name: // Desc: //----------------------------------------------------------------------------- BOOL Network_ConnectToSession(const char* pszSessionName, const char* pcszServerIP) { DPSESSIONDESC2 dpsd; HRESULT hRet; BOOL bCon = FALSE; if (!nm_InitConnection(pcszServerIP)) return FALSE; g_cDesc.bIsServer = FALSE; strcpy(g_cDesc.szSessionName, pszSessionName); memset(&dpsd, 0, sizeof(dpsd)); dpsd.dwSize = sizeof(dpsd); dpsd.guidApplication = PXAPP_GUID; hRet = g_pDPlay->EnumSessions(&dpsd, 0, DPConnect_EnumSessionsCallback, &bCon, DPENUMSESSIONS_ALL); if (FAILED(hRet)) return FALSE; return bCon; }