From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 146 +++++++++++++++++++++++++++++-------- dlls/dplayx/tests/dplayx.c | 41 ++++++----- 2 files changed, 138 insertions(+), 49 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 4662bdb3192..7fbcf0192bb 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -322,6 +322,65 @@ static void *DP_DuplicateString( void *src, BOOL dstAnsi, BOOL srcAnsi ) return dst; }
+static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, struct PlayerData *player, + DPID excludeId, void *msg, DWORD msgSize ) +{ + struct DPMSG *elem; + + if ( !( player->dwFlags & DPLAYI_PLAYER_PLAYERLOCAL ) ) + return DP_OK; + if ( player->dwFlags & DPLAYI_PLAYER_SYSPLAYER ) + return DP_OK; + if ( player->dpid == excludeId ) + return DP_OK; + + elem = calloc( 1, sizeof( struct DPMSG ) ); + if( !elem ) + return DPERR_OUTOFMEMORY; + + elem->msg = malloc( msgSize ); + if ( !elem->msg ) + { + free( elem ); + return DPERR_OUTOFMEMORY; + } + memcpy( elem->msg, msg, msgSize ); + + DPQ_INSERT_IN_TAIL( This->dp2->receiveMsgs, elem, msgs ); + + if( player->hEvent ) + SetEvent( player->hEvent ); + + return DP_OK; +} + +static HRESULT DP_QueueMessage( IDirectPlayImpl *This, DPID toId, DPID excludeId, void *msg, + DWORD msgSize ) +{ + struct PlayerList *plist; + struct GroupData *group; + HRESULT hr; + + plist = DP_FindPlayer( This, toId ); + if ( plist ) + return DP_QueuePlayerMessage( This, plist->lpPData, excludeId, msg, msgSize ); + + group = DP_FindAnyGroup( This, toId ); + if( group ) + { + for( plist = DPQ_FIRST( group->players ); plist; plist = DPQ_NEXT( plist->players ) ) + { + hr = DP_QueuePlayerMessage( This, plist->lpPData, excludeId, msg, msgSize ); + if ( FAILED( hr ) ) + return hr; + } + + return DP_OK; + } + + return DPERR_INVALIDPLAYER; +} + /* *lplpReply will be non NULL iff there is something to reply */ HRESULT DP_HandleMessage( IDirectPlayImpl *This, void *messageBody, DWORD dwMessageBodySize, void *messageHeader, WORD wCommandId, WORD wVersion, @@ -1492,6 +1551,26 @@ static HRESULT DP_CreateSPPlayer( IDirectPlayImpl *This, DPID dpid, DWORD flags, return DP_OK; }
+static void DP_DeleteSPPlayer( IDirectPlayImpl *This, DPID dpid ) +{ + if ( This->dp2->spData.lpCB->RemovePlayerFromGroup ) + { + DPSP_REMOVEPLAYERFROMGROUPDATA data; + data.idPlayer = dpid; + data.idGroup = DPID_SYSTEM_GROUP; + data.lpISP = This->dp2->spData.lpISP; + This->dp2->spData.lpCB->RemovePlayerFromGroup( &data ); + } + if ( This->dp2->spData.lpCB->DeletePlayer ) + { + DPSP_DELETEPLAYERDATA data; + data.idPlayer = dpid; + data.dwFlags = 0; + data.lpISP = This->dp2->spData.lpISP; + This->dp2->spData.lpCB->DeletePlayer( &data ); + } +} + HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPNAME *lpName, void *data, DWORD dataSize, void *spData, DWORD spDataSize, DWORD dwFlags, HANDLE hEvent, struct PlayerData **playerData, BOOL bAnsi ) @@ -1592,10 +1671,44 @@ HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPN return hr; }
- TRACE( "Created player id 0x%08lx\n", *lpid ); - if( ~dwFlags & DPLAYI_PLAYER_SYSPLAYER ) + { + DPMSG_CREATEPLAYERORGROUP msg; + DWORD currentPlayers; + + currentPlayers = This->dp2->lpSessionDesc->dwCurrentPlayers; + if ( ~dwFlags & DPLAYI_PLAYER_PLAYERLOCAL ) + ++currentPlayers; + + msg.dwType = DPSYS_CREATEPLAYERORGROUP; + msg.dwPlayerType = DPPLAYERTYPE_PLAYER; + msg.dpId = *lpid; + msg.dwCurrentPlayers = currentPlayers; + msg.lpData = data; + msg.dwDataSize = dataSize; + msg.dpnName = *lpPData->name; + msg.dpIdParent = 0; + msg.dwFlags = dwFlags; + + hr = DP_QueueMessage( This, DPID_ALLPLAYERS, *lpid, &msg, sizeof( msg ) ); + if ( FAILED( hr ) ) + { + DP_DeleteSPPlayer( This, *lpid ); + free( lpPData->lpLocalData ); + free( lpPData->lpRemoteData ); + DPQ_REMOVE( This->dp2->lpSysGroup->players, lpPList, players ); + free( lpPList ); + CloseHandle( lpPData->hEvent ); + free( lpPData->nameA ); + free( lpPData->name ); + free( lpPData ); + return hr; + } + This->dp2->lpSessionDesc->dwCurrentPlayers++; + } + + TRACE( "Created player id 0x%08lx\n", *lpid );
if( playerData ) *playerData = lpPData; @@ -1827,7 +1940,6 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, DPID *lpidPlayer, return hr; }
-#if 1 hr = DP_MSG_SendCreatePlayer( This, DPID_ALLPLAYERS, *lpidPlayer, dwCreateFlags, player->name, lpData, dwDataSize, This->dp2->systemPlayerId ); if( FAILED( hr ) ) @@ -1835,34 +1947,6 @@ static HRESULT DP_IF_CreatePlayer( IDirectPlayImpl *This, DPID *lpidPlayer, LeaveCriticalSection( &This->lock ); return hr; } -#else - /* Inform all other peers of the creation of a new player. If there are - * no peers keep this quiet. - * Also, if this was a remote event, no need to rebroadcast it. - */ - if( ( lpMsgHdr == NULL ) && - This->dp2->lpSessionDesc && - ( This->dp2->lpSessionDesc->dwFlags & DPSESSION_MULTICASTSERVER ) ) - { - DPMSG_CREATEPLAYERORGROUP msg; - msg.dwType = DPSYS_CREATEPLAYERORGROUP; - - msg.dwPlayerType = DPPLAYERTYPE_PLAYER; - msg.dpId = *lpidPlayer; - msg.dwCurrentPlayers = 0; /* FIXME: Incorrect */ - msg.lpData = lpData; - msg.dwDataSize = dwDataSize; - msg.dpnName = *lpPlayerName; - msg.dpIdParent = DPID_NOPARENT_GROUP; - msg.dwFlags = DPMSG_CREATEPLAYER_DWFLAGS( dwFlags ); - - /* FIXME: Correct to just use send effectively? */ - /* FIXME: Should size include data w/ message or just message "header" */ - /* FIXME: Check return code */ - hr = IDirectPlayX_SendEx( &This->IDirectPlay4_iface, DPID_SERVERPLAYER, DPID_ALLPLAYERS, 0, - &msg, sizeof( msg ), 0, 0, NULL, NULL ); - } -#endif
LeaveCriticalSection( &This->lock );
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 27f4e2f4579..c13e136cc5a 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -4076,17 +4076,17 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD fromId = 0xdeadbeef; toId = 0xdeadbeef; hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); - todo_wine ok_( __FILE__, line )( hr == DP_OK, "got hr %#lx.\n", hr ); - if ( FAILED( hr ) ) - return toId; - ok_( __FILE__, line )( fromId == DPID_SYSMSG, "got source id %#lx.\n", fromId ); + ok_( __FILE__, line )( hr == DP_OK, "got hr %#lx.\n", hr ); + todo_wine ok_( __FILE__, line )( fromId == DPID_SYSMSG, "got source id %#lx.\n", fromId );
msg = (DPMSG_CREATEPLAYERORGROUP *) msgData; ok_( __FILE__, line )( msg->dwType == DPSYS_CREATEPLAYERORGROUP, "got message type %#lx.\n", msg->dwType ); ok_( __FILE__, line )( msg->dwPlayerType == expectedType, "got player type %#lx.\n", msg->dwPlayerType ); - ok_( __FILE__, line )( msg->dpId == expectedDpid, "got id %#lx.\n", msg->dpId ); - ok_( __FILE__, line )( msg->dwCurrentPlayers == expectedCurrentPlayers, "got current players %lu.\n", - msg->dwCurrentPlayers ); + todo_wine_if( msg->dpId != expectedDpid ) ok_( __FILE__, line )( msg->dpId == expectedDpid, "got id %#lx.\n", + msg->dpId ); + todo_wine_if( msg->dwCurrentPlayers != expectedCurrentPlayers ) + ok_( __FILE__, line )( msg->dwCurrentPlayers == expectedCurrentPlayers, "got current players %lu.\n", + msg->dwCurrentPlayers ); ok_( __FILE__, line )( msg->dwDataSize == expectedPlayerDataSize, "got player data size %lu.\n", msg->dwDataSize ); if ( expectedPlayerData ) { @@ -4101,33 +4101,38 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD ok_( __FILE__, line )( !msg->dpnName.dwFlags, "got name flags %#lx.\n", msg->dpnName.dwFlags ); if ( expectedShortName ) { - ok_( __FILE__, line )( msg->dpnName.lpszShortNameA && !strcmp( msg->dpnName.lpszShortNameA, expectedShortName ), - "got short name %s.\n", wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); + todo_wine + ok_( __FILE__, line )( msg->dpnName.lpszShortNameA && !strcmp( msg->dpnName.lpszShortNameA, expectedShortName ), + "got short name %s.\n", wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); } else { - ok_( __FILE__, line )( !msg->dpnName.lpszShortNameA, "got short name %s.\n", - wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); + todo_wine_if( msg->dpnName.lpszShortNameA) + ok_( __FILE__, line )( !msg->dpnName.lpszShortNameA, "got short name %s.\n", + wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); } if ( expectedLongName ) { - ok_( __FILE__, line )( msg->dpnName.lpszLongNameA && !strcmp( msg->dpnName.lpszLongNameA, expectedLongName ), - "got long name %s.\n", wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); + todo_wine + ok_( __FILE__, line )( msg->dpnName.lpszLongNameA && !strcmp( msg->dpnName.lpszLongNameA, expectedLongName ), + "got long name %s.\n", wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); } else { - ok_( __FILE__, line )( !msg->dpnName.lpszLongNameA, "got long name %s.\n", - wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); + todo_wine_if( msg->dpnName.lpszShortNameA) + ok_( __FILE__, line )( !msg->dpnName.lpszLongNameA, "got long name %s.\n", + wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); } ok_( __FILE__, line )( msg->dpIdParent == expectedParent, "got parent id %#lx.\n", msg->dpIdParent ); - ok_( __FILE__, line )( msg->dwFlags == expectedFlags, "got flags %#lx.\n", msg->dwFlags ); + todo_wine_if( msg->dwFlags != expectedFlags ) ok_( __FILE__, line )( msg->dwFlags == expectedFlags, + "got flags %#lx.\n", msg->dwFlags );
expectedShortNameSize = expectedShortName ? strlen( expectedShortName ) + 1 : 0; expectedLongNameSize = expectedLongName ? strlen( expectedLongName ) + 1 : 0; expectedMsgDataSize = sizeof( DPMSG_CREATEPLAYERORGROUP ) + expectedShortNameSize + expectedLongNameSize + expectedPlayerDataSize;
- ok_( __FILE__, line )( msgDataSize == expectedMsgDataSize, "got message size %lu.\n", msgDataSize ); + todo_wine ok_( __FILE__, line )( msgDataSize == expectedMsgDataSize, "got message size %lu.\n", msgDataSize );
return toId; } @@ -4247,7 +4252,7 @@ static void check_CreatePlayer_( int line, IDirectPlay4 *dp, DPID *dpid, DPNAME playerData, sizeof( playerData ), expectedShortNameA, expectedLongNameA, 0, expectedFlags );
- checkNoMorePlayerMessages_( line, dp ); + todo_wine_if( expectedCurrentPlayers >= 2 ) checkNoMorePlayerMessages_( line, dp );
closesocket( sendSock ); }
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 12 ++++++----- dlls/dplayx/tests/dplayx.c | 41 ++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 27 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 7fbcf0192bb..20611b283fd 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3740,11 +3740,6 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT if( dwFlags & DPRECEIVE_ALL ) { lpMsg = This->dp2->receiveMsgs.lpQHFirst; - - if( !( dwFlags & DPRECEIVE_PEEK ) ) - { - FIXME( "Remove from queue\n" ); - } } else if( ( dwFlags & DPRECEIVE_TOPLAYER ) || ( dwFlags & DPRECEIVE_FROMPLAYER ) @@ -3765,6 +3760,13 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT /* Copy into the provided buffer */ if (lpData) CopyMemory( lpData, lpMsg->msg, *lpdwDataSize );
+ if( !( dwFlags & DPRECEIVE_PEEK ) ) + { + DPQ_REMOVE( This->dp2->receiveMsgs, lpMsg, msgs ); + free( lpMsg->msg ); + free( lpMsg ); + } + return DP_OK; }
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index c13e136cc5a..7df429e6b27 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -4053,14 +4053,15 @@ if(0)
#define checkCreatePlayerOrGroupMessage( dp, expectedType, expectedDpid, expectedCurrentPlayers, expectedPlayerData, \ expectedPlayerDataSize, expectedShortName, expectedLongName, expectedParent, \ - expectedFlags ) \ + expectedFlags, flagsTodo ) \ checkCreatePlayerOrGroupMessage_( __LINE__, dp, expectedType, expectedDpid, expectedCurrentPlayers, \ expectedPlayerData, expectedPlayerDataSize, expectedShortName, \ - expectedLongName, expectedParent, expectedFlags ) + expectedLongName, expectedParent, expectedFlags, flagsTodo ) static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD expectedType, DPID expectedDpid, DWORD expectedCurrentPlayers, void *expectedPlayerData, DWORD expectedPlayerDataSize, const char *expectedShortName, - const char *expectedLongName, DPID expectedParent, DWORD expectedFlags ) + const char *expectedLongName, DPID expectedParent, DWORD expectedFlags, + BOOL flagsTodo ) { DPMSG_CREATEPLAYERORGROUP *msg; DWORD expectedShortNameSize; @@ -4082,11 +4083,9 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD msg = (DPMSG_CREATEPLAYERORGROUP *) msgData; ok_( __FILE__, line )( msg->dwType == DPSYS_CREATEPLAYERORGROUP, "got message type %#lx.\n", msg->dwType ); ok_( __FILE__, line )( msg->dwPlayerType == expectedType, "got player type %#lx.\n", msg->dwPlayerType ); - todo_wine_if( msg->dpId != expectedDpid ) ok_( __FILE__, line )( msg->dpId == expectedDpid, "got id %#lx.\n", - msg->dpId ); - todo_wine_if( msg->dwCurrentPlayers != expectedCurrentPlayers ) - ok_( __FILE__, line )( msg->dwCurrentPlayers == expectedCurrentPlayers, "got current players %lu.\n", - msg->dwCurrentPlayers ); + ok_( __FILE__, line )( msg->dpId == expectedDpid, "got id %#lx.\n", msg->dpId ); + ok_( __FILE__, line )( msg->dwCurrentPlayers == expectedCurrentPlayers, "got current players %lu.\n", + msg->dwCurrentPlayers ); ok_( __FILE__, line )( msg->dwDataSize == expectedPlayerDataSize, "got player data size %lu.\n", msg->dwDataSize ); if ( expectedPlayerData ) { @@ -4107,9 +4106,8 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD } else { - todo_wine_if( msg->dpnName.lpszShortNameA) - ok_( __FILE__, line )( !msg->dpnName.lpszShortNameA, "got short name %s.\n", - wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); + ok_( __FILE__, line )( !msg->dpnName.lpszShortNameA, "got short name %s.\n", + wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); } if ( expectedLongName ) { @@ -4119,13 +4117,11 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD } else { - todo_wine_if( msg->dpnName.lpszShortNameA) - ok_( __FILE__, line )( !msg->dpnName.lpszLongNameA, "got long name %s.\n", - wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); + ok_( __FILE__, line )( !msg->dpnName.lpszLongNameA, "got long name %s.\n", + wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); } ok_( __FILE__, line )( msg->dpIdParent == expectedParent, "got parent id %#lx.\n", msg->dpIdParent ); - todo_wine_if( msg->dwFlags != expectedFlags ) ok_( __FILE__, line )( msg->dwFlags == expectedFlags, - "got flags %#lx.\n", msg->dwFlags ); + todo_wine_if( flagsTodo ) ok_( __FILE__, line )( msg->dwFlags == expectedFlags, "got flags %#lx.\n", msg->dwFlags );
expectedShortNameSize = expectedShortName ? strlen( expectedShortName ) + 1 : 0; expectedLongNameSize = expectedLongName ? strlen( expectedLongName ) + 1 : 0; @@ -4172,14 +4168,15 @@ static BOOL CALLBACK getPlayerIdsCallback( DPID dpid, DWORD playerType, const DP
#define checkCreatePlayerOrGroupMessages( dp, expectedType, expectedDpid, expectedCurrentPlayers, expectedPlayerData, \ expectedPlayerDataSize, expectedShortName, expectedLongName, expectedParent, \ - expectedFlags ) \ + expectedFlags, flagsTodo ) \ checkCreatePlayerOrGroupMessages_( __LINE__, dp, expectedType, expectedDpid, expectedCurrentPlayers, \ expectedPlayerData, expectedPlayerDataSize, expectedShortName, \ - expectedLongName, expectedParent, expectedFlags ) + expectedLongName, expectedParent, expectedFlags, flagsTodo ) static void checkCreatePlayerOrGroupMessages_( int line, IDirectPlay4 *dp, DWORD expectedType, DPID expectedDpid, DWORD expectedCurrentPlayers, void *expectedPlayerData, DWORD expectedPlayerDataSize, const char *expectedShortName, - const char *expectedLongName, DPID expectedParent, DWORD expectedFlags ) + const char *expectedLongName, DPID expectedParent, DWORD expectedFlags, + BOOL flagsTodo ) { GetPlayerIdsCallbackData data = { 0 }; HRESULT hr; @@ -4194,7 +4191,7 @@ static void checkCreatePlayerOrGroupMessages_( int line, IDirectPlay4 *dp, DWORD { dpid = checkCreatePlayerOrGroupMessage_( line, dp, expectedType, expectedDpid, expectedCurrentPlayers, expectedPlayerData, expectedPlayerDataSize, expectedShortName, - expectedLongName, expectedParent, expectedFlags ); + expectedLongName, expectedParent, expectedFlags, flagsTodo ); for ( j = 0; j < data.idCount; ++j ) { if ( data.ids[ j ] == dpid ) @@ -4250,9 +4247,9 @@ static void check_CreatePlayer_( int line, IDirectPlay4 *dp, DPID *dpid, DPNAME if ( hr == DP_OK ) checkCreatePlayerOrGroupMessages_( line, dp, DPPLAYERTYPE_PLAYER, expectedDpid, expectedCurrentPlayers, playerData, sizeof( playerData ), expectedShortNameA, expectedLongNameA, - 0, expectedFlags ); + 0, expectedFlags, flagsTodo );
- todo_wine_if( expectedCurrentPlayers >= 2 ) checkNoMorePlayerMessages_( line, dp ); + checkNoMorePlayerMessages_( line, dp );
closesocket( sendSock ); }
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 18 ++++++++++++------ dlls/dplayx/dplay_global.h | 2 ++ dlls/dplayx/tests/dplayx.c | 5 ++--- 3 files changed, 16 insertions(+), 9 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 20611b283fd..baeab4ac45a 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -322,7 +322,7 @@ static void *DP_DuplicateString( void *src, BOOL dstAnsi, BOOL srcAnsi ) return dst; }
-static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, struct PlayerData *player, +static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, DPID fromId, struct PlayerData *player, DPID excludeId, void *msg, DWORD msgSize ) { struct DPMSG *elem; @@ -346,6 +346,9 @@ static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, struct PlayerData * } memcpy( elem->msg, msg, msgSize );
+ elem->fromId = fromId; + elem->toId = player->dpid; + DPQ_INSERT_IN_TAIL( This->dp2->receiveMsgs, elem, msgs );
if( player->hEvent ) @@ -354,8 +357,8 @@ static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, struct PlayerData * return DP_OK; }
-static HRESULT DP_QueueMessage( IDirectPlayImpl *This, DPID toId, DPID excludeId, void *msg, - DWORD msgSize ) +static HRESULT DP_QueueMessage( IDirectPlayImpl *This, DPID fromId, DPID toId, DPID excludeId, + void *msg, DWORD msgSize ) { struct PlayerList *plist; struct GroupData *group; @@ -363,14 +366,14 @@ static HRESULT DP_QueueMessage( IDirectPlayImpl *This, DPID toId, DPID excludeId
plist = DP_FindPlayer( This, toId ); if ( plist ) - return DP_QueuePlayerMessage( This, plist->lpPData, excludeId, msg, msgSize ); + return DP_QueuePlayerMessage( This, fromId, plist->lpPData, excludeId, msg, msgSize );
group = DP_FindAnyGroup( This, toId ); if( group ) { for( plist = DPQ_FIRST( group->players ); plist; plist = DPQ_NEXT( plist->players ) ) { - hr = DP_QueuePlayerMessage( This, plist->lpPData, excludeId, msg, msgSize ); + hr = DP_QueuePlayerMessage( This, fromId, plist->lpPData, excludeId, msg, msgSize ); if ( FAILED( hr ) ) return hr; } @@ -1690,7 +1693,7 @@ HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPN msg.dpIdParent = 0; msg.dwFlags = dwFlags;
- hr = DP_QueueMessage( This, DPID_ALLPLAYERS, *lpid, &msg, sizeof( msg ) ); + hr = DP_QueueMessage( This, DPID_SYSMSG, DPID_ALLPLAYERS, *lpid, &msg, sizeof( msg ) ); if ( FAILED( hr ) ) { DP_DeleteSPPlayer( This, *lpid ); @@ -3757,6 +3760,9 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT return DPERR_NOMESSAGES; }
+ *lpidFrom = lpMsg->fromId; + *lpidTo = lpMsg->toId; + /* Copy into the provided buffer */ if (lpData) CopyMemory( lpData, lpMsg->msg, *lpdwDataSize );
diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index ebdb81f0a98..7c9b1c11a3a 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -134,6 +134,8 @@ typedef struct GroupList* lpGroupList; struct DPMSG { DPQ_ENTRY( DPMSG ) msgs; + DPID fromId; + DPID toId; DPMSG_GENERIC* msg; }; typedef struct DPMSG* LPDPMSG; diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 7df429e6b27..3bab15cac42 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -4078,7 +4078,7 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD toId = 0xdeadbeef; hr = IDirectPlayX_Receive( dp, &fromId, &toId, 0, msgData, &msgDataSize ); ok_( __FILE__, line )( hr == DP_OK, "got hr %#lx.\n", hr ); - todo_wine ok_( __FILE__, line )( fromId == DPID_SYSMSG, "got source id %#lx.\n", fromId ); + ok_( __FILE__, line )( fromId == DPID_SYSMSG, "got source id %#lx.\n", fromId );
msg = (DPMSG_CREATEPLAYERORGROUP *) msgData; ok_( __FILE__, line )( msg->dwType == DPSYS_CREATEPLAYERORGROUP, "got message type %#lx.\n", msg->dwType ); @@ -4200,8 +4200,7 @@ static void checkCreatePlayerOrGroupMessages_( int line, IDirectPlay4 *dp, DWORD break; } } - todo_wine ok_( __FILE__, line )( dpid && dpid != expectedDpid && j < data.idCount, "got destination id %#lx.\n", - dpid ); + ok_( __FILE__, line )( dpid && dpid != expectedDpid && j < data.idCount, "got destination id %#lx.\n", dpid ); } }
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 46 ++++++++++++++++++++++++++++++++------ dlls/dplayx/dplay_global.h | 3 +++ dlls/dplayx/tests/dplayx.c | 10 ++++----- 3 files changed, 46 insertions(+), 13 deletions(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index baeab4ac45a..9ac0fef779b 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -323,9 +323,10 @@ static void *DP_DuplicateString( void *src, BOOL dstAnsi, BOOL srcAnsi ) }
static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, DPID fromId, struct PlayerData *player, - DPID excludeId, void *msg, DWORD msgSize ) + DPID excludeId, void *msg, FN_COPY_MESSAGE *copyMessage ) { struct DPMSG *elem; + DWORD msgSize;
if ( !( player->dwFlags & DPLAYI_PLAYER_PLAYERLOCAL ) ) return DP_OK; @@ -338,16 +339,18 @@ static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, DPID fromId, struct if( !elem ) return DPERR_OUTOFMEMORY;
+ msgSize = copyMessage( NULL, msg, FALSE ); elem->msg = malloc( msgSize ); if ( !elem->msg ) { free( elem ); return DPERR_OUTOFMEMORY; } - memcpy( elem->msg, msg, msgSize ); + copyMessage( elem->msg, msg, FALSE );
elem->fromId = fromId; elem->toId = player->dpid; + elem->copyMessage = copyMessage;
DPQ_INSERT_IN_TAIL( This->dp2->receiveMsgs, elem, msgs );
@@ -358,7 +361,7 @@ static HRESULT DP_QueuePlayerMessage( IDirectPlayImpl *This, DPID fromId, struct }
static HRESULT DP_QueueMessage( IDirectPlayImpl *This, DPID fromId, DPID toId, DPID excludeId, - void *msg, DWORD msgSize ) + void *msg, FN_COPY_MESSAGE *copyMessage ) { struct PlayerList *plist; struct GroupData *group; @@ -366,14 +369,14 @@ static HRESULT DP_QueueMessage( IDirectPlayImpl *This, DPID fromId, DPID toId, D
plist = DP_FindPlayer( This, toId ); if ( plist ) - return DP_QueuePlayerMessage( This, fromId, plist->lpPData, excludeId, msg, msgSize ); + return DP_QueuePlayerMessage( This, fromId, plist->lpPData, excludeId, msg, copyMessage );
group = DP_FindAnyGroup( This, toId ); if( group ) { for( plist = DPQ_FIRST( group->players ); plist; plist = DPQ_NEXT( plist->players ) ) { - hr = DP_QueuePlayerMessage( This, fromId, plist->lpPData, excludeId, msg, msgSize ); + hr = DP_QueuePlayerMessage( This, fromId, plist->lpPData, excludeId, msg, copyMessage ); if ( FAILED( hr ) ) return hr; } @@ -384,6 +387,34 @@ static HRESULT DP_QueueMessage( IDirectPlayImpl *This, DPID fromId, DPID toId, D return DPERR_INVALIDPLAYER; }
+static DWORD DP_CopyCreatePlayerOrGroup( DPMSG_GENERIC *genericDst, DPMSG_GENERIC *genericSrc, + BOOL ansi ) +{ + DPMSG_CREATEPLAYERORGROUP *src = (DPMSG_CREATEPLAYERORGROUP *) genericSrc; + DPMSG_CREATEPLAYERORGROUP *dst = (DPMSG_CREATEPLAYERORGROUP *) genericDst; + DWORD offset = sizeof( DPMSG_CREATEPLAYERORGROUP ); + + if ( dst ) + *dst = *src; + + if ( src->lpData ) + { + if ( dst ) + { + dst->lpData = (char *) dst + offset; + memcpy( dst->lpData, src->lpData, src->dwDataSize ); + } + offset += src->dwDataSize; + } + + offset += DP_CopyString( &dst->dpnName.lpszShortNameA, src->dpnName.lpszShortNameA, ansi, FALSE, + genericDst, offset ); + offset += DP_CopyString( &dst->dpnName.lpszLongNameA, src->dpnName.lpszLongNameA, ansi, FALSE, + genericDst, offset ); + + return offset; +} + /* *lplpReply will be non NULL iff there is something to reply */ HRESULT DP_HandleMessage( IDirectPlayImpl *This, void *messageBody, DWORD dwMessageBodySize, void *messageHeader, WORD wCommandId, WORD wVersion, @@ -1693,7 +1724,8 @@ HRESULT DP_CreatePlayer( IDirectPlayImpl *This, void *msgHeader, DPID *lpid, DPN msg.dpIdParent = 0; msg.dwFlags = dwFlags;
- hr = DP_QueueMessage( This, DPID_SYSMSG, DPID_ALLPLAYERS, *lpid, &msg, sizeof( msg ) ); + hr = DP_QueueMessage( This, DPID_SYSMSG, DPID_ALLPLAYERS, *lpid, &msg, + DP_CopyCreatePlayerOrGroup ); if ( FAILED( hr ) ) { DP_DeleteSPPlayer( This, *lpid ); @@ -3764,7 +3796,7 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT *lpidTo = lpMsg->toId;
/* Copy into the provided buffer */ - if (lpData) CopyMemory( lpData, lpMsg->msg, *lpdwDataSize ); + if (lpData) lpMsg->copyMessage( lpData, lpMsg->msg, bAnsi );
if( !( dwFlags & DPRECEIVE_PEEK ) ) { diff --git a/dlls/dplayx/dplay_global.h b/dlls/dplayx/dplay_global.h index 7c9b1c11a3a..cf3bbd0d592 100644 --- a/dlls/dplayx/dplay_global.h +++ b/dlls/dplayx/dplay_global.h @@ -131,12 +131,15 @@ struct GroupList }; typedef struct GroupList* lpGroupList;
+typedef DWORD FN_COPY_MESSAGE( DPMSG_GENERIC *genericDst, DPMSG_GENERIC *genericSrc, BOOL ansi ); + struct DPMSG { DPQ_ENTRY( DPMSG ) msgs; DPID fromId; DPID toId; DPMSG_GENERIC* msg; + FN_COPY_MESSAGE *copyMessage; }; typedef struct DPMSG* LPDPMSG;
diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 3bab15cac42..21032876c50 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -4100,9 +4100,8 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD ok_( __FILE__, line )( !msg->dpnName.dwFlags, "got name flags %#lx.\n", msg->dpnName.dwFlags ); if ( expectedShortName ) { - todo_wine - ok_( __FILE__, line )( msg->dpnName.lpszShortNameA && !strcmp( msg->dpnName.lpszShortNameA, expectedShortName ), - "got short name %s.\n", wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); + ok_( __FILE__, line )( msg->dpnName.lpszShortNameA && !strcmp( msg->dpnName.lpszShortNameA, expectedShortName ), + "got short name %s.\n", wine_dbgstr_a( msg->dpnName.lpszShortNameA ) ); } else { @@ -4111,9 +4110,8 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD } if ( expectedLongName ) { - todo_wine - ok_( __FILE__, line )( msg->dpnName.lpszLongNameA && !strcmp( msg->dpnName.lpszLongNameA, expectedLongName ), - "got long name %s.\n", wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); + ok_( __FILE__, line )( msg->dpnName.lpszLongNameA && !strcmp( msg->dpnName.lpszLongNameA, expectedLongName ), + "got long name %s.\n", wine_dbgstr_a( msg->dpnName.lpszLongNameA ) ); } else {
From: Anton Baskanov baskanov@gmail.com
--- dlls/dplayx/dplay.c | 4 ++++ dlls/dplayx/tests/dplayx.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index 9ac0fef779b..99d50f53d6c 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -3750,6 +3750,7 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT void *lpData, DWORD *lpdwDataSize, BOOL bAnsi ) { LPDPMSG lpMsg = NULL; + DWORD msgSize;
FIXME( "(%p)->(%p,%p,0x%08lx,%p,%p,%u): stub\n", This, lpidFrom, lpidTo, dwFlags, lpData, lpdwDataSize, bAnsi ); @@ -3792,8 +3793,11 @@ static HRESULT DP_IF_Receive( IDirectPlayImpl *This, DPID *lpidFrom, DPID *lpidT return DPERR_NOMESSAGES; }
+ msgSize = lpMsg->copyMessage( NULL, lpMsg->msg, bAnsi ); + *lpidFrom = lpMsg->fromId; *lpidTo = lpMsg->toId; + *lpdwDataSize = msgSize;
/* Copy into the provided buffer */ if (lpData) lpMsg->copyMessage( lpData, lpMsg->msg, bAnsi ); diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index 21032876c50..c3d4dac7bc6 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -4126,7 +4126,7 @@ static DPID checkCreatePlayerOrGroupMessage_( int line, IDirectPlay4 *dp, DWORD expectedMsgDataSize = sizeof( DPMSG_CREATEPLAYERORGROUP ) + expectedShortNameSize + expectedLongNameSize + expectedPlayerDataSize;
- todo_wine ok_( __FILE__, line )( msgDataSize == expectedMsgDataSize, "got message size %lu.\n", msgDataSize ); + ok_( __FILE__, line )( msgDataSize == expectedMsgDataSize, "got message size %lu.\n", msgDataSize );
return toId; }
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=149192
Your paranoid android.
=== debian11 (32 bit hi:IN report) ===
dplayx: dplayx.c:4321: Test failed: got short name "". dplayx.c:4321: Test failed: got long name "". dplayx.c:4321: Test failed: got message size 58. dplayx.c:4327: Test failed: got short name "". dplayx.c:4327: Test failed: got long name "". dplayx.c:4327: Test failed: got message size 58. dplayx.c:4327: Test failed: got short name "". dplayx.c:4327: Test failed: got long name "". dplayx.c:4327: Test failed: got message size 58.
This merge request was approved by Alistair Leslie-Hughes.