Original Post
First of all, lemme post the code first:
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.
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;
}
|