Compare commits

...

3 Commits

Author SHA1 Message Date
Mr_Goldberg eda9abd2aa
Fix linux CI build. 2022-01-26 03:07:49 -05:00
Mr_Goldberg f852e5c272
steam_interfaces.txt can now be put in the steam_settings folder. 2022-01-26 01:52:21 -05:00
Mr_Goldberg 0a5f136bc3
Fix games that use the ip and port to identify socket connections. 2022-01-26 01:51:55 -05:00
2 changed files with 39 additions and 21 deletions

View File

@ -44,12 +44,13 @@ static char old_inventory[128] = "STEAMINVENTORY_INTERFACE_V001";
static char old_video[128] = "STEAMVIDEO_INTERFACE_V001"; static char old_video[128] = "STEAMVIDEO_INTERFACE_V001";
static char old_masterserver_updater[128] = "SteamMasterServerUpdater001"; static char old_masterserver_updater[128] = "SteamMasterServerUpdater001";
static void load_old_interface_versions() static bool try_load_steam_interfaces(std::string interfaces_path)
{ {
static bool loaded = false;
if (loaded) return;
std::string interfaces_path = Local_Storage::get_program_path() + "steam_interfaces.txt";
std::ifstream input( utf8_decode(interfaces_path) ); std::ifstream input( utf8_decode(interfaces_path) );
if (!input.is_open()) {
return false;
}
PRINT_DEBUG("load from: %s\n", interfaces_path.c_str()); PRINT_DEBUG("load from: %s\n", interfaces_path.c_str());
for( std::string line; getline( input, line ); ) for( std::string line; getline( input, line ); )
@ -83,6 +84,17 @@ static void load_old_interface_versions()
#undef REPLACE_WITH_FILE #undef REPLACE_WITH_FILE
} }
return true;
}
static void load_old_interface_versions()
{
static bool loaded = false;
if (loaded) return;
if (!try_load_steam_interfaces(Local_Storage::get_game_settings_path() + "steam_interfaces.txt"))
try_load_steam_interfaces(Local_Storage::get_program_path() + "steam_interfaces.txt");
PRINT_DEBUG("client: %s\n", old_client); PRINT_DEBUG("client: %s\n", old_client);
PRINT_DEBUG("gameserver: %s\n", old_gameserver); PRINT_DEBUG("gameserver: %s\n", old_gameserver);
PRINT_DEBUG("gameserver stats: %s\n", old_gameserver_stats); PRINT_DEBUG("gameserver stats: %s\n", old_gameserver_stats);

View File

@ -210,6 +210,27 @@ ESteamNetworkingConnectionState convert_status(enum connect_socket_status old_st
return k_ESteamNetworkingConnectionState_None; return k_ESteamNetworkingConnectionState_None;
} }
void set_steamnetconnectioninfo(std::map<HSteamNetConnection, Connect_Socket>::iterator connect_socket, SteamNetConnectionInfo_t *pInfo)
{
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.Clear(); //TODO
if (connect_socket->second.real_port != SNS_DISABLED_PORT) {
pInfo->m_addrRemote.SetIPv4(network->getIP(connect_socket->second.remote_identity.GetSteamID()), connect_socket->first);
}
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", connect_socket->first);
//Note some games might not allocate a struct the whole size of SteamNetConnectionInfo_t when calling GetConnectionInfo
//keep this in mind in future interface updates
}
void launch_callback(HSteamNetConnection m_hConn, enum connect_socket_status old_status) void launch_callback(HSteamNetConnection m_hConn, enum connect_socket_status old_status)
{ {
auto connect_socket = connect_sockets.find(m_hConn); auto connect_socket = connect_sockets.find(m_hConn);
@ -217,14 +238,8 @@ void launch_callback(HSteamNetConnection m_hConn, enum connect_socket_status old
struct SteamNetConnectionStatusChangedCallback_t data = {}; struct SteamNetConnectionStatusChangedCallback_t data = {};
data.m_hConn = connect_socket->first; data.m_hConn = connect_socket->first;
data.m_info.m_identityRemote = connect_socket->second.remote_identity;
data.m_info.m_hListenSocket = connect_socket->second.listen_socket_id;
data.m_info.m_nUserData = connect_socket->second.user_data;
//TODO
//m_addrRemote
//m_eEndReason
data.m_info.m_eState = convert_status(connect_socket->second.status);
data.m_eOldState = convert_status(old_status); data.m_eOldState = convert_status(old_status);
set_steamnetconnectioninfo(connect_socket, &data.m_info);
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
} }
@ -883,16 +898,7 @@ bool GetConnectionInfo( HSteamNetConnection hConn, SteamNetConnectionInfo_t *pIn
auto connect_socket = connect_sockets.find(hConn); auto connect_socket = connect_sockets.find(hConn);
if (connect_socket == connect_sockets.end()) return false; if (connect_socket == connect_sockets.end()) return false;
pInfo->m_identityRemote = connect_socket->second.remote_identity; set_steamnetconnectioninfo(connect_socket, pInfo);
pInfo->m_nUserData = connect_socket->second.user_data;
pInfo->m_hListenSocket = connect_socket->second.listen_socket_id;
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 //Note some games might not allocate a struct the whole size of SteamNetConnectionInfo_t
//keep this in mind in future interface updates //keep this in mind in future interface updates