Don't memset the whole connection status structs to zero.

Some games pass smaller versions of the struct.
This commit is contained in:
Mr_Goldberg 2021-04-18 22:36:48 -04:00
parent 19015c097c
commit b8eae2b709
No known key found for this signature in database
GPG Key ID: 8597D87419DEF278
1 changed files with 14 additions and 3 deletions

View File

@ -882,17 +882,20 @@ bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo_t *pIn
auto connect_socket = connect_sockets.find(hConn);
if (connect_socket == connect_sockets.end()) return false;
memset(pInfo, 0, sizeof(SteamNetConnectionInfo_t));
pInfo->m_identityRemote = connect_socket->second.remote_identity;
pInfo->m_nUserData = connect_socket->second.user_data;
pInfo->m_hListenSocket = connect_socket->second.listen_socket_id;
//pInfo->m_addrRemote; //TODO
pInfo->m_addrRemote.Clear(); //TODO
pInfo->m_idPOPRemote = 0;
pInfo->m_idPOPRelay = 0;
pInfo->m_eState = convert_status(connect_socket->second.status);
pInfo->m_eEndReason = 0; //TODO
pInfo->m_szEndDebug[0] = 0;
sprintf(pInfo->m_szConnectionDescription, "%u", hConn);
//Note some games might not allocate a struct the whole size of SteamNetConnectionInfo_t
//keep this in mind in future interface updates
return true;
}
@ -954,13 +957,21 @@ bool GetQuickConnectionStatus( HSteamNetConnection hConn, SteamNetworkingQuickCo
std::lock_guard<std::recursive_mutex> lock(global_mutex);
auto connect_socket = connect_sockets.find(hConn);
if (connect_socket == connect_sockets.end()) return false;
memset(pStats, 0, sizeof(SteamNetworkingQuickConnectionStatus));
pStats->m_eState = convert_status(connect_socket->second.status);
pStats->m_nPing = 10; //TODO: calculate real numbers?
pStats->m_flConnectionQualityLocal = 1.0;
pStats->m_flConnectionQualityRemote = 1.0;
//TODO: rest
pStats->m_flOutPacketsPerSec = 0.0;
pStats->m_flOutBytesPerSec = 0.0;
pStats->m_flInPacketsPerSec = 0.0;
pStats->m_flInBytesPerSec = 0.0;
pStats->m_cbSentUnackedReliable = 0.0;
pStats->m_usecQueueTime = 0.0;
//Note some games (volcanoids) might not allocate a struct the whole size of SteamNetworkingQuickConnectionStatus
//keep this in mind in future interface updates
return true;
}