From a0648d454cc55a0b4ce97a8bcf7b273e5b74fd3d Mon Sep 17 00:00:00 2001 From: Mr_Goldberg Date: Sat, 20 Jun 2020 21:15:26 -0400 Subject: [PATCH] Add a way to set subscribed groups. --- Readme_release.txt | 4 ++++ dll/settings.h | 3 +++ dll/settings_parser.cpp | 22 +++++++++++++++++++ dll/steam_friends.h | 4 ++++ .../subscribed_groups.EXAMPLE.txt | 4 ++++ 5 files changed, 37 insertions(+) create mode 100644 files_example/steam_settings.EXAMPLE/subscribed_groups.EXAMPLE.txt diff --git a/Readme_release.txt b/Readme_release.txt index b4d573d..37b6926 100644 --- a/Readme_release.txt +++ b/Readme_release.txt @@ -48,6 +48,10 @@ Depots: This is pretty rare but some games might use depot ids to see if dlcs are installed. You can provide a list of installed depots to the game with a steam_settings\depots.txt file. See the steam_settings.EXAMPLE folder for an example. +Subscribed Groups: +Some games like payday 2 check which groups you are subscribed in and unlock things based on that. You can provide a list of subscribed groups to the game with a steam_settings\subscribed_groups.txt file. +See steam_settings.EXAMPLE\subscribed_groups.EXAMPLE.txt for an example for payday 2. + App paths: Some rare games might need to be provided one or more paths to app ids. For example the path to where a dlc is installed. This sets the paths returned by the Steam_Apps::GetAppInstallDir function. See steam_settings.EXAMPLE\app_paths.EXAMPLE.txt for an example. diff --git a/dll/settings.h b/dll/settings.h index 225d268..ce4bb76 100644 --- a/dll/settings.h +++ b/dll/settings.h @@ -132,6 +132,9 @@ public: std::map getStats() { return stats; } void setStatDefiniton(std::string name, struct Stat_config stat_config) {stats[name] = stat_config; } + //subscribed lobby/group ids + std::set subscribed_groups; + //images std::map images; int add_image(std::string data, uint32 width, uint32 height); diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index 38484c2..a68d291 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -511,6 +511,28 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s } } + { + std::string depots_config_path = Local_Storage::get_game_settings_path() + "subscribed_groups.txt"; + std::ifstream input( depots_config_path ); + if (input.is_open()) { + consume_bom(input); + for( std::string line; getline( input, line ); ) { + if (!line.empty() && line[line.length()-1] == '\n') { + line.pop_back(); + } + + if (!line.empty() && line[line.length()-1] == '\r') { + line.pop_back(); + } + + uint64 source_id = stoull(line); + settings_client->subscribed_groups.insert(source_id); + settings_server->subscribed_groups.insert(source_id); + PRINT_DEBUG("Added source %llu\n", source_id); + } + } + } + { std::string mod_path = Local_Storage::get_game_settings_path() + "mods"; std::vector paths = Local_Storage::get_filenames_path(mod_path); diff --git a/dll/steam_friends.h b/dll/steam_friends.h index 1d91712..788dec4 100644 --- a/dll/steam_friends.h +++ b/dll/steam_friends.h @@ -502,6 +502,10 @@ bool IsUserInSource( CSteamID steamIDUser, CSteamID steamIDSource ) if (settings->get_lobby() == steamIDSource) { return true; } + + if (settings->subscribed_groups.find(steamIDSource.ConvertToUint64()) != settings->subscribed_groups.end()) { + return true; + } } else { Friend *f = find_friend(steamIDUser); if (!f) return false; diff --git a/files_example/steam_settings.EXAMPLE/subscribed_groups.EXAMPLE.txt b/files_example/steam_settings.EXAMPLE/subscribed_groups.EXAMPLE.txt new file mode 100644 index 0000000..6e883bf --- /dev/null +++ b/files_example/steam_settings.EXAMPLE/subscribed_groups.EXAMPLE.txt @@ -0,0 +1,4 @@ +103582791433980119 +103582791438562929 +103582791441335905 +103582791460014708