revert the changes to the old steam interfaces parser

This commit is contained in:
otavepto 2024-04-23 04:37:18 +02:00
parent f8ad4c9f0f
commit ad07ff0fb1
7 changed files with 114 additions and 107 deletions

View File

@ -78,7 +78,7 @@ static ISteamMasterServerUpdater *old_gamserver_masterupdater_instance{};
static void load_old_interface_versions() static void load_old_steam_interfaces()
{ {
static bool loaded = false; static bool loaded = false;
@ -174,7 +174,7 @@ Steam_Client *get_steam_client()
std::lock_guard<std::recursive_mutex> lock(global_mutex); std::lock_guard<std::recursive_mutex> lock(global_mutex);
// if we win the thread arbitration for the first time, this will still be null // if we win the thread arbitration for the first time, this will still be null
if (!steamclient_instance) { if (!steamclient_instance) {
load_old_interface_versions(); load_old_steam_interfaces();
steamclient_instance = new Steam_Client(); steamclient_instance = new Steam_Client();
} }
} }

View File

@ -1284,8 +1284,78 @@ static void parse_simple_features(class Settings *settings_client, class Setting
} }
static std::map<SettingsItf, std::string> old_itfs_map{}; static std::map<SettingsItf, std::string> old_itfs_map{};
static bool try_load_steam_interfaces(std::string interfaces_path)
{
std::ifstream input( utf8_decode(interfaces_path) );
if (!input.is_open()) return false;
PRINT_DEBUG("Trying to parse old steam interfaces from '%s'", interfaces_path.c_str());
for( std::string line; std::getline( input, line ); ) {
line.erase(std::remove(line.begin(), line.end(), ' '), line.end());
line.erase(std::remove(line.begin(), line.end(), '\n'), line.end());
line.erase(std::remove(line.begin(), line.end(), '\r'), line.end());
line.erase(std::remove(line.begin(), line.end(), '\t'), line.end());
PRINT_DEBUG(" line: |%s|", line.c_str());
#define OLD_ITF_LINE(istr, itype) { \
if (line.find(istr) != std::string::npos) { \
old_itfs_map[itype] = line; \
continue; \
} \
}
OLD_ITF_LINE("SteamClient", SettingsItf::CLIENT);
// NOTE: you must try to read the one with the most characters first
OLD_ITF_LINE("SteamGameServerStats", SettingsItf::GAMESERVER_STATS);
OLD_ITF_LINE("SteamGameServer", SettingsItf::GAMESERVER);
// NOTE: you must try to read the one with the most characters first
OLD_ITF_LINE("SteamMatchMakingServers", SettingsItf::MATCHMAKING_SERVERS);
OLD_ITF_LINE("SteamMatchMaking", SettingsItf::MATCHMAKING);
OLD_ITF_LINE("SteamUser", SettingsItf::USER);
OLD_ITF_LINE("SteamFriends", SettingsItf::FRIENDS);
OLD_ITF_LINE("SteamUtils", SettingsItf::UTILS);
OLD_ITF_LINE("STEAMUSERSTATS_INTERFACE_VERSION", SettingsItf::USER_STATS);
OLD_ITF_LINE("STEAMAPPS_INTERFACE_VERSION", SettingsItf::APPS);
OLD_ITF_LINE("SteamNetworking", SettingsItf::NETWORKING);
OLD_ITF_LINE("STEAMREMOTESTORAGE_INTERFACE_VERSION", SettingsItf::REMOTE_STORAGE);
OLD_ITF_LINE("STEAMSCREENSHOTS_INTERFACE_VERSION", SettingsItf::SCREENSHOTS);
OLD_ITF_LINE("STEAMHTTP_INTERFACE_VERSION", SettingsItf::HTTP);
OLD_ITF_LINE("STEAMUNIFIEDMESSAGES_INTERFACE_VERSION", SettingsItf::UNIFIED_MESSAGES);
OLD_ITF_LINE("STEAMCONTROLLER_INTERFACE_VERSION", SettingsItf::CONTROLLER);
OLD_ITF_LINE("SteamController", SettingsItf::CONTROLLER);
OLD_ITF_LINE("STEAMUGC_INTERFACE_VERSION", SettingsItf::UGC);
OLD_ITF_LINE("STEAMAPPLIST_INTERFACE_VERSION", SettingsItf::APPLIST);
OLD_ITF_LINE("STEAMMUSIC_INTERFACE_VERSION", SettingsItf::MUSIC);
OLD_ITF_LINE("STEAMMUSICREMOTE_INTERFACE_VERSION", SettingsItf::MUSIC_REMOTE);
OLD_ITF_LINE("STEAMHTMLSURFACE_INTERFACE_VERSION", SettingsItf::HTML_SURFACE);
OLD_ITF_LINE("STEAMINVENTORY_INTERFACE", SettingsItf::INVENTORY);
OLD_ITF_LINE("STEAMVIDEO_INTERFACE", SettingsItf::VIDEO);
OLD_ITF_LINE("SteamMasterServerUpdater", SettingsItf::MASTERSERVER_UPDATER);
#undef OLD_ITF_LINE
PRINT_DEBUG(" NOT REPLACED |%s|", line.c_str());
}
return true;
}
static void parse_old_steam_interfaces()
{
if (!try_parse_old_steam_interfaces_file(Local_Storage::get_game_settings_path() + "steam_interfaces.txt") &&
!try_parse_old_steam_interfaces_file(Local_Storage::get_program_path() + "steam_interfaces.txt")) {
PRINT_DEBUG("Couldn't load steam_interfaces.txt");
}
}
static void load_all_config_settings() static void load_all_config_settings()
{ {
static std::recursive_mutex ini_mtx{}; static std::recursive_mutex ini_mtx{};
@ -1348,30 +1418,7 @@ static void load_all_config_settings()
} }
} }
old_itfs_map[SettingsItf::CLIENT] = ini.GetValue("app::steam_interfaces", "client", ""); parse_old_steam_interfaces();
old_itfs_map[SettingsItf::GAMESERVER_STATS] = ini.GetValue("app::steam_interfaces", "gameserver_stats", "");
old_itfs_map[SettingsItf::GAMESERVER] = ini.GetValue("app::steam_interfaces", "gameserver", "");
old_itfs_map[SettingsItf::MATCHMAKING_SERVERS] = ini.GetValue("app::steam_interfaces", "matchmaking_servers", "");
old_itfs_map[SettingsItf::MATCHMAKING] = ini.GetValue("app::steam_interfaces", "matchmaking", "");
old_itfs_map[SettingsItf::USER] = ini.GetValue("app::steam_interfaces", "user", "");
old_itfs_map[SettingsItf::FRIENDS] = ini.GetValue("app::steam_interfaces", "friends", "");
old_itfs_map[SettingsItf::UTILS] = ini.GetValue("app::steam_interfaces", "utils", "");
old_itfs_map[SettingsItf::USER_STATS] = ini.GetValue("app::steam_interfaces", "user_stats", "");
old_itfs_map[SettingsItf::APPS] = ini.GetValue("app::steam_interfaces", "apps", "");
old_itfs_map[SettingsItf::NETWORKING] = ini.GetValue("app::steam_interfaces", "networking", "");
old_itfs_map[SettingsItf::REMOTE_STORAGE] = ini.GetValue("app::steam_interfaces", "remote_storage", "");
old_itfs_map[SettingsItf::SCREENSHOTS] = ini.GetValue("app::steam_interfaces", "screenshots", "");
old_itfs_map[SettingsItf::HTTP] = ini.GetValue("app::steam_interfaces", "http", "");
old_itfs_map[SettingsItf::UNIFIED_MESSAGES] = ini.GetValue("app::steam_interfaces", "unified_messages", "");
old_itfs_map[SettingsItf::CONTROLLER] = ini.GetValue("app::steam_interfaces", "controller", "");
old_itfs_map[SettingsItf::UGC] = ini.GetValue("app::steam_interfaces", "ugc", "");
old_itfs_map[SettingsItf::APPLIST] = ini.GetValue("app::steam_interfaces", "applist", "");
old_itfs_map[SettingsItf::MUSIC] = ini.GetValue("app::steam_interfaces", "music", "");
old_itfs_map[SettingsItf::MUSIC_REMOTE] = ini.GetValue("app::steam_interfaces", "music_remote", "");
old_itfs_map[SettingsItf::HTML_SURFACE] = ini.GetValue("app::steam_interfaces", "html_surface", "");
old_itfs_map[SettingsItf::INVENTORY] = ini.GetValue("app::steam_interfaces", "inventory", "");
old_itfs_map[SettingsItf::VIDEO] = ini.GetValue("app::steam_interfaces", "video", "");
old_itfs_map[SettingsItf::MASTERSERVER_UPDATER] = ini.GetValue("app::steam_interfaces", "masterserver_updater", "");
#ifndef EMU_RELEASE_BUILD #ifndef EMU_RELEASE_BUILD
// dump the final ini file // dump the final ini file

View File

@ -7,6 +7,7 @@ See both the regular and experimental readmes for how to configure it.
--- ---
**Note** that all emu config files should be put beside the `steamclient(64).dll`. **Note** that all emu config files should be put beside the `steamclient(64).dll`.
You do not need to create a `steam_interfaces.txt` file for the `steamclient` version of the emu. You do not need to create a `steam_interfaces.txt` file for the `steamclient` version of the emu.
--- ---

View File

@ -1,5 +1,4 @@
# you do not have to specify everything, pick and choose the options you need only # you do not have to specify everything, pick and choose the options you need only
# [app::steam_interfaces] is very important, make sure to always generate this one
[app::general] [app::general]
# allow the app/game to show the correct build id # allow the app/game to show the correct build id
@ -11,32 +10,6 @@ is_beta_branch=0
# the name of the beta branch # the name of the beta branch
branch_name=public branch_name=public
[app::steam_interfaces]
client=SteamClient015
gameserver_stats=SteamGameServerStats001
gameserver=SteamGameServer012
matchmaking_servers=SteamMatchMakingServers002
matchmaking=SteamMatchMaking009
user=SteamUser017
friends=SteamFriends014
utils=SteamUtils007
user_stats=STEAMUSERSTATS_INTERFACE_VERSION011
apps=STEAMAPPS_INTERFACE_VERSION006
networking=SteamNetworking005
remote_storage=STEAMREMOTESTORAGE_INTERFACE_VERSION012
screenshots=STEAMSCREENSHOTS_INTERFACE_VERSION002
http=STEAMHTTP_INTERFACE_VERSION002
unified_messages=STEAMUNIFIEDMESSAGES_INTERFACE_VERSION001
controller=STEAMCONTROLLER_INTERFACE_VERSION
ugc=STEAMUGC_INTERFACE_VERSION002
applist=STEAMAPPLIST_INTERFACE_VERSION001
music=STEAMMUSIC_INTERFACE_VERSION001
music_remote=STEAMMUSICREMOTE_INTERFACE_VERSION001
html_surface=STEAMHTMLSURFACE_INTERFACE_VERSION_003
inventory=STEAMINVENTORY_INTERFACE_V001
video=STEAMVIDEO_INTERFACE_V001
masterserver_updater=SteamMasterServerUpdater001
[app::dlcs] [app::dlcs]
# should the emu report all DLCs as unlocked # should the emu report all DLCs as unlocked
# some games check for "hidden" DLCs, hence this should be set to 1 in that case # some games check for "hidden" DLCs, hence this should be set to 1 in that case

