dplayx: Merge the IDirectPlay4_GetPlayerData helper.
This commit is contained in:
parent
a784e23917
commit
0dd3f041f4
|
@ -89,9 +89,6 @@ static HRESULT DP_IF_DestroyPlayer
|
|||
static HRESULT DP_IF_GetGroupName
|
||||
( IDirectPlay2Impl* This, DPID idGroup, LPVOID lpData,
|
||||
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
|
||||
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
|
||||
LPDWORD lpdwDataSize, BOOL bAnsi );
|
||||
|
@ -2249,70 +2246,52 @@ static HRESULT WINAPI IDirectPlay4Impl_GetPlayerCaps( IDirectPlay4 *iface, DPID
|
|||
return (*This->dp2->spData.lpCB->GetCaps)( &data );
|
||||
}
|
||||
|
||||
static HRESULT DP_IF_GetPlayerData
|
||||
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
|
||||
LPDWORD lpdwDataSize, DWORD dwFlags, BOOL bAnsi )
|
||||
static HRESULT WINAPI IDirectPlay4AImpl_GetPlayerData( IDirectPlay4A *iface, DPID player,
|
||||
void *data, DWORD *size, DWORD flags )
|
||||
{
|
||||
lpPlayerList lpPList;
|
||||
DWORD dwRequiredBufferSize;
|
||||
LPVOID lpCopyDataFrom;
|
||||
IDirectPlayImpl *This = impl_from_IDirectPlay4A( iface );
|
||||
return IDirectPlayX_GetPlayerData( &This->IDirectPlay4_iface, player, data, size, flags );
|
||||
}
|
||||
|
||||
TRACE( "(%p)->(0x%08x,%p,%p,0x%08x,%u)\n",
|
||||
This, idPlayer, lpData, lpdwDataSize, dwFlags, bAnsi );
|
||||
static HRESULT WINAPI IDirectPlay4Impl_GetPlayerData( IDirectPlay4 *iface, DPID player,
|
||||
void *data, DWORD *size, DWORD flags )
|
||||
{
|
||||
IDirectPlayImpl *This = impl_from_IDirectPlay4( iface );
|
||||
lpPlayerList plist;
|
||||
DWORD bufsize;
|
||||
void *src;
|
||||
|
||||
TRACE( "(%p)->(0x%08x,%p,%p,0x%08x)\n", This, player, data, size, flags );
|
||||
|
||||
if ( This->dp2->connectionInitialized == NO_PROVIDER )
|
||||
{
|
||||
return DPERR_UNINITIALIZED;
|
||||
}
|
||||
|
||||
if( ( lpPList = DP_FindPlayer( This, idPlayer ) ) == NULL )
|
||||
{
|
||||
if ( ( plist = DP_FindPlayer( This, player ) ) == NULL )
|
||||
return DPERR_INVALIDPLAYER;
|
||||
}
|
||||
|
||||
/* How much buffer is required? */
|
||||
if( dwFlags & DPSET_LOCAL )
|
||||
if ( flags & DPSET_LOCAL )
|
||||
{
|
||||
dwRequiredBufferSize = lpPList->lpPData->dwLocalDataSize;
|
||||
lpCopyDataFrom = lpPList->lpPData->lpLocalData;
|
||||
bufsize = plist->lpPData->dwLocalDataSize;
|
||||
src = plist->lpPData->lpLocalData;
|
||||
}
|
||||
else
|
||||
{
|
||||
dwRequiredBufferSize = lpPList->lpPData->dwRemoteDataSize;
|
||||
lpCopyDataFrom = lpPList->lpPData->lpRemoteData;
|
||||
bufsize = plist->lpPData->dwRemoteDataSize;
|
||||
src = plist->lpPData->lpRemoteData;
|
||||
}
|
||||
|
||||
/* Is the user requesting to know how big a buffer is required? */
|
||||
if( ( lpData == NULL ) ||
|
||||
( *lpdwDataSize < dwRequiredBufferSize )
|
||||
)
|
||||
if ( !data || *size < bufsize )
|
||||
{
|
||||
*lpdwDataSize = dwRequiredBufferSize;
|
||||
*size = bufsize;
|
||||
return DPERR_BUFFERTOOSMALL;
|
||||
}
|
||||
|
||||
CopyMemory( lpData, lpCopyDataFrom, dwRequiredBufferSize );
|
||||
CopyMemory( data, src, bufsize );
|
||||
|
||||
return DP_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI IDirectPlay4AImpl_GetPlayerData( IDirectPlay4A *iface, DPID idPlayer,
|
||||
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
|
||||
( 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
|
||||
( IDirectPlay2Impl* This, DPID idPlayer, LPVOID lpData,
|
||||
LPDWORD lpdwDataSize, BOOL bAnsi )
|
||||
|
@ -4489,7 +4468,7 @@ static const IDirectPlay4Vtbl dp4_vt =
|
|||
IDirectPlay4Impl_GetMessageCount,
|
||||
IDirectPlay4Impl_GetPlayerAddress,
|
||||
IDirectPlay4Impl_GetPlayerCaps,
|
||||
XCAST(GetPlayerData)DirectPlay2WImpl_GetPlayerData,
|
||||
IDirectPlay4Impl_GetPlayerData,
|
||||
XCAST(GetPlayerName)DirectPlay2WImpl_GetPlayerName,
|
||||
XCAST(GetSessionDesc)DirectPlay2WImpl_GetSessionDesc,
|
||||
IDirectPlay4Impl_Initialize,
|
||||
|
|
Loading…
Reference in New Issue