Commit 0dd3f041 authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

dplayx: Merge the IDirectPlay4_GetPlayerData helper.

parent a784e239
...@@ -89,9 +89,6 @@ static HRESULT DP_IF_DestroyPlayer ...@@ -89,9 +89,6 @@ static HRESULT DP_IF_DestroyPlayer
static HRESULT DP_IF_GetGroupName static HRESULT DP_IF_GetGroupName
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData, ( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
LPDWORD lpdwDataSize, BOOL bAnsi ); LPDWORD lpdwDataSize, BOOL bAnsi );
static HRESULT DP_IF_GetPlayerData
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi );
static HRESULT DP_IF_GetPlayerName static HRESULT DP_IF_GetPlayerName
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, ( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
LPDWORD lpdwDataSize, BOOL bAnsi ); LPDWORD lpdwDataSize, BOOL bAnsi );
...@@ -2249,68 +2246,50 @@ static HRESULT WINAPI IDirectPlay4Impl_GetPlayerCaps( IDirectPlay4 *iface, DPID ...@@ -2249,68 +2246,50 @@ static HRESULT WINAPI IDirectPlay4Impl_GetPlayerCaps( IDirectPlay4 *iface, DPID
return (*This->dp2->spData.lpCB->GetCaps)( &data ); return (*This->dp2->spData.lpCB->GetCaps)( &data );
} }
static HRESULT DP_IF_GetPlayerData static HRESULT WINAPI IDirectPlay4AImpl_GetPlayerData( IDirectPlay4A *iface, DPID player,
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData, void *data, DWORD *size, DWORD flags )
LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi )
{ {
lpPlayerList lpPList; IDirectPlayImpl *This = impl_from_IDirectPlay4A( iface );
DWORD dwRequiredBufferSize; return IDirectPlayX_GetPlayerData( &This->IDirectPlay4_iface, player, data, size, flags );
LPVOID lpCopyDataFrom; }
TRACE( "(%p)->(0x%08x,%p,%p,0x%08x,%u)\n",
This, idPlayer, lpData, lpdwDataSize, dwFlags, bAnsi );
if( This->dp2->connectionInitialized == NO_PROVIDER ) static HRESULT WINAPI IDirectPlay4Impl_GetPlayerData( IDirectPlay4 *iface, DPID player,
{ void *data, DWORD *size, DWORD flags )
return DPERR_UNINITIALIZED; {
} IDirectPlayImpl *This = impl_from_IDirectPlay4( iface );
lpPlayerList plist;
DWORD bufsize;
void *src;
if( ( lpPList = DP_FindPlayer( This, idPlayer ) ) == NULL ) TRACE( "(%p)->(0x%08x,%p,%p,0x%08x)\n", This, player, data, size, flags );
{
return DPERR_INVALIDPLAYER;
}
/* How much buffer is required? */ if ( This->dp2->connectionInitialized == NO_PROVIDER )
if( dwFlags & DPSET_LOCAL ) return DPERR_UNINITIALIZED;
{
dwRequiredBufferSize = lpPList->lpPData->dwLocalDataSize;
lpCopyDataFrom = lpPList->lpPData->lpLocalData;
}
else
{
dwRequiredBufferSize = lpPList->lpPData->dwRemoteDataSize;
lpCopyDataFrom = lpPList->lpPData->lpRemoteData;
}
/* Is the user requesting to know how big a buffer is required? */ if ( ( plist = DP_FindPlayer( This, player ) ) == NULL )
if( ( lpData == NULL ) || return DPERR_INVALIDPLAYER;
( *lpdwDataSize < dwRequiredBufferSize )
)
{
*lpdwDataSize = dwRequiredBufferSize;
return DPERR_BUFFERTOOSMALL;
}
CopyMemory( lpData, lpCopyDataFrom, dwRequiredBufferSize ); if ( flags & DPSET_LOCAL )
{
bufsize = plist->lpPData->dwLocalDataSize;
src = plist->lpPData->lpLocalData;
}
else
{
bufsize = plist->lpPData->dwRemoteDataSize;
src = plist->lpPData->lpRemoteData;
}
return DP_OK; /* Is the user requesting to know how big a buffer is required? */
} if ( !data || *size < bufsize )
{
*size = bufsize;
return DPERR_BUFFERTOOSMALL;
}
static HRESULT WINAPI IDirectPlay4AImpl_GetPlayerData( IDirectPlay4A *iface, DPID idPlayer, CopyMemory( data, src, bufsize );
void *lpData, DWORD *lpdwDataSize, DWORD dwFlags )
{
IDirectPlayImpl *This = impl_from_IDirectPlay4A( iface );
return DP_IF_GetPlayerData( This, idPlayer, lpData, lpdwDataSize,
dwFlags, TRUE );
}
static HRESULT WINAPI DirectPlay2WImpl_GetPlayerData return DP_OK;
( LPDIRECTPLAY2 iface, DPID idPlayer, LPVOID lpData,
LPDWORD lpdwDataSize, DWORD dwFlags )
{
IDirectPlay2Impl *This = (IDirectPlay2Impl *)iface;
return DP_IF_GetPlayerData( This, idPlayer, lpData, lpdwDataSize,
dwFlags, FALSE );
} }
static HRESULT DP_IF_GetPlayerName static HRESULT DP_IF_GetPlayerName
...@@ -4489,7 +4468,7 @@ static const IDirectPlay4Vtbl dp4_vt = ...@@ -4489,7 +4468,7 @@ static const IDirectPlay4Vtbl dp4_vt =
IDirectPlay4Impl_GetMessageCount, IDirectPlay4Impl_GetMessageCount,
IDirectPlay4Impl_GetPlayerAddress, IDirectPlay4Impl_GetPlayerAddress,
IDirectPlay4Impl_GetPlayerCaps, IDirectPlay4Impl_GetPlayerCaps,
XCAST(GetPlayerData)DirectPlay2WImpl_GetPlayerData, IDirectPlay4Impl_GetPlayerData,
XCAST(GetPlayerName)DirectPlay2WImpl_GetPlayerName, XCAST(GetPlayerName)DirectPlay2WImpl_GetPlayerName,
XCAST(GetSessionDesc)DirectPlay2WImpl_GetSessionDesc, XCAST(GetSessionDesc)DirectPlay2WImpl_GetSessionDesc,
IDirectPlay4Impl_Initialize, IDirectPlay4Impl_Initialize,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment