예제 #1
0
/*
 * DPlayOpenSession
 *
 * Wrapper for DirectPlay OpenSession API. 
 */
HRESULT DPlayOpenSession(LPGUID lpSessionGuid)
{
	HRESULT hr = E_FAIL;
	DPSESSIONDESC2 dpDesc;

	if (!glpDP)
		return DPERR_NOINTERFACE;

	ZeroMemory(&dpDesc, sizeof(dpDesc));
	dpDesc.dwSize = sizeof(dpDesc);
	if (gbUseProtocol)
		dpDesc.dwFlags = DPSESSION_DIRECTPLAYPROTOCOL;

	// set the session guid
	if (lpSessionGuid)
		dpDesc.guidInstance = *lpSessionGuid;
	// set the application guid
	if (glpGuid)
		dpDesc.guidApplication = *glpGuid;

	// open it
	hr = IDirectPlayX_Open(glpDP, &dpDesc, DPOPEN_JOIN);

	// Check for Async message support
//	if (SUCCEEDED(hr))
//		CheckCaps();

	return hr;
}
예제 #2
0
//========================================================================================================
//	DPlayOpenSession
//========================================================================================================
HRESULT DPlayOpenSession(LPGUID lpSessionGuid)
{
    HRESULT hr = E_FAIL;
    DPSESSIONDESC2 dpDesc;

	assert(g_lpDP);

    ZeroMemory(&dpDesc, sizeof(dpDesc));
    dpDesc.dwSize = sizeof(dpDesc);

	//dpDesc.dwFlags = DPSESSION_DIRECTPLAYPROTOCOL;

    // set the session guid
    if (lpSessionGuid)
        dpDesc.guidInstance = *lpSessionGuid;

    // Set the application guid
    if (glpGuid)
        dpDesc.guidApplication = *glpGuid;

    // open it
	hr = IDirectPlayX_Open(g_lpDP, &dpDesc, DPOPEN_JOIN);

    return hr;
}
예제 #3
0
// ////////////////////////////////////////////////////////////////////////
// Create a new DPLAY game
HRESULT HostSession(LPDIRECTPLAY4A lpDirectPlay4A, LPSTR lpszSessionName, LPSTR lpszPlayerName,LPNETPLAY lpNetPlay,
					DWORD one, DWORD two, DWORD three, DWORD four, UDWORD mplayers)
{
	DPID				dpidPlayer;
	DPNAME				dpName;
	DPSESSIONDESC2		sessionDesc;
	HRESULT				hr;

	ZeroMemory(&sessionDesc, sizeof(DPSESSIONDESC2));					// host a new session
	sessionDesc.dwSize = sizeof(DPSESSIONDESC2);
   
    sessionDesc.guidApplication = GAME_GUID;
    sessionDesc.dwMaxPlayers = mplayers;
	sessionDesc.lpszSessionNameA = lpszSessionName;
#ifdef USE_DIRECTPLAY_PROTOCOL
	sessionDesc.dwFlags = DPSESSION_MIGRATEHOST | DPSESSION_KEEPALIVE | DPSESSION_DIRECTPLAYPROTOCOL ;
#else
	sessionDesc.dwFlags = DPSESSION_MIGRATEHOST | DPSESSION_KEEPALIVE;
#endif
	sessionDesc.dwUser1 = one;											// set the user flags
	sessionDesc.dwUser2 = two;
	sessionDesc.dwUser3 = three;
	sessionDesc.dwUser4 = four;

	hr = IDirectPlayX_Open(glpDP,&sessionDesc, DPOPEN_CREATE);
	if FAILED(hr)
	{
		goto OPEN_FAILURE;
	}
	ZeroMemory(&dpName, sizeof(DPNAME));								// fill out name structure
	dpName.dwSize = sizeof(DPNAME);
	dpName.lpszShortNameA = lpszPlayerName;
	dpName.lpszLongNameA = NULL;

	hr = IDirectPlayX_CreatePlayer(glpDP,&dpidPlayer, &dpName, lpNetPlay->hPlayerEvent, NULL, 0, 0);		
							
	if FAILED(hr)
	{
		goto CREATEPLAYER_FAILURE;
	}
	lpNetPlay->lpDirectPlay4A	= lpDirectPlay4A;							// return connection info
	lpNetPlay->dpidPlayer		= dpidPlayer;
	lpNetPlay->bHost			= TRUE;
	lpNetPlay->bSpectator		= FALSE;
	return (DP_OK);

CREATEPLAYER_FAILURE:
OPEN_FAILURE:
	IDirectPlayX_Close(glpDP);
	return (hr);
}
예제 #4
0
// ////////////////////////////////////////////////////////////////////////
// Enter a DPLAY game 
HRESULT JoinSession(LPDIRECTPLAY4A lpDirectPlay4A,
					LPGUID lpguidSessionInstance, LPSTR lpszPlayerName,
					LPNETPLAY	lpNetPlay)
{
	DPID				dpidPlayer;
	DPNAME				dpName;
	DPSESSIONDESC2		sessionDesc;
	HRESULT				hr;

	ZeroMemory(&sessionDesc, sizeof(DPSESSIONDESC2));					// join existing session
	sessionDesc.dwSize = sizeof(DPSESSIONDESC2);
    sessionDesc.guidInstance = *lpguidSessionInstance;

	hr = IDirectPlayX_Open(glpDP,&sessionDesc, DPOPEN_JOIN);
	
	if FAILED(hr)
		goto OPEN_FAILURE;

	ZeroMemory(&dpName, sizeof(DPNAME));								// fill out name structure
	dpName.dwSize = sizeof(DPNAME);
	dpName.lpszShortNameA = lpszPlayerName;
	dpName.lpszLongNameA = NULL;

	hr = IDirectPlayX_CreatePlayer(glpDP,&dpidPlayer, &dpName, lpNetPlay->hPlayerEvent, NULL, 0, 0);			
							
	if FAILED(hr)
		goto CREATEPLAYER_FAILURE;
	
	lpNetPlay->lpDirectPlay4A = lpDirectPlay4A;							// return connection info
	lpNetPlay->dpidPlayer = dpidPlayer;
	lpNetPlay->bHost = FALSE;
	lpNetPlay->bSpectator = FALSE;

	return (DP_OK);

CREATEPLAYER_FAILURE:
OPEN_FAILURE:
	IDirectPlayX_Close(glpDP);
	return (hr);
}
예제 #5
0
//========================================================================================
//	DPlayCreateSession
//========================================================================================
HRESULT DPlayCreateSession(LPTSTR lptszSessionName, DWORD MaxPlayers)
{
    HRESULT hr = E_FAIL;
    DPSESSIONDESC2 dpDesc;

	assert(g_lpDP);

    ZeroMemory(&dpDesc, sizeof(dpDesc));
    dpDesc.dwSize = sizeof(dpDesc);
    
	dpDesc.dwFlags = DPSESSION_KEEPALIVE;

#if 0		// Just keeping these here for reference...
	dpDesc.dwFlags |= DPSESSION_CLIENTSERVER;
    dpDesc.dwFlags |= DPSESSION_MIGRATEHOST;
	dpDesc.dwFlags |= DPSESSION_OPTIMIZELATENCY;
	dpDesc.dwFlags |= DPSESSION_DIRECTPLAYPROTOCOL;
#endif

	dpDesc.dwMaxPlayers = MaxPlayers;

#ifdef UNICODE
    dpDesc.lpszSessionName = lptszSessionName;
#else
    dpDesc.lpszSessionNameA = lptszSessionName;
#endif

    // set the application guid
    if (glpGuid)
        dpDesc.guidApplication = *glpGuid;

	hr = IDirectPlayX_Open(g_lpDP, &dpDesc, DPOPEN_CREATE);

	if (hr != DP_OK)
	{
		DoDPError(hr);
	}

    return hr;
}
예제 #6
0
/*
 * DPlayCreateSession
 *
 * Wrapper for DirectPlay CreateSession API.Uses the global application guid (glpGuid).
 */
