This commit is contained in:
Roland Winklmeier
2016-11-17 11:05:19 +01:00
committed by Klaus Basan
parent 0ce38cb7d6
commit 51b2aa6f88

View File

@@ -42,7 +42,6 @@ namespace BlackSimPlugin
} }
SafeRelease(m_deviceAddress); SafeRelease(m_deviceAddress);
CoUninitialize(); CoUninitialize();
} }
@@ -54,26 +53,23 @@ namespace BlackSimPlugin
{ {
DPNMSG_CREATE_PLAYER *pCreatePlayerMsg = static_cast<DPNMSG_CREATE_PLAYER *>(msgBuffer); DPNMSG_CREATE_PLAYER *pCreatePlayerMsg = static_cast<DPNMSG_CREATE_PLAYER *>(msgBuffer);
HRESULT hr;
// Get the peer info and extract its name // Get the peer info and extract its name
DWORD dwSize = 0; DWORD dwSize = 0;
DPN_PLAYER_INFO *pdpPlayerInfo = nullptr; DPN_PLAYER_INFO *pdpPlayerInfo = nullptr;
hr = DPNERR_CONNECTING; HRESULT hr = DPNERR_CONNECTING;
// GetPeerInfo might return DPNERR_CONNECTING when connecting, // GetPeerInfo might return DPNERR_CONNECTING when connecting,
// so just keep calling it if it does // so just keep calling it if it does
while (hr == DPNERR_CONNECTING) while (hr == DPNERR_CONNECTING)
{
hr = m_directPlayPeer->GetPeerInfo(pCreatePlayerMsg->dpnidPlayer, pdpPlayerInfo, &dwSize, 0); hr = m_directPlayPeer->GetPeerInfo(pCreatePlayerMsg->dpnidPlayer, pdpPlayerInfo, &dwSize, 0);
}
if (hr == DPNERR_BUFFERTOOSMALL) if (hr == DPNERR_BUFFERTOOSMALL)
{ {
QScopedArrayPointer<unsigned char> memPtr(new unsigned char[dwSize]); QScopedArrayPointer<unsigned char> memPtr(new unsigned char[dwSize]);
pdpPlayerInfo = reinterpret_cast<DPN_PLAYER_INFO *>(memPtr.data()); pdpPlayerInfo = reinterpret_cast<DPN_PLAYER_INFO *>(memPtr.data());
if (pdpPlayerInfo == nullptr) if (pdpPlayerInfo == nullptr) { break; }
{
break;
}
ZeroMemory(pdpPlayerInfo, dwSize); ZeroMemory(pdpPlayerInfo, dwSize);
pdpPlayerInfo->dwSize = sizeof(DPN_PLAYER_INFO); pdpPlayerInfo->dwSize = sizeof(DPN_PLAYER_INFO);
@@ -82,19 +78,16 @@ namespace BlackSimPlugin
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
{ {
if (pdpPlayerInfo->dwPlayerFlags & DPNPLAYER_LOCAL) if (pdpPlayerInfo->dwPlayerFlags & DPNPLAYER_LOCAL)
{
m_playerLocal = pCreatePlayerMsg->dpnidPlayer; m_playerLocal = pCreatePlayerMsg->dpnidPlayer;
}
else else
{ {
// The first connecting player should be the user // The first connecting player should be the user
if (m_playerUser == 0) if (m_playerUser == 0) { m_playerUser = pCreatePlayerMsg->dpnidPlayer; }
{
m_playerUser = pCreatePlayerMsg->dpnidPlayer;
} }
} }
} }
}
break; break;
} }
@@ -157,7 +150,6 @@ namespace BlackSimPlugin
} }
break; break;
} }
} }
// Directx9 SDK: Unless otherwise noted, this function should return S_OK. // Directx9 SDK: Unless otherwise noted, this function should return S_OK.
@@ -227,10 +219,10 @@ namespace BlackSimPlugin
} }
// There are no items returned so the requested SP is not available // There are no items returned so the requested SP is not available
if (dwItems == 0) hr = E_FAIL; if (dwItems == 0) { hr = E_FAIL; }
if (SUCCEEDED(hr)) return true; if (SUCCEEDED(hr)) { return true; }
else return false; else { return false; }
} }
HRESULT CDirectPlayPeer::createDeviceAddress() HRESULT CDirectPlayPeer::createDeviceAddress()
@@ -270,7 +262,9 @@ namespace BlackSimPlugin
// Set the SP for our Device Address // Set the SP for our Device Address
if (FAILED(hr = m_deviceAddress->SetSP(&CLSID_DP8SP_TCPIP))) if (FAILED(hr = m_deviceAddress->SetSP(&CLSID_DP8SP_TCPIP)))
{
return logDirectPlayError(hr); return logDirectPlayError(hr);
}
return S_OK; return S_OK;
} }
@@ -280,7 +274,7 @@ namespace BlackSimPlugin
HRESULT hr = S_OK; HRESULT hr = S_OK;
DPN_BUFFER_DESC dpBufferDesc; DPN_BUFFER_DESC dpBufferDesc;
if ((dpBufferDesc.dwBufferSize = message.size()) == 0) return S_FALSE; if ((dpBufferDesc.dwBufferSize = message.size()) == 0) { return S_FALSE; }
dpBufferDesc.pBufferData = (BYTE *)message.data(); dpBufferDesc.pBufferData = (BYTE *)message.data();