diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 75a5261..fb9f312 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -2380,6 +2380,11 @@ static HRESULT WINAPI DP_IF_GetPlayerCaps TRACE("(%p)->(0x%08x,%p,0x%08x)\n", This, idPlayer, lpDPCaps, dwFlags); + if ( This->dp2->connectionInitialized == NO_PROVIDER ) + { + return DPERR_UNINITIALIZED; + } + /* Query the service provider */ data.idPlayer = idPlayer; data.dwFlags = dwFlags; diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 9774624..d385ba6 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -518,6 +518,56 @@ static LPCSTR dwFlags2str(DWORD dwFlags, DWORD flagType) return flags; } +static void init_TCPIP_provider( LPDIRECTPLAY4 pDP, + LPCSTR strIPAddressString, + WORD port ) +{ + + DPCOMPOUNDADDRESSELEMENT addressElements[3]; + VOID* pAddress = NULL; + DWORD dwAddressSize = 0; + LPDIRECTPLAYLOBBY3 pDPL; + HRESULT hr; + + CoCreateInstance( &CLSID_DirectPlayLobby, NULL, CLSCTX_ALL, + &IID_IDirectPlayLobby3A, (LPVOID*) &pDPL ); + + /* Service provider */ + addressElements[0].guidDataType = DPAID_ServiceProvider; + addressElements[0].dwDataSize = sizeof(GUID); + addressElements[0].lpData = (LPVOID) &DPSPGUID_TCPIP; + + /* IP address string */ + addressElements[1].guidDataType = DPAID_INet; + addressElements[1].dwDataSize = lstrlen(strIPAddressString) + 1; + addressElements[1].lpData = (LPVOID) strIPAddressString; + + /* Optional Port number */ + if( port > 0 ) + { + addressElements[2].guidDataType = DPAID_INetPort; + addressElements[2].dwDataSize = sizeof(WORD); + addressElements[2].lpData = &port; + } + + + hr = IDirectPlayLobby_CreateCompoundAddress( pDPL, addressElements, 2, + NULL, &dwAddressSize ); + _okHR( DPERR_BUFFERTOOSMALL, hr ); + + if( hr == DPERR_BUFFERTOOSMALL ) + { + pAddress = GlobalAllocPtr( GHND, dwAddressSize ); + hr = IDirectPlayLobby_CreateCompoundAddress( pDPL, addressElements, 2, + pAddress, &dwAddressSize ); + _okHR( DP_OK, hr ); + } + + hr = IDirectPlayX_InitializeConnection( pDP, pAddress, 0 ); + todo_wine _okHR( DP_OK, hr ); + +} + /* DirectPlayCreate */ @@ -749,6 +799,75 @@ static void test_InitializeConnection() } +/* GetCaps */ + +static void test_GetCaps() +{ + + LPDIRECTPLAY4 pDP; + DPCAPS dpcaps; + DWORD dwFlags; + HRESULT hr; + + + CoCreateInstance( &CLSID_DirectPlay, NULL, CLSCTX_ALL, + &IID_IDirectPlay4A, (LPVOID*) &pDP ); + ZeroMemory( &dpcaps, sizeof(DPCAPS) ); + + /* Service provider not ininitialized */ + hr = IDirectPlayX_GetCaps( pDP, &dpcaps, 0 ); + _okHR( DPERR_UNINITIALIZED, hr ); + + init_TCPIP_provider( pDP, "127.0.0.1", 0 ); + + /* dpcaps not ininitialized */ + hr = IDirectPlayX_GetCaps( pDP, &dpcaps, 0 ); + todo_wine _okHR( DPERR_INVALIDPARAMS, hr ); + + dpcaps.dwSize = sizeof(DPCAPS); + + for (dwFlags=0; + dwFlags<=DPGETCAPS_GUARANTEED; + dwFlags+=DPGETCAPS_GUARANTEED) + { + + hr = IDirectPlayX_GetCaps( pDP, &dpcaps, dwFlags ); + todo_wine _okHR( DP_OK, hr ); + + + if ( hr == DP_OK ) + { + _ok( sizeof(DPCAPS), dpcaps.dwSize ); + _ok( DPCAPS_ASYNCSUPPORTED | + DPCAPS_GUARANTEEDOPTIMIZED | + DPCAPS_GUARANTEEDSUPPORTED, + dpcaps.dwFlags ); + _ok( 0, dpcaps.dwMaxQueueSize ); + _ok( 0, dpcaps.dwHundredBaud ); + _ok( 500, dpcaps.dwLatency ); + _ok( 65536, dpcaps.dwMaxLocalPlayers ); + _ok( 20, dpcaps.dwHeaderLength ); + _ok( 5000, dpcaps.dwTimeout ); + + switch (dwFlags) + { + case 0: + _ok( 65479, dpcaps.dwMaxBufferSize ); + _ok( 65536, dpcaps.dwMaxPlayers ); + break; + case DPGETCAPS_GUARANTEED: + _ok( 1048547, dpcaps.dwMaxBufferSize ); + _ok( 64, dpcaps.dwMaxPlayers ); + break; + default: break; + } + } + } + + IDirectPlayX_Release( pDP ); + +} + START_TEST(dplayx) { @@ -760,6 +879,8 @@ START_TEST(dplayx) test_EnumConnections(); test_InitializeConnection(); + test_GetCaps(); + HeapDestroy( heap ); CoUninitialize();