HRESULT DPlayCreateSession(LPTSTR lptszSessionName,int maxPlayers,int dwUser1,int dwUser2)
{
	HRESULT hr = E_FAIL;
	DPSESSIONDESC2 dpDesc;

	if (!glpDP)
		return DPERR_NOINTERFACE;

	ZeroMemory(&dpDesc, sizeof(dpDesc));
	dpDesc.dwSize = sizeof(dpDesc);
	dpDesc.dwFlags = DPSESSION_MIGRATEHOST | DPSESSION_KEEPALIVE;
	if (gbUseProtocol)
		dpDesc.dwFlags |= DPSESSION_DIRECTPLAYPROTOCOL;

#ifdef UNICODE
	dpDesc.lpszSessionName = lptszSessionName;
#else
	dpDesc.lpszSessionNameA = lptszSessionName;
#endif
	dpDesc.dwMaxPlayers=maxPlayers;

	dpDesc.dwUser1 = dwUser1;
	dpDesc.dwUser2 = dwUser2;

	// set the application guid
	if (glpGuid)
		dpDesc.guidApplication = *glpGuid;

	hr = IDirectPlayX_Open(glpDP, &dpDesc, DPOPEN_CREATE);

	// Check for Async message support
//	if (SUCCEEDED(hr))
//		CheckCaps();

	return hr;
}