dplayx: Add group to the parent group in DP_CreateGroup().

This commit is contained in:
Anton Baskanov 2024-11-17 16:05:21 +07:00 committed by Alexandre Julliard
parent 46b79b1856
commit 1b9b7a5e65
Notes: Alexandre Julliard 2024-11-18 23:18:20 +01:00
Approved-by: Alistair Leslie-Hughes (@alesliehughes)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/wine/merge_requests/6829

View file

@ -1284,8 +1284,17 @@ static HRESULT WINAPI IDirectPlay4Impl_Close( IDirectPlay4 *iface )
static lpGroupData DP_CreateGroup( IDirectPlayImpl *This, const DPID *lpid, const DPNAME *lpName, static lpGroupData DP_CreateGroup( IDirectPlayImpl *This, const DPID *lpid, const DPNAME *lpName,
DWORD dwFlags, DPID idParent, BOOL bAnsi ) DWORD dwFlags, DPID idParent, BOOL bAnsi )
{ {
struct GroupList *groupList = NULL;
struct GroupData *parent = NULL;
lpGroupData lpGData; lpGroupData lpGData;
if( DPID_SYSTEM_GROUP != *lpid )
{
parent = DP_FindAnyGroup( This, idParent );
if( !parent )
return NULL;
}
/* Allocate the new space and add to end of high level group list */ /* Allocate the new space and add to end of high level group list */
lpGData = calloc( 1, sizeof( *lpGData ) ); lpGData = calloc( 1, sizeof( *lpGData ) );
@ -1315,8 +1324,7 @@ static lpGroupData DP_CreateGroup( IDirectPlayImpl *This, const DPID *lpid, cons
return NULL; return NULL;
} }
/* FIXME: Should we check that the parent exists? */ lpGData->parent = idParent;
lpGData->parent = idParent;
/* FIXME: Should we validate the dwFlags? */ /* FIXME: Should we validate the dwFlags? */
lpGData->dwFlags = dwFlags; lpGData->dwFlags = dwFlags;
@ -1331,6 +1339,30 @@ static lpGroupData DP_CreateGroup( IDirectPlayImpl *This, const DPID *lpid, cons
return NULL; return NULL;
} }
if( DPID_SYSTEM_GROUP == *lpid )
{
This->dp2->lpSysGroup = lpGData;
TRACE( "Inserting system group\n" );
}
else
{
/* Insert into the parent group */
groupList = calloc( 1, sizeof( *groupList ) );
if( !groupList )
{
free( lpGData->nameA );
free( lpGData->name );
free( lpGData );
return NULL;
}
groupList->lpGData = lpGData;
DPQ_INSERT( parent->groups, groupList, groups );
}
/* Something is now referencing this data */
lpGData->uRef++;
TRACE( "Created group id 0x%08lx\n", *lpid ); TRACE( "Created group id 0x%08lx\n", *lpid );
return lpGData; return lpGData;
@ -1429,23 +1461,6 @@ static HRESULT DP_IF_CreateGroup( IDirectPlayImpl *This, void *lpMsgHdr, DPID *l
return DPERR_CANTADDPLAYER; /* yes player not group */ return DPERR_CANTADDPLAYER; /* yes player not group */
} }
if( DPID_SYSTEM_GROUP == *lpidGroup )
{
This->dp2->lpSysGroup = lpGData;
TRACE( "Inserting system group\n" );
}
else
{
/* Insert into the system group */
lpGroupList lpGroup = calloc( 1, sizeof( *lpGroup ) );
lpGroup->lpGData = lpGData;
DPQ_INSERT( This->dp2->lpSysGroup->groups, lpGroup, groups );
}
/* Something is now referencing this data */
lpGData->uRef++;
/* Set all the important stuff for the group */ /* Set all the important stuff for the group */
DP_SetGroupData( lpGData, DPSET_REMOTE, lpData, dwDataSize ); DP_SetGroupData( lpGData, DPSET_REMOTE, lpData, dwDataSize );
@ -4458,8 +4473,6 @@ static HRESULT DP_IF_CreateGroupInGroup( IDirectPlayImpl *This, void *lpMsgHdr,
DPID *lpidGroup, DPNAME *lpGroupName, void *lpData, DWORD dwDataSize, DWORD dwFlags, DPID *lpidGroup, DPNAME *lpGroupName, void *lpData, DWORD dwDataSize, DWORD dwFlags,
BOOL bAnsi ) BOOL bAnsi )
{ {
lpGroupData lpGParentData;
lpGroupList lpGList;
lpGroupData lpGData; lpGroupData lpGData;
TRACE( "(%p)->(0x%08lx,%p,%p,%p,0x%08lx,0x%08lx,%u)\n", TRACE( "(%p)->(0x%08lx,%p,%p,%p,0x%08lx,0x%08lx,%u)\n",
@ -4471,10 +4484,6 @@ static HRESULT DP_IF_CreateGroupInGroup( IDirectPlayImpl *This, void *lpMsgHdr,
return DPERR_UNINITIALIZED; return DPERR_UNINITIALIZED;
} }
/* Verify that the specified parent is valid */
if( ( lpGParentData = DP_FindAnyGroup(This, idParentGroup ) ) == NULL )
return DPERR_INVALIDGROUP;
lpGData = DP_CreateGroup(This, lpidGroup, lpGroupName, dwFlags, idParentGroup, bAnsi ); lpGData = DP_CreateGroup(This, lpidGroup, lpGroupName, dwFlags, idParentGroup, bAnsi );
if( lpGData == NULL ) if( lpGData == NULL )
@ -4482,24 +4491,8 @@ static HRESULT DP_IF_CreateGroupInGroup( IDirectPlayImpl *This, void *lpMsgHdr,
return DPERR_CANTADDPLAYER; /* yes player not group */ return DPERR_CANTADDPLAYER; /* yes player not group */
} }
/* Something else is referencing this data */
lpGData->uRef++;
DP_SetGroupData( lpGData, DPSET_REMOTE, lpData, dwDataSize ); DP_SetGroupData( lpGData, DPSET_REMOTE, lpData, dwDataSize );
/* The list has now been inserted into the interface group list. We now
need to put a "shortcut" to this group in the parent group */
lpGList = calloc( 1, sizeof( *lpGList ) );
if( lpGList == NULL )
{
FIXME( "Memory leak\n" );
return DPERR_CANTADDPLAYER; /* yes player not group */
}
lpGList->lpGData = lpGData;
DPQ_INSERT( lpGParentData->groups, lpGList, groups );
/* Let the SP know that we've created this group */ /* Let the SP know that we've created this group */
if( This->dp2->spData.lpCB->CreateGroup ) if( This->dp2->spData.lpCB->CreateGroup )
{ {