-- v2: dplayx: Set player data in DP_CreatePlayer(). dplayx: Add player to the system group in DP_CreatePlayer(). dplayx: Don't enumerate system players. dplayx/tests: Test that players from SUPERENUMPLAYERSREPLY are added to the session.
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/tests/dplayx.c | 53 ++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 105de7f9618..44ae628a699 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -1950,8 +1950,8 @@ static BOOL CALLBACK EnumSessions_cb2( LPCDPSESSIONDESC2 lpThisSD, return TRUE; }
-#define check_Open( dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr ) check_Open_( __LINE__, dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr ) -static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, const DPSESSIONDESC2 *serverDpsd, BOOL requestExpected, unsigned short port, const WCHAR *expectedPassword, HRESULT expectedHr ) +#define check_Open( dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr, hrTodo, requestTodo ) check_Open_( __LINE__, dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr, hrTodo, requestTodo ) +static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, const DPSESSIONDESC2 *serverDpsd, BOOL requestExpected, unsigned short port, const WCHAR *expectedPassword, HRESULT expectedHr, BOOL hrTodo, BOOL requestTodo ) { SOCKET listenSock; OpenParam *param; @@ -1973,7 +1973,17 @@ static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, cons unsigned short port;
recvSock = acceptTcp_( line, listenSock ); - ok_( __FILE__, line )( recvSock != INVALID_SOCKET, "accept() returned %#Ix.\n", recvSock ); + todo_wine_if( requestTodo ) ok_( __FILE__, line )( recvSock != INVALID_SOCKET, "accept() returned %#Ix.\n", + recvSock ); + if ( recvSock == INVALID_SOCKET ) + { + hr = openAsyncWait( param, 2000 ); + todo_wine_if( hrTodo ) ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); + + closesocket( listenSock ); + WSACleanup(); + return; + }
port = receiveRequestPlayerId_( line, recvSock, 0x9 );
@@ -1988,7 +1998,7 @@ static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, cons checkNoMoreMessages_( line, recvSock );
hr = openAsyncWait( param, 2000 ); - ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); + todo_wine_if( hrTodo ) ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr );
hr = IDirectPlayX_Close( dp ); checkHR( DP_OK, hr ); @@ -1999,7 +2009,7 @@ static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, cons else { hr = openAsyncWait( param, 2000 ); - ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); + todo_wine_if( hrTodo ) ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); }
checkNoMoreAccepts_( line, listenSock ); @@ -2056,6 +2066,7 @@ static void test_Open(void) .dwReserved1 = 0xaabbccdd, }; EnumSessionsParam *enumSessionsParam; + DPSESSIONDESC2 replyDpsd; DPSESSIONDESC2 dpsd; unsigned short port; IDirectPlay4 *dp; @@ -2069,9 +2080,9 @@ static void test_Open(void)
dpsd = dpsdZero; dpsd.dwSize = 0; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE );
- check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_UNINITIALIZED ); + check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_UNINITIALIZED, FALSE, FALSE );
init_TCPIP_provider( dp, "127.0.0.1", 0 );
@@ -2079,19 +2090,19 @@ static void test_Open(void) /* - Checking how strict dplay is with sizes */ dpsd = dpsdZero; dpsd.dwSize = 0; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE );
dpsd = dpsdZero; dpsd.dwSize = sizeof( DPSESSIONDESC2 ) - 1; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE );
dpsd = dpsdZero; dpsd.dwSize = sizeof( DPSESSIONDESC2 ) + 1; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE );
- check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS ); + check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS, FALSE, FALSE );
- check_Open( dp, &dpsdAppGuid, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS ); + check_Open( dp, &dpsdAppGuid, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS, FALSE, FALSE );
enumSock = bindUdp( 47624 );
@@ -2108,20 +2119,30 @@ static void test_Open(void)
sendEnumSessionsReply( sock, 2349, &normalDpsd );
+ replyDpsd = normalDpsd; + replyDpsd.guidInstance = appGuid2; + sendEnumSessionsReply( sock, 2348, &replyDpsd ); + hr = enumSessionsAsyncWait( enumSessionsParam, 2000 ); checkHR( DP_OK, hr );
closesocket( sock );
- if ( tryIndex < 19 && count < 1 ) + if ( tryIndex < 19 && count < 2 ) continue;
- ok( count == 1, "got session count %d.\n", count ); + ok( count == 2, "got session count %d.\n", count );
break; }
- check_Open( dp, &dpsdAppGuid, &normalDpsd, TRUE, 2349, L"", DP_OK ); + check_Open( dp, &dpsdAppGuid, &normalDpsd, TRUE, 2349, L"", DP_OK, FALSE, FALSE ); + + dpsd = dpsdAppGuid; + dpsd.guidInstance = appGuid2; + replyDpsd = normalDpsd; + replyDpsd.guidInstance = appGuid2; + check_Open( dp, &dpsd, &replyDpsd, TRUE, 2348, L"", DP_OK, TRUE, TRUE );
/* Join to protected session */ for ( tryIndex = 0; ; ++tryIndex ) @@ -2152,7 +2173,7 @@ static void test_Open(void)
dpsd = dpsdAppGuid; dpsd.lpszPasswordA = (char *) "hadouken"; - check_Open( dp, &dpsd, &protectedDpsd, TRUE, 2349, L"hadouken", DP_OK ); + check_Open( dp, &dpsd, &protectedDpsd, TRUE, 2349, L"hadouken", DP_OK, FALSE, FALSE );
closesocket( enumSock );
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 11 ++++++++--- dlls/dplayx/tests/dplayx.c | 40 ++++++++++++++------------------------ 2 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index cecc4d62657..ccc8af14a09 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3336,9 +3336,14 @@ static HRESULT DP_SecureOpen( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpsd,
LeaveCriticalSection( &This->lock );
- sessionDesc = NS_WalkSessions( This->dp2->lpNameServerData, &spMessageHeader ); - if ( !sessionDesc ) - return DPERR_NOSESSIONS; + for ( ;; ) + { + sessionDesc = NS_WalkSessions( This->dp2->lpNameServerData, &spMessageHeader ); + if ( !sessionDesc ) + return DPERR_NOSESSIONS; + if ( IsEqualGUID( &sessionDesc->guidInstance, &lpsd->guidInstance ) ) + break; + }
This->dp2->lpSessionDesc = DP_DuplicateSessionDesc( sessionDesc, bAnsi, bAnsi ); if ( !This->dp2->lpSessionDesc ) diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 44ae628a699..179c7bd49e4 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -1950,8 +1950,8 @@ static BOOL CALLBACK EnumSessions_cb2( LPCDPSESSIONDESC2 lpThisSD, return TRUE; }
-#define check_Open( dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr, hrTodo, requestTodo ) check_Open_( __LINE__, dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr, hrTodo, requestTodo ) -static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, const DPSESSIONDESC2 *serverDpsd, BOOL requestExpected, unsigned short port, const WCHAR *expectedPassword, HRESULT expectedHr, BOOL hrTodo, BOOL requestTodo ) +#define check_Open( dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr ) check_Open_( __LINE__, dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr ) +static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, const DPSESSIONDESC2 *serverDpsd, BOOL requestExpected, unsigned short port, const WCHAR *expectedPassword, HRESULT expectedHr ) { SOCKET listenSock; OpenParam *param; @@ -1973,17 +1973,7 @@ static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, cons unsigned short port;
recvSock = acceptTcp_( line, listenSock ); - todo_wine_if( requestTodo ) ok_( __FILE__, line )( recvSock != INVALID_SOCKET, "accept() returned %#Ix.\n", - recvSock ); - if ( recvSock == INVALID_SOCKET ) - { - hr = openAsyncWait( param, 2000 ); - todo_wine_if( hrTodo ) ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); - - closesocket( listenSock ); - WSACleanup(); - return; - } + ok_( __FILE__, line )( recvSock != INVALID_SOCKET, "accept() returned %#Ix.\n", recvSock );
port = receiveRequestPlayerId_( line, recvSock, 0x9 );
@@ -1998,7 +1988,7 @@ static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, cons checkNoMoreMessages_( line, recvSock );
hr = openAsyncWait( param, 2000 ); - todo_wine_if( hrTodo ) ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); + ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr );
hr = IDirectPlayX_Close( dp ); checkHR( DP_OK, hr ); @@ -2009,7 +1999,7 @@ static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, cons else { hr = openAsyncWait( param, 2000 ); - todo_wine_if( hrTodo ) ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); + ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr ); }
checkNoMoreAccepts_( line, listenSock ); @@ -2080,9 +2070,9 @@ static void test_Open(void)
dpsd = dpsdZero; dpsd.dwSize = 0; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS );
- check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_UNINITIALIZED, FALSE, FALSE ); + check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_UNINITIALIZED );
init_TCPIP_provider( dp, "127.0.0.1", 0 );
@@ -2090,19 +2080,19 @@ static void test_Open(void) /* - Checking how strict dplay is with sizes */ dpsd = dpsdZero; dpsd.dwSize = 0; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS );
dpsd = dpsdZero; dpsd.dwSize = sizeof( DPSESSIONDESC2 ) - 1; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS );
dpsd = dpsdZero; dpsd.dwSize = sizeof( DPSESSIONDESC2 ) + 1; - check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS, FALSE, FALSE ); + check_Open( dp, &dpsd, NULL, FALSE, 2349, NULL, DPERR_INVALIDPARAMS );
- check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS, FALSE, FALSE ); + check_Open( dp, &dpsdZero, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS );
- check_Open( dp, &dpsdAppGuid, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS, FALSE, FALSE ); + check_Open( dp, &dpsdAppGuid, NULL, FALSE, 2349, NULL, DPERR_NOSESSIONS );
enumSock = bindUdp( 47624 );
@@ -2136,13 +2126,13 @@ static void test_Open(void) break; }
- check_Open( dp, &dpsdAppGuid, &normalDpsd, TRUE, 2349, L"", DP_OK, FALSE, FALSE ); + check_Open( dp, &dpsdAppGuid, &normalDpsd, TRUE, 2349, L"", DP_OK );
dpsd = dpsdAppGuid; dpsd.guidInstance = appGuid2; replyDpsd = normalDpsd; replyDpsd.guidInstance = appGuid2; - check_Open( dp, &dpsd, &replyDpsd, TRUE, 2348, L"", DP_OK, TRUE, TRUE ); + check_Open( dp, &dpsd, &replyDpsd, TRUE, 2348, L"", DP_OK );
/* Join to protected session */ for ( tryIndex = 0; ; ++tryIndex ) @@ -2173,7 +2163,7 @@ static void test_Open(void)
dpsd = dpsdAppGuid; dpsd.lpszPasswordA = (char *) "hadouken"; - check_Open( dp, &dpsd, &protectedDpsd, TRUE, 2349, L"hadouken", DP_OK, FALSE, FALSE ); + check_Open( dp, &dpsd, &protectedDpsd, TRUE, 2349, L"hadouken", DP_OK );
closesocket( enumSock );
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/tests/dplayx.c | 247 ++++++++++++++++++++++++++++++------- 1 file changed, 202 insertions(+), 45 deletions(-)
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 179c7bd49e4..8ce47e66532 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -810,8 +810,6 @@ typedef struct DPID id; DWORD infoMask; DWORD versionOrSystemPlayerId; - BYTE spDataLength; - SpData spData; } SuperPackedPlayer;
typedef struct @@ -1285,13 +1283,27 @@ static unsigned short receiveAddForwardRequest_( int line, SOCKET sock, DPID exp static void sendSuperEnumPlayersReply_( int line, SOCKET sock, unsigned short tcpPort, unsigned short udpPort, const DPSESSIONDESC2 *dpsd, const WCHAR *sessionName ) { +#define SHORT_NAME L"short name" +#define LONG_NAME L"long name" struct { SpHeader spHeader; SuperEnumPlayersReply reply; DPSESSIONDESC2 dpsd; WCHAR sessionName[ 256 ]; - SuperPackedPlayer superPackedPlayer[ 3 ]; + SuperPackedPlayer superPackedPlayer0; + BYTE spDataLength0; + SpData spData0; + SuperPackedPlayer superPackedPlayer1; + BYTE spDataLength1; + SpData spData1; + SuperPackedPlayer superPackedPlayer2; + WCHAR shortName[ ARRAYSIZE( SHORT_NAME ) ]; + WCHAR longName[ ARRAYSIZE( LONG_NAME ) ]; + BYTE playerDataLength2; + BYTE playerData[ 4 ]; + BYTE spDataLength2; + SpData spData2; } reply = { .spHeader = @@ -1311,7 +1323,7 @@ static void sendSuperEnumPlayersReply_( int line, SOCKET sock, unsigned short tc .command = 41, .version = 14, }, - .playerCount = 2, + .playerCount = 3, .groupCount = 0, .packedOffset = sizeof( reply.reply ) + sizeof( reply.dpsd ) + sizeof( reply.sessionName ), .shortcutCount = 0, @@ -1320,54 +1332,79 @@ static void sendSuperEnumPlayersReply_( int line, SOCKET sock, unsigned short tc .passwordOffset = 0, }, .dpsd = *dpsd, - .superPackedPlayer = + .superPackedPlayer0 = + { + .size = 16, + .flags = 0x5, + .id = 0x12345678, + .infoMask = 0x4, + .versionOrSystemPlayerId = 14, + }, + .spDataLength0 = sizeof( SpData ), + .spData0 = { - [ 0 ] = + .tcpAddr = { - .size = 16, - .flags = 0x5, - .id = 0x12345678, - .infoMask = 0x4, - .versionOrSystemPlayerId = 14, - .spDataLength = sizeof( reply.superPackedPlayer[ 0 ].spData ), - .spData = - { - .tcpAddr = - { - .sin_family = AF_INET, - .sin_port = htons( tcpPort ), - }, - .udpAddr = - { - .sin_family = AF_INET, - .sin_port = htons( udpPort ), - }, - }, + .sin_family = AF_INET, + .sin_port = htons( tcpPort ), }, - [ 1 ] = + .udpAddr = { - .size = 16, - .flags = 0xf, - .id = 0x51573, - .infoMask = 0x4, - .versionOrSystemPlayerId = 14, - .spDataLength = sizeof( reply.superPackedPlayer[ 1 ].spData ), - .spData = - { - .tcpAddr = - { - .sin_family = AF_INET, - .sin_port = htons( tcpPort ), - }, - .udpAddr = - { - .sin_family = AF_INET, - .sin_port = htons( udpPort ), - }, - }, + .sin_family = AF_INET, + .sin_port = htons( udpPort ), + }, + }, + .superPackedPlayer1 = + { + .size = 16, + .flags = 0xf, + .id = 0x51573, + .infoMask = 0x4, + .versionOrSystemPlayerId = 14, + }, + .spDataLength1 = sizeof( SpData ), + .spData1 = + { + .tcpAddr = + { + .sin_family = AF_INET, + .sin_port = htons( tcpPort ), + }, + .udpAddr = + { + .sin_family = AF_INET, + .sin_port = htons( udpPort ), + }, + }, + .superPackedPlayer2 = + { + .size = 16, + .flags = 0x8, + .id = 0x1337, + .infoMask = 0x17, + .versionOrSystemPlayerId = 14, + }, + .shortName = SHORT_NAME, + .longName = LONG_NAME, + .playerDataLength2 = 4, + .playerData = { 1, 2, 3, 4, }, + .spDataLength2 = sizeof( SpData ), + .spData2 = + { + .tcpAddr = + { + .sin_family = AF_INET, + .sin_port = htons( tcpPort ), + }, + .udpAddr = + { + .sin_family = AF_INET, + .sin_port = htons( udpPort ), }, }, }; +#undef LONG_NAME +#undef SHORT_NAME int wsResult;
reply.dpsd.lpszSessionName = NULL; @@ -1950,6 +1987,108 @@ static BOOL CALLBACK EnumSessions_cb2( LPCDPSESSIONDESC2 lpThisSD, return TRUE; }
+typedef struct +{ + DPID expectedDpid; + DWORD expectedPlayerType; + const char *expectedShortName; + const char *expectedLongName; + DWORD expectedFlags; + BYTE *expectedPlayerData; + DWORD expectedPlayerDataSize; + int actualCount; +} ExpectedPlayer; + +typedef struct +{ + int line; + IDirectPlay4 *dp; + ExpectedPlayer *expectedPlayers; + int expectedPlayerCount; + int actualPlayerCount; +} CheckPlayerListCallbackData; + +static BOOL CALLBACK checkPlayerListCallback( DPID dpid, DWORD playerType, const DPNAME *name, DWORD flags, + void *context ) +{ + CheckPlayerListCallbackData *data = context; + int i; + + for ( i = 0; i < data->expectedPlayerCount; ++i ) + { + ExpectedPlayer *player = &data->expectedPlayers[ i ]; + if ( player->expectedDpid == dpid ) + { + BYTE playerData[ 256 ]; + DWORD playerDataSize; + HRESULT hr; + + if ( player->actualCount ) + ok_( __FILE__, data->line )( 0, "duplicate player dpid %#lx.\n", dpid ); + ok_( __FILE__, data->line )( playerType == player->expectedPlayerType, "got player type %lu.\n", + playerType ); + if ( player->expectedShortName ) + { + ok_( __FILE__, data->line )( name->lpszShortNameA && !strcmp( name->lpszShortNameA, player->expectedShortName ), + "got short name %s.\n", wine_dbgstr_a( name->lpszShortNameA ) ); + } + else + { + ok_( __FILE__, data->line )( !name->lpszShortNameA, "got short name %s.\n", + wine_dbgstr_a( name->lpszShortNameA ) ); + } + if ( player->expectedLongName ) + { + ok_( __FILE__, data->line )( name->lpszLongNameA && !strcmp( name->lpszLongNameA, player->expectedLongName ), + "got long name %s.\n", wine_dbgstr_a( name->lpszLongNameA ) ); + } + else + { + ok_( __FILE__, data->line )( !name->lpszLongNameA, "got long name %s.\n", + wine_dbgstr_a( name->lpszLongNameA ) ); + } + ok_( __FILE__, data->line )( flags == player->expectedFlags, "got flags %#lx.\n", flags ); + + memset( &playerData, 0xcc, sizeof( playerData ) ); + playerDataSize = sizeof( playerData ); + hr = IDirectPlayX_GetPlayerData( data->dp, dpid, playerData, &playerDataSize, DPGET_REMOTE ); + ok_( __FILE__, data->line )( hr == DP_OK, "GetPlayerData() returned %#lx.\n", hr ); + ok_( __FILE__, data->line )( playerDataSize == player->expectedPlayerDataSize, + "got player data size %lu.\n", playerDataSize ); + ok_( __FILE__, data->line )( !memcmp( playerData, player->expectedPlayerData, player->expectedPlayerDataSize ), + "player data doesn't match.\n" ); + + ++player->actualCount; + ++data->actualPlayerCount; + + return TRUE; + } + } + + todo_wine ok_( __FILE__, data->line )( 0, "unexpected player dpid %#lx.\n", dpid ); + + ++data->actualPlayerCount; + + return TRUE; +} + +#define checkPlayerList( dp, expectedPlayers, expectedPlayerCount ) checkPlayerList_( __LINE__, dp, expectedPlayers, expectedPlayerCount ) +static void checkPlayerList_( int line, IDirectPlay4 *dp, ExpectedPlayer *expectedPlayers, int expectedPlayerCount ) +{ + CheckPlayerListCallbackData data = { + .line = line, + .dp = dp, + .expectedPlayers = expectedPlayers, + .expectedPlayerCount = expectedPlayerCount, + }; + HRESULT hr; + + hr = IDirectPlayX_EnumPlayers( dp, NULL, checkPlayerListCallback, &data, 0 ); + ok_( __FILE__, line )( hr == DP_OK, "EnumPlayers() returned %#lx.\n", hr ); + ok_( __FILE__, line )( data.actualPlayerCount == data.expectedPlayerCount, "got player count %d.\n", + data.actualPlayerCount ); +} + #define check_Open( dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr ) check_Open_( __LINE__, dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr ) static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, const DPSESSIONDESC2 *serverDpsd, BOOL requestExpected, unsigned short port, const WCHAR *expectedPassword, HRESULT expectedHr ) { @@ -1990,6 +2129,24 @@ static void check_Open_( int line, IDirectPlay4A *dp, DPSESSIONDESC2 *dpsd, cons hr = openAsyncWait( param, 2000 ); ok_( __FILE__, line )( hr == expectedHr, "Open() returned %#lx.\n", hr );
+ if ( expectedHr == DP_OK ) + { + BYTE expectedPlayerData[] = { 1, 2, 3, 4, }; + ExpectedPlayer expectedPlayers[] = { + { + .expectedDpid = 0x1337, + .expectedPlayerType = DPPLAYERTYPE_PLAYER, + .expectedShortName = "short name", + .expectedLongName = "long name", + .expectedFlags = 0, + .expectedPlayerData = expectedPlayerData, + .expectedPlayerDataSize = sizeof( expectedPlayerData ), + }, + }; + + checkPlayerList_( line, dp, expectedPlayers, ARRAYSIZE( expectedPlayers ) ); + } + hr = IDirectPlayX_Close( dp ); checkHR( DP_OK, hr );
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 3 +-- dlls/dplayx/tests/dplayx.c | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index ccc8af14a09..9852e493548 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -2220,8 +2220,7 @@ static HRESULT WINAPI IDirectPlay4Impl_EnumGroupPlayers( IDirectPlay4 *iface, DP /* We do not enum the name server or app server as they are of no * consequence to the end user. */ - if ( ( plist->lpPData->dpid != DPID_NAME_SERVER ) && - ( plist->lpPData->dpid != DPID_SERVERPLAYER ) ) + if ( !(plist->lpPData->dwFlags & DPLAYI_PLAYER_SYSPLAYER) ) { /* FIXME: Need to add stuff for flags checking */ if ( !enumplayercb( plist->lpPData->dpid, DPPLAYERTYPE_PLAYER, diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 8ce47e66532..1c2b9bcbd19 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -2065,7 +2065,7 @@ static BOOL CALLBACK checkPlayerListCallback( DPID dpid, DWORD playerType, const } }
- todo_wine ok_( __FILE__, data->line )( 0, "unexpected player dpid %#lx.\n", dpid ); + ok_( __FILE__, data->line )( 0, "unexpected player dpid %#lx.\n", dpid );
++data->actualPlayerCount;
@@ -2085,8 +2085,8 @@ static void checkPlayerList_( int line, IDirectPlay4 *dp, ExpectedPlayer *expect
hr = IDirectPlayX_EnumPlayers( dp, NULL, checkPlayerListCallback, &data, 0 ); ok_( __FILE__, line )( hr == DP_OK, "EnumPlayers() returned %#lx.\n", hr ); - ok_( __FILE__, line )( data.actualPlayerCount == data.expectedPlayerCount, "got player count %d.\n", - data.actualPlayerCount ); + todo_wine ok_( __FILE__, line )( data.actualPlayerCount == data.expectedPlayerCount, "got player count %d.\n", + data.actualPlayerCount ); }
#define check_Open( dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr ) check_Open_( __LINE__, dp, dpsd, serverDpsd, requestExpected, port, expectedPassword, expectedHr )
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 9852e493548..fbc42e9965e 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -1356,11 +1356,11 @@ DP_SetGroupData( lpGroupData lpGData, DWORD dwFlags,
}
-/* This function will just create the storage for the new player. */ static lpPlayerData DP_CreatePlayer( IDirectPlayImpl *This, DPID *lpid, DPNAME *lpName, DWORD dwFlags, HANDLE hEvent, BOOL bAnsi ) { lpPlayerData lpPData; + lpPlayerList lpPList;
TRACE( "(%p)->(%p,%p,%u)\n", This, lpid, lpName, bAnsi );
@@ -1394,6 +1394,23 @@ static lpPlayerData DP_CreatePlayer( IDirectPlayImpl *This, DPID *lpid, DPNAME * /* Initialize the SP data section */ lpPData->lpSPPlayerData = DPSP_CreateSPPlayerData();
+ /* Create the list object and link it in */ + lpPList = calloc( 1, sizeof( *lpPList ) ); + if( !lpPList ) + { + free( lpPData->lpSPPlayerData ); + CloseHandle( lpPData->hEvent ); + DP_DeleteDPNameStruct( &lpPData->name ); + free( lpPData ); + return NULL; + } + + lpPData->uRef = 1; + lpPList->lpPData = lpPData; + + /* Add the player to the system group */ + DPQ_INSERT( This->dp2->lpSysGroup->players, lpPList, players ); + TRACE( "Created player id 0x%08lx\n", *lpid );
if( ~dwFlags & DPLAYI_PLAYER_SYSPLAYER ) @@ -1542,7 +1559,6 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, void *lpMsgHdr, DPID * { HRESULT hr = DP_OK; lpPlayerData lpPData; - lpPlayerList lpPList; DWORD dwCreateFlags = 0;
TRACE( "(%p)->(%p,%p,%p,%p,0x%08lx,0x%08lx,%u)\n", @@ -1632,20 +1648,8 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, void *lpMsgHdr, DPID * player total */ lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwCreateFlags, hEvent, bAnsi ); - /* Create the list object and link it in */ - lpPList = calloc( 1, sizeof( *lpPList ) ); - if( !lpPData || !lpPList ) - { - free( lpPData ); - free( lpPList ); + if( !lpPData ) return DPERR_CANTADDPLAYER; - } - - lpPData->uRef = 1; - lpPList->lpPData = lpPData; - - /* Add the player to the system group */ - DPQ_INSERT( This->dp2->lpSysGroup->players, lpPList, players );
/* Update the information and send it to all players in the session */ DP_SetPlayerData( lpPData, DPSET_REMOTE, lpData, dwDataSize );
v2: - Don't crash if name strings are null in `checkPlayerListCallback()`.
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index fbc42e9965e..49b80f4d4b8 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -61,6 +61,8 @@ static lpGroupData DP_FindAnyGroup( IDirectPlayImpl *This, DPID dpid ); /* Helper methods for player/group interfaces */ static HRESULT DP_SetSessionDesc( IDirectPlayImpl *This, const DPSESSIONDESC2 *lpSessDesc, DWORD dwFlags, BOOL bInitial, BOOL bAnsi ); +static void DP_SetPlayerData( lpPlayerData lpPData, DWORD dwFlags, + LPVOID lpData, DWORD dwDataSize ); static HRESULT DP_SP_SendEx( IDirectPlayImpl *This, DWORD dwFlags, void *lpData, DWORD dwDataSize, DWORD dwPriority, DWORD dwTimeout, void *lpContext, DWORD *lpdwMsgID ); static BOOL DP_BuildSPCompoundAddr( LPGUID lpcSpGuid, LPVOID* lplpAddrBuf, @@ -1357,7 +1359,7 @@ DP_SetGroupData( lpGroupData lpGData, DWORD dwFlags, }
static lpPlayerData DP_CreatePlayer( IDirectPlayImpl *This, DPID *lpid, DPNAME *lpName, - DWORD dwFlags, HANDLE hEvent, BOOL bAnsi ) + void *data, DWORD dataSize, DWORD dwFlags, HANDLE hEvent, BOOL bAnsi ) { lpPlayerData lpPData; lpPlayerList lpPList; @@ -1411,6 +1413,8 @@ static lpPlayerData DP_CreatePlayer( IDirectPlayImpl *This, DPID *lpid, DPNAME * /* Add the player to the system group */ DPQ_INSERT( This->dp2->lpSysGroup->players, lpPList, players );
+ DP_SetPlayerData( lpPData, DPSET_REMOTE, data, dataSize ); + TRACE( "Created player id 0x%08lx\n", *lpid );
if( ~dwFlags & DPLAYI_PLAYER_SYSPLAYER ) @@ -1646,14 +1650,11 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, void *lpMsgHdr, DPID *
/* We pass creation flags, so we can distinguish sysplayers and not count them in the current player total */ - lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, dwCreateFlags, + lpPData = DP_CreatePlayer( This, lpidPlayer, lpPlayerName, lpData, dwDataSize, dwCreateFlags, hEvent, bAnsi ); if( !lpPData ) return DPERR_CANTADDPLAYER;
- /* Update the information and send it to all players in the session */ - DP_SetPlayerData( lpPData, DPSET_REMOTE, lpData, dwDataSize ); - /* Let the SP know that we've created this player */ if( This->dp2->spData.lpCB->CreatePlayer ) {
Hi,
It looks like your patch introduced the new failures shown below. Please investigate and fix them before resubmitting your patch. If they are not new, fixing them anyway would help a lot. Otherwise please ask for the known failures list to be updated.
The tests also ran into some preexisting test failures. If you know how to fix them that would be helpful. See the TestBot job for the details:
The full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=148753
Your paranoid android.
=== w7u_el (32 bit report) ===
dplayx: dplayx.c:2900: Test failed: select() returned 1. dplayx.c:2903: Test failed: select() returned 1. dplayx.c:2906: Test failed: select() returned 1. dplayx.c:2907: Test failed: select() returned 1. dplayx.c:2302: Test failed: got flags 0.
=== w10pro64 (32 bit report) ===
dplayx: dplayx.c:2302: Test failed: got flags 0.
=== debian11b (64 bit WoW report) ===
d3d9: d3d9ex.c:3230: Test failed: Expected message 0x18 for window 0, but didn't receive it, i=0.
This merge request was approved by Alistair Leslie-Hughes.