diff --git a/dlls/dplayx/dplay.c b/dlls/dplayx/dplay.c index b355310f20d..7646f12fa76 100644 --- a/dlls/dplayx/dplay.c +++ b/dlls/dplayx/dplay.c @@ -1231,20 +1231,11 @@ static HRESULT WINAPI IDirectPlay4Impl_AddPlayerToGroup( IDirectPlay4 *iface, DP * Also, if this event was the result of another machine sending it to us, * don't bother rebroadcasting it. */ - if ( This->dp2->lpSessionDesc && - ( This->dp2->lpSessionDesc->dwFlags & DPSESSION_MULTICASTSERVER ) ) + hr = DP_MSG_SendAddPlayerToGroup( This, DPID_ALLPLAYERS, player, group ); + if( FAILED( hr ) ) { - DPMSG_ADDPLAYERTOGROUP msg; - msg.dwType = DPSYS_ADDPLAYERTOGROUP; - - msg.dpIdGroup = group; - msg.dpIdPlayer = player; - - /* FIXME: Correct to just use send effectively? */ - /* FIXME: Should size include data w/ message or just message "header" */ - /* FIXME: Check return code */ - IDirectPlayX_SendEx( iface, DPID_SERVERPLAYER, DPID_ALLPLAYERS, 0, &msg, sizeof( msg ), - 0, 0, NULL, NULL ); + LeaveCriticalSection( &This->lock ); + return hr; } LeaveCriticalSection( &This->lock ); diff --git a/dlls/dplayx/dplayx_messages.c b/dlls/dplayx/dplayx_messages.c index d81e29a7e0b..9af044b4e4d 100644 --- a/dlls/dplayx/dplayx_messages.c +++ b/dlls/dplayx/dplayx_messages.c @@ -831,6 +831,49 @@ HRESULT DP_MSG_SendCreatePlayer( IDirectPlayImpl *This, DPID toId, DPID id, DWOR return DP_OK; } +HRESULT DP_MSG_SendAddPlayerToGroup( IDirectPlayImpl *This, DPID toId, DPID playerId, DPID groupId ) +{ + DPSP_SENDTOGROUPEXDATA sendData; + DPSP_MSG_ADDPLAYERTOGROUP msg; + SGBUFFER buffers[ 2 ] = { 0 }; + HRESULT hr; + + msg.envelope.dwMagic = DPMSGMAGIC_DPLAYMSG; + msg.envelope.wCommandId = DPMSGCMD_ADDPLAYERTOGROUP; + msg.envelope.wVersion = DPMSGVER_DP6; + msg.toId = 0; + msg.playerId = playerId; + msg.groupId = groupId; + msg.createOffset = 0; + msg.passwordOffset = 0; + + buffers[ 0 ].len = This->dp2->spData.dwSPHeaderSize; + buffers[ 0 ].pData = NULL; + buffers[ 1 ].len = sizeof( msg ); + buffers[ 1 ].pData = (UCHAR *)&msg; + + sendData.lpISP = This->dp2->spData.lpISP; + sendData.dwFlags = DPSEND_GUARANTEED; + sendData.idGroupTo = toId; + sendData.idPlayerFrom = This->dp2->systemPlayerId; + sendData.lpSendBuffers = buffers; + sendData.cBuffers = ARRAYSIZE( buffers ); + sendData.dwMessageSize = DP_MSG_ComputeMessageSize( sendData.lpSendBuffers, sendData.cBuffers ); + sendData.dwPriority = 0; + sendData.dwTimeout = 0; + sendData.lpDPContext = NULL; + sendData.lpdwSPMsgID = NULL; + + hr = (*This->dp2->spData.lpCB->SendToGroupEx)( &sendData ); + if( FAILED( hr ) ) + { + ERR( "SendToGroupEx failed: %s\n", DPLAYX_HresultToString( hr ) ); + return hr; + } + + return DP_OK; +} + HRESULT DP_MSG_SendPingReply( IDirectPlayImpl *This, DPID toId, DPID fromId, DWORD tickCount ) { SGBUFFER buffers[ 2 ] = { 0 }; diff --git a/dlls/dplayx/dplayx_messages.h b/dlls/dplayx/dplayx_messages.h index 2a3a15d5c73..5b6ce52663f 100644 --- a/dlls/dplayx/dplayx_messages.h +++ b/dlls/dplayx/dplayx_messages.h @@ -57,6 +57,8 @@ HRESULT DP_MSG_ForwardPlayerCreation( IDirectPlayImpl *This, DPID dpidServer, WC HRESULT DP_MSG_SendCreatePlayer( IDirectPlayImpl *This, DPID toId, DPID id, DWORD flags, DPNAME *name, void *playerData, DWORD playerDataSize, DPID systemPlayerId ); +HRESULT DP_MSG_SendAddPlayerToGroup( IDirectPlayImpl *This, DPID toId, DPID playerId, + DPID groupId ); HRESULT DP_MSG_SendPingReply( IDirectPlayImpl *This, DPID toId, DPID fromId, DWORD tickCount ); HRESULT DP_MSG_SendAddForwardAck( IDirectPlayImpl *This, DPID id ); @@ -103,6 +105,7 @@ typedef struct #define DPMSGCMD_SYSTEMMESSAGE 10 #define DPMSGCMD_DELETEPLAYER 11 #define DPMSGCMD_DELETEGROUP 12 +#define DPMSGCMD_ADDPLAYERTOGROUP 13 #define DPMSGCMD_ENUMGROUPS 17 @@ -231,6 +234,16 @@ typedef struct tagDPMSG_NEWPLAYERIDREPLY } DPMSG_NEWPLAYERIDREPLY, *LPDPMSG_NEWPLAYERIDREPLY; typedef const DPMSG_NEWPLAYERIDREPLY* LPCDPMSG_NEWPLAYERIDREPLY; +typedef struct +{ + DPMSG_SENDENVELOPE envelope; + DPID toId; + DPID playerId; + DPID groupId; + DWORD createOffset; + DWORD passwordOffset; +} DPSP_MSG_ADDPLAYERTOGROUP; + typedef struct tagDPMSG_FORWARDADDPLAYER { DPMSG_SENDENVELOPE envelope; diff --git a/dlls/dplayx/tests/dplayx.c b/dlls/dplayx/tests/dplayx.c index cb61c946bf4..08d2f48ae82 100644 --- a/dlls/dplayx/tests/dplayx.c +++ b/dlls/dplayx/tests/dplayx.c @@ -2193,9 +2193,7 @@ static unsigned short receiveAddPlayerToGroup_( int line, SOCKET sock, DPID expe int wsResult; wsResult = receiveMessage_( line, sock, &request, sizeof( request ) ); - todo_wine ok_( __FILE__, line )( wsResult == sizeof( request ), "recv() returned %d.\n", wsResult ); - if ( wsResult == SOCKET_ERROR ) - return 0; + ok_( __FILE__, line )( wsResult == sizeof( request ), "recv() returned %d.\n", wsResult ); port = checkSpHeader_( line, &request.spHeader, sizeof( request ) ); checkMessageHeader_( line, &request.request.header, 13 );