Changeset 5311 for trunk/src/DPlayX/dplaysp.cpp
- Timestamp:
- Mar 14, 2001, 12:13:28 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/DPlayX/dplaysp.cpp
r4446 r5311 1 // $Id: dplaysp.cpp,v 1. 3 2000-10-06 19:49:04hugh Exp $1 // $Id: dplaysp.cpp,v 1.4 2001-03-13 23:13:27 hugh Exp $ 2 2 /* This contains the implementation of the interface Service 3 3 * Providers require to communicate with Direct Play … … 58 58 IDirectPlay2Impl* dplay; /* FIXME: This should perhaps be iface not impl */ 59 59 60 LPVOID lpPlayerData; /* FIXME: Need to figure out how this actually behaves */61 DWORD dwPlayerDataSize;62 60 } DirectPlaySPData; 63 61 … … 75 73 /* Forward declaration of virtual tables */ 76 74 extern ICOM_VTABLE(IDirectPlaySP) directPlaySPVT; 75 76 /* This structure is passed to the DP object for safe keeping */ 77 typedef struct tagDP_SPPLAYERDATA 78 { 79 LPVOID lpPlayerLocalData; 80 DWORD dwPlayerLocalDataSize; 81 82 LPVOID lpPlayerRemoteData; 83 DWORD dwPlayerRemoteDataSize; 84 } DP_SPPLAYERDATA, *LPDP_SPPLAYERDATA; 77 85 78 86 … … 177 185 /* IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp ); */ 178 186 187 /* FIXME: This is a kludge to get around a problem where a queryinterface 188 * is used to get a new interface and then is closed. We will then 189 * reference garbage. However, with this we will never deallocate 190 * the interface we store. The correct fix is to require all 191 * DP internal interfaces to use the This->dp2 interface which 192 * should be changed to This->dp 193 */ 194 IDirectPlayX_AddRef( (LPDIRECTPLAY2)dp ); 195 179 196 return TRUE; 180 197 } … … 375 392 ) 376 393 { 377 ICOM_THIS(IDirectPlaySPImpl,iface); 378 379 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 380 FIXME( "(%p)->(0x%08lx,%p,%p,0x%08lx): stub\n", 394 HRESULT hr; 395 LPDP_SPPLAYERDATA lpPlayerData; 396 ICOM_THIS(IDirectPlaySPImpl,iface); 397 398 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 399 TRACE( "(%p)->(0x%08lx,%p,%p,0x%08lx)\n", 381 400 This, idPlayer, lplpData, lpdwDataSize, dwFlags ); 382 401 402 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerData ); 403 404 if( FAILED(hr) ) 405 { 406 TRACE( "Couldn't get player data: %s\n", DPLAYX_HresultToString(hr) ); 407 return DPERR_INVALIDPLAYER; 408 } 409 383 410 /* What to do in the case where there is nothing set yet? */ 384 385 *lplpData = This->sp->lpPlayerData; 386 *lpdwDataSize = This->sp->dwPlayerDataSize; 387 388 return DP_OK; 411 if( dwFlags == DPSET_LOCAL ) 412 { 413 if( lpPlayerData->lpPlayerLocalData ) 414 { 415 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerLocalData ); 416 } 417 418 *lplpData = lpPlayerData->lpPlayerLocalData; 419 *lpdwDataSize = lpPlayerData->dwPlayerLocalDataSize; 420 } 421 else if( dwFlags == DPSET_REMOTE ) 422 { 423 if( lpPlayerData->lpPlayerRemoteData ) 424 { 425 HeapFree( GetProcessHeap(), 0, lpPlayerData->lpPlayerRemoteData ); 426 } 427 428 *lplpData = lpPlayerData->lpPlayerRemoteData; 429 *lpdwDataSize = lpPlayerData->dwPlayerRemoteDataSize; 430 } 431 432 if( *lplpData == NULL ) 433 { 434 hr = DPERR_GENERIC; 435 } 436 437 return hr; 389 438 } 390 439 … … 403 452 ICOM_THIS(IDirectPlaySPImpl,iface); 404 453 405 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 454 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 406 455 FIXME( "(%p)->(%p,0x%08lx,%p): mostly stub\n", 407 456 This, lpMessageBody, dwMessageBodySize, lpMessageHeader ); … … 421 470 { 422 471 /* Name server needs to handle this request */ 472 /* FIXME: This should be done in direct play handler */ 423 473 case DPMSGCMD_ENUMSESSIONSREQUEST: 424 474 { … … 442 492 443 493 /* Name server needs to handle this request */ 494 /* FIXME: This should be done in direct play handler */ 444 495 case DPMSGCMD_ENUMSESSIONSREPLY: 445 496 { … … 450 501 451 502 /* No reply expected */ 452 453 break; 454 } 455 456 case DPMSGCMD_GETNAMETABLE: 457 case DPMSGCMD_GETNAMETABLEREPLY: 458 case DPMSGCMD_NEWPLAYERIDREPLY: 459 case DPMSGCMD_REQUESTNEWPLAYERID: 503 hr = DP_OK; 504 505 break; 506 } 507 508 /* Pass everything else to Direct Play */ 509 default: 460 510 { 461 511 DPSP_REPLYDATA data; … … 465 515 466 516 /* Pass this message to the dplay interface to handle */ 467 DP_HandleMessage( This->sp->dplay, lpMessageBody, dwMessageBodySize,517 hr = DP_HandleMessage( This->sp->dplay, lpMessageBody, dwMessageBodySize, 468 518 lpMessageHeader, wCommandId, wVersion, 469 519 &data.lpMessage, &data.dwMessageSize ); … … 488 538 break; 489 539 } 490 491 default:492 FIXME( "Unknown Command of %u and size 0x%08lx\n",493 lpMsg->wCommandId, dwMessageBodySize );494 540 } 495 541 … … 748 794 ) 749 795 { 750 ICOM_THIS(IDirectPlaySPImpl,iface);751 752 /* FIXME: I'm not sure if this stuff should be associated with the DPlay753 * player lists. How else would this stuff get deleted? 754 */755 756 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 757 FIXME( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx): stub\n",796 HRESULT hr; 797 LPDP_SPPLAYERDATA lpPlayerEntry; 798 LPVOID lpPlayerData; 799 800 ICOM_THIS(IDirectPlaySPImpl,iface); 801 802 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 803 TRACE( "(%p)->(0x%08lx,%p,0x%08lx,0x%08lx)\n", 758 804 This, idPlayer, lpData, dwDataSize, dwFlags ); 759 805 760 This->sp->lpPlayerData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 761 762 This->sp->dwPlayerDataSize = dwDataSize; 763 CopyMemory( This->sp->lpPlayerData, lpData, dwDataSize ); 764 765 return DP_OK; 806 hr = DP_GetSPPlayerData( This->sp->dplay, idPlayer, (LPVOID*)&lpPlayerEntry ); 807 if( FAILED(hr) ) 808 { 809 /* Player must not exist */ 810 return DPERR_INVALIDPLAYER; 811 } 812 813 lpPlayerData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 814 CopyMemory( lpPlayerData, lpData, dwDataSize ); 815 816 if( dwFlags == DPSET_LOCAL ) 817 { 818 lpPlayerEntry->lpPlayerLocalData = lpPlayerData; 819 lpPlayerEntry->dwPlayerLocalDataSize = dwDataSize; 820 } 821 else if( dwFlags == DPSET_REMOTE ) 822 { 823 lpPlayerEntry->lpPlayerRemoteData = lpPlayerData; 824 lpPlayerEntry->dwPlayerRemoteDataSize = dwDataSize; 825 } 826 827 hr = DP_SetSPPlayerData( This->sp->dplay, idPlayer, lpPlayerEntry ); 828 829 return hr; 766 830 } 767 831 … … 789 853 ) 790 854 { 791 ICOM_THIS(IDirectPlaySPImpl,iface); 792 793 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 855 HRESULT hr = DP_OK; 856 ICOM_THIS(IDirectPlaySPImpl,iface); 857 858 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 794 859 TRACE( "(%p)->(%p,%p,0x%08lx)\n", 795 860 This, lplpData, lpdwDataSize, dwFlags ); … … 797 862 #if 0 798 863 /* This is what the documentation says... */ 799 if( dwFlags != 0)864 if( dwFlags != DPSET_REMOTE ) 800 865 { 801 866 return DPERR_INVALIDPARAMS; … … 806 871 * thing? 807 872 */ 808 if( dwFlags != 0)873 if( dwFlags != DPSET_REMOTE ) 809 874 { 810 875 FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags ); 811 876 } 812 877 #endif 878 879 /* FIXME: What to do in the case where this isn't initialized yet? */ 813 880 814 881 /* Yes, we're supposed to return a pointer to the memory we have stored! */ … … 817 884 *lpdwDataSize = This->sp->dwSpRemoteDataSize; 818 885 *lplpData = This->sp->lpSpRemoteData; 886 887 if( This->sp->lpSpRemoteData == NULL ) 888 { 889 hr = DPERR_GENERIC; 890 } 819 891 } 820 892 else if( dwFlags == DPSET_LOCAL ) … … 822 894 *lpdwDataSize = This->sp->dwSpLocalDataSize; 823 895 *lplpData = This->sp->lpSpLocalData; 824 } 825 826 return DP_OK; 896 897 if( This->sp->lpSpLocalData == NULL ) 898 { 899 hr = DPERR_GENERIC; 900 } 901 } 902 903 return hr; 827 904 } 828 905 … … 838 915 ICOM_THIS(IDirectPlaySPImpl,iface); 839 916 840 TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); 917 /* TRACE( "Called on process 0x%08lx\n", GetCurrentProcessId() ); */ 841 918 TRACE( "(%p)->(%p,0x%08lx,0x%08lx)\n", 842 919 This, lpData, dwDataSize, dwFlags ); … … 844 921 #if 0 845 922 /* This is what the documentation says... */ 846 if( dwFlags != 0)923 if( dwFlags != DPSET_REMOTE ) 847 924 { 848 925 return DPERR_INVALIDPARAMS; … … 853 930 * thing? 854 931 */ 855 if( dwFlags != 0)932 if( dwFlags != DPSET_REMOTE ) 856 933 { 857 934 FIXME( "Undocumented dwFlags 0x%08lx used\n", dwFlags ); … … 859 936 #endif 860 937 861 if( dwFlags == DPSET_REMOTE ) 862 { 863 lpSpData = DPLAYX_PrivHeapAlloc( HEAP_ZERO_MEMORY, dwDataSize ); 864 } 865 else 866 { 867 lpSpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 868 } 869 938 lpSpData = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, dwDataSize ); 870 939 CopyMemory( lpSpData, lpData, dwDataSize ); 871 940 … … 873 942 if( dwFlags == DPSET_REMOTE ) 874 943 { 875 /* FIXME: This doesn't strictly make sense as there is no means to share876 * this shared data. Must be misinterpreting something...877 */878 944 if( This->sp->lpSpRemoteData ) 879 945 { 880 DPLAYX_PrivHeapFree( This->sp->lpSpRemoteData ); 881 } 882 883 /* NOTE: dwDataSize is also stored in the heap structure */ 946 HeapFree( GetProcessHeap(), 0, This->sp->lpSpRemoteData ); 947 } 948 884 949 This->sp->dwSpRemoteDataSize = dwDataSize; 885 950 This->sp->lpSpRemoteData = lpSpData; … … 933 998 IDirectPlaySPImpl_SendComplete 934 999 }; 1000 1001 1002 /* DP external interfaces to call into DPSP interface */ 1003 1004 /* Allocate the structure */ 1005 extern LPVOID DPSP_CreateSPPlayerData(void) 1006 { 1007 TRACE( "Creating SPPlayer data struct\n" ); 1008 return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, 1009 sizeof( DP_SPPLAYERDATA ) ); 1010 } 1011
Note:
See TracChangeset
for help on using the changeset viewer.