Skip to content

Commit fd62410

Browse files
authored
Merge pull request #450 from Detanup01/socket-connInfo-fix
Minimal Socket fixes
2 parents 96a8829 + d0bb072 commit fd62410

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

dll/dll/steam_networking_sockets.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public ISteamNetworkingSockets
115115
ESteamNetworkingConnectionState convert_status(enum connect_socket_status old_status);
116116

117117
void set_steamnetconnectioninfo(std::map<HSteamNetConnection, Connect_Socket>::iterator connect_socket, SteamNetConnectionInfo_t *pInfo);
118+
void set_steamnetconnectioninfo_001(std::map<HSteamNetConnection, Connect_Socket>::iterator connect_socket, SteamNetConnectionInfo001_t* pInfo);
119+
118120

119121
void launch_callback(HSteamNetConnection m_hConn, enum connect_socket_status old_status);
120122

dll/steam_networking_sockets.cpp

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ void Steam_Networking_Sockets::set_steamnetconnectioninfo(std::map<HSteamNetConn
187187
pInfo->m_hListenSocket = connect_socket->second.listen_socket_id;
188188
pInfo->m_addrRemote.Clear(); //TODO
189189
if (connect_socket->second.real_port != SNS_DISABLED_PORT) {
190-
pInfo->m_addrRemote.SetIPv4(network->getIP(connect_socket->second.remote_identity.GetSteamID()), connect_socket->first);
190+
pInfo->m_addrRemote.SetIPv4(network->getIP(connect_socket->second.remote_identity.GetSteamID()), connect_socket->second.real_port);
191191
}
192192

193193
pInfo->m_idPOPRemote = 0;
@@ -201,6 +201,25 @@ void Steam_Networking_Sockets::set_steamnetconnectioninfo(std::map<HSteamNetConn
201201
//keep this in mind in future interface updates
202202
}
203203

204+
void Steam_Networking_Sockets::set_steamnetconnectioninfo_001(std::map<HSteamNetConnection, Connect_Socket>::iterator connect_socket, SteamNetConnectionInfo001_t* pInfo)
205+
{
206+
pInfo->m_steamIDRemote = connect_socket->second.remote_identity.GetSteamID();
207+
pInfo->m_nUserData = connect_socket->second.user_data;
208+
pInfo->m_hListenSocket = connect_socket->second.listen_socket_id;
209+
if (connect_socket->second.real_port != SNS_DISABLED_PORT) {
210+
pInfo->m_unIPRemote = network->getIP(connect_socket->second.remote_identity.GetSteamID());
211+
pInfo->m_unPortRemote = connect_socket->second.real_port;
212+
}
213+
214+
pInfo->m_idPOPRemote = 0;
215+
pInfo->m_idPOPRelay = 0;
216+
pInfo->m_eState = convert_status(connect_socket->second.status);
217+
pInfo->m_eEndReason = 0; //TODO
218+
pInfo->m_szEndDebug[0] = 0;
219+
//Note some games might not allocate a struct the whole size of SteamNetConnectionInfo_t when calling GetConnectionInfo
220+
//keep this in mind in future interface updates
221+
}
222+
204223
void Steam_Networking_Sockets::launch_callback(HSteamNetConnection m_hConn, enum connect_socket_status old_status)
205224
{
206225
auto connect_socket = sbcs->connect_sockets.find(m_hConn);
@@ -576,7 +595,7 @@ bool Steam_Networking_Sockets::CloseListenSocket( HSteamListenSocket hSocket, co
576595
{
577596
PRINT_DEBUG("old");
578597
std::lock_guard<std::recursive_mutex> lock(global_mutex);
579-
return false;
598+
return CloseListenSocket(hSocket);
580599
}
581600

582601
/// Destroy a listen socket. All the connections that were accepting on the listen
@@ -892,7 +911,7 @@ int Steam_Networking_Sockets::ReceiveMessagesOnListenSocket( HSteamListenSocket
892911
/// Returns basic information about the high-level state of the connection.
893912
bool Steam_Networking_Sockets::GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo_t *pInfo )
894913
{
895-
PRINT_DEBUG_ENTRY();
914+
PRINT_DEBUG("%u %i", hConn, pInfo == NULL);
896915
std::lock_guard<std::recursive_mutex> lock(global_mutex);
897916
if (!pInfo) return false;
898917

@@ -993,9 +1012,16 @@ int Steam_Networking_Sockets::ReceiveMessagesOnListenSocket( HSteamListenSocket
9931012
/// Returns information about the specified connection.
9941013
bool Steam_Networking_Sockets::GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo001_t *pInfo )
9951014
{
996-
PRINT_DEBUG_TODO();
1015+
PRINT_DEBUG("001 %u %i", hConn, pInfo == NULL);
9971016
std::lock_guard<std::recursive_mutex> lock(global_mutex);
998-
return false;
1017+
1018+
if (!pInfo) return false;
1019+
1020+
auto connect_socket = sbcs->connect_sockets.find(hConn);
1021+
if (connect_socket == sbcs->connect_sockets.end()) return false;
1022+
1023+
set_steamnetconnectioninfo_001(connect_socket, pInfo);
1024+
return true;
9991025
}
10001026

10011027

0 commit comments

Comments
 (0)