View File

@ -7,48 +7,53 @@
// these are defined in dll.cpp at the top like this: // these are defined in dll.cpp at the top like this:
// static char old_xxx[128] = ... // static char old_xxx[128] = ...
const static std::vector<std::pair<std::string, std::string>> interface_patterns = { const static std::vector<std::string> interface_patterns = {
{ R"(SteamClient\d+)", "client" }, R"(SteamClient\d+)",
{ R"(SteamGameServerStats\d+)", "gameserver_stats" }, R"(SteamGameServerStats\d+)",
{ R"(SteamGameServer\d+)", "gameserver" }, R"(SteamGameServer\d+)",
{ R"(SteamMatchMakingServers\d+)", "matchmaking_servers" }, R"(SteamMatchMakingServers\d+)",
{ R"(SteamMatchMaking\d+)", "matchmaking" }, R"(SteamMatchMaking\d+)",
{ R"(SteamUser\d+)", "user" }, R"(SteamUser\d+)",
{ R"(SteamFriends\d+)", "friends" }, R"(SteamFriends\d+)",
{ R"(SteamUtils\d+)", "utils" }, R"(SteamUtils\d+)",
{ R"(STEAMUSERSTATS_INTERFACE_VERSION\d+)", "user_stats" }, R"(STEAMUSERSTATS_INTERFACE_VERSION\d+)",
{ R"(STEAMAPPS_INTERFACE_VERSION\d+)", "apps" }, R"(STEAMAPPS_INTERFACE_VERSION\d+)",
{ R"(SteamNetworking\d+)", "networking" }, R"(SteamNetworking\d+)",
{ R"(STEAMREMOTESTORAGE_INTERFACE_VERSION\d+)", "remote_storage" }, R"(STEAMREMOTESTORAGE_INTERFACE_VERSION\d+)",
{ R"(STEAMSCREENSHOTS_INTERFACE_VERSION\d+)", "screenshots" }, R"(STEAMSCREENSHOTS_INTERFACE_VERSION\d+)",
{ R"(STEAMHTTP_INTERFACE_VERSION\d+)", "http" }, R"(STEAMHTTP_INTERFACE_VERSION\d+)",
{ R"(STEAMUNIFIEDMESSAGES_INTERFACE_VERSION\d+)", "unified_messages" }, R"(STEAMUNIFIEDMESSAGES_INTERFACE_VERSION\d+)",
{ R"(STEAMCONTROLLER_INTERFACE_VERSION\d+)", "controller" }, R"(STEAMCONTROLLER_INTERFACE_VERSION\d+)",
{ R"(SteamController\d+)", "controller" }, R"(SteamController\d+)",
{ R"(STEAMUGC_INTERFACE_VERSION\d+)", "ugc" }, R"(STEAMUGC_INTERFACE_VERSION\d+)",
{ R"(STEAMAPPLIST_INTERFACE_VERSION\d+)", "applist" }, R"(STEAMAPPLIST_INTERFACE_VERSION\d+)",
{ R"(STEAMMUSIC_INTERFACE_VERSION\d+)", "music" }, R"(STEAMMUSIC_INTERFACE_VERSION\d+)",
{ R"(STEAMMUSICREMOTE_INTERFACE_VERSION\d+)", "music_remote" }, R"(STEAMMUSICREMOTE_INTERFACE_VERSION\d+)",
{ R"(STEAMHTMLSURFACE_INTERFACE_VERSION_\d+)", "html_surface" }, R"(STEAMHTMLSURFACE_INTERFACE_VERSION_\d+)",
{ R"(STEAMINVENTORY_INTERFACE_V\d+)", "inventory" }, R"(STEAMINVENTORY_INTERFACE_V\d+)",
{ R"(STEAMVIDEO_INTERFACE_V\d+)", "video" }, R"(STEAMVIDEO_INTERFACE_V\d+)",
{ R"(SteamMasterServerUpdater\d+)", "masterserver_updater" }, R"(SteamMasterServerUpdater\d+)",
}; };
unsigned int findinterface(std::ofstream &out_file, const std::string &file_contents, const std::pair<std::string, std::string> &interface_patt) unsigned int findinterface(
std::ofstream &out_file,
const std::string &file_contents,
const std::string &interface_patt)
{ {
std::regex interface_regex(interface_patt.first); std::regex interface_regex(interface_patt);
auto begin = std::sregex_iterator(file_contents.begin(), file_contents.end(), interface_regex); auto begin = std::sregex_iterator(file_contents.begin(), file_contents.end(), interface_regex);
auto end = std::sregex_iterator(); auto end = std::sregex_iterator();
unsigned int matches = 0; unsigned int matches = 0;
for (std::sregex_iterator itr = begin; itr != end; ++itr) { for (std::sregex_iterator i = begin; i != end; ++i) {
out_file << interface_patt.second << "=" << itr->str() << std::endl; std::smatch match = *i;
std::string match_str = match.str();
out_file << match_str << std::endl;
++matches; ++matches;
} }
@ -73,23 +78,21 @@ int main (int argc, char *argv[])
std::istreambuf_iterator<char>()); std::istreambuf_iterator<char>());
steam_api_file.close(); steam_api_file.close();
if (steam_api_contents.empty()) { if (steam_api_contents.size() == 0) {
std::cerr << "Error loading data" << std::endl; std::cerr << "Error loading data" << std::endl;
return 1; return 1;
} }
unsigned int total_matches = 0; unsigned int total_matches = 0;
std::ofstream out_file("configs.app.ini"); std::ofstream out_file("steam_interfaces.txt");
if (!out_file.is_open()) { if (!out_file.is_open()) {
std::cerr << "Error opening output file" << std::endl; std::cerr << "Error opening output file" << std::endl;
return 1; return 1;
} }
out_file << "[app::steam_interfaces]" << std::endl;
for (const auto &patt : interface_patterns) { for (const auto &patt : interface_patterns) {
total_matches += findinterface(out_file, steam_api_contents, patt); total_matches += findinterface(out_file, steam_api_contents, patt);
} }
out_file << std::endl;
out_file.close(); out_file.close();
if (total_matches == 0) { if (total_matches == 0) {

View File

@ -64,18 +64,6 @@ itf_patts = [
( r'SteamMasterServerUpdater\d+', "masterserver_updater" ), ( r'SteamMasterServerUpdater\d+', "masterserver_updater" ),
] ]
def add_itf_line(itf: str, out_dict_ini: dict):
for itf_patt in itf_patts:
if re.match(itf_patt[0], itf):
merge_dict(out_dict_ini, {
'configs.app.ini': {
'app::steam_interfaces': {
itf_patt[1]: (itf, ''),
},
}
})
return
def main(): def main():
is_windows = platform.system().lower() == "windows" is_windows = platform.system().lower() == "windows"
@ -216,11 +204,6 @@ def main():
}, },
} }
}) })
elif file == 'steam_interfaces.txt':
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
itf_lines = [lll.strip() for lll in fr.readlines() if lll.strip()]
for itf in itf_lines:
add_itf_line(itf, out_dict_ini)
elif file == 'overlay_hook_delay_sec.txt': elif file == 'overlay_hook_delay_sec.txt':
with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr: with open(os.path.join(global_settings, file), "r", encoding='utf-8') as fr:
merge_dict(out_dict_ini, { merge_dict(out_dict_ini, {