Skip to main content
GameDev.net gamedev.net
🔒 Locked

DirectPlay Host() Error...

Started by 1kevgriff Jan 5, 2002 at 10:20 PM 0 replies 800+ views
Original Post
1kevgriff
1kevgriff
First of all, lemme post the code first:
  
HRESULT		hrHostGame(HWND hgame, GUID GUID_INFO)
{
	HRESULT			hReturn;
	char			szSessionName[256];
	WCHAR			wszPeerName[256];
	WCHAR			wszSessionName[256];
	DPN_APPLICATION_DESC	dnAppDesc;
	DWORD			dwLength = 256;
	DPN_PLAYER_INFO	dpPlayerInfo;
	DWORD			dwPort = 6000;

	DXUtil_ConvertGenericStringToWide(wszPeerName, appInfo.playerName);
	ZeroMemory(&dpPlayerInfo, sizeof(DPN_PLAYER_INFO));

	dpPlayerInfo.dwSize = sizeof(DPN_PLAYER_INFO);
	dpPlayerInfo.dwInfoFlags = DPNINFO_NAME;
	dpPlayerInfo.pwszName = wszPeerName;

	if (FAILED(hReturn = g_pDP->SetPeerInfo(&dpPlayerInfo, NULL, NULL, DPNSETPEERINFO_SYNC)))
	{
		printChatText(hgame, "<SYSTEM> Unable to set up peer infomration.");
		return hReturn;
	}

	sprintf(szSessionName, "%s''s Game", appInfo.playerName);
	DXUtil_ConvertGenericStringToWide(wszSessionName, szSessionName);
	
	dnAppDesc.dwSize		= sizeof(DPN_APPLICATION_DESC);
	dnAppDesc.guidApplication = GUID_INFO;
	dnAppDesc.pwszSessionName = wszSessionName;
	dnAppDesc.dwMaxPlayers	= MAX_PLAYERS;
	dnAppDesc.dwFlags		= DPNSESSION_MIGRATE_HOST;

	hReturn = g_pDeviceAddress->AddComponent(DPNA_KEY_PORT, &dwPort, sizeof(DWORD), DPNA_DATATYPE_DWORD);

	if (FAILED(hReturn))
	{
		printChatText(hgame, "<SYSTEM> Unable to set up port!");
		return hReturn;
	}

	hReturn = g_pDP->Host(&dnAppDesc, &g_pDeviceAddress, 1, NULL, NULL, NULL, NULL);

	if (FAILED(hReturn))
	{
		if (hReturn == DPNERR_DATATOOLARGE)
			printChatText(hgame, "<SYSTEM> Host() says DATA TOO LARGE");		
		else if (hReturn == DPNERR_INVALIDDEVICEADDRESS)
			printChatText(hgame, "<SYSTEM> Host() says INVALID DEVICE ADDRESS");
		else if (hReturn == DPNERR_INVALIDPARAM)
			printChatText(hgame, "<SYSTEM> Host() says INVALID PARAM");
		else
			printChatText(hgame, "<SYSTEM> Host is crying... doesn''t know error.");
		return hReturn;
	}

	appInfo.host = true;

	printChatText(hgame, "<SYSTEM> You are currently hosting the game...");

	return hReturn;
}
  
When the program goes through the Host() function, it returns a DPNERR_INVALIDPARAM. I can''t really see what the problem is, but I''m probably just overlooking something. Any help would be great.
cLE
cLE
Hi,

try to
  
ZeroMemory(dnAppDesc, sizeof(DPN_APPLICATION_DESC));

the struct before you fill in some fields.


cLE

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.