diff --git a/dll/dll/settings.h b/dll/dll/settings.h index 5189a604..17ca03d5 100644 --- a/dll/dll/settings.h +++ b/dll/dll/settings.h @@ -174,14 +174,20 @@ class Settings { std::string language{}; // default "english" CSteamID lobby_id = k_steamIDNil; - bool unlockAllDLCs = true; bool offline = false; + uint16 port{}; // Listen port, default 47584 + + bool unlockAllDLCs = true; std::vector DLCs{}; - std::vector mods{}; + + //installed app ids, Steam_Apps::BIsAppInstalled() + bool assume_any_app_installed = true; + std::set installed_app_ids{}; + std::map app_paths{}; + std::vector mods{}; std::map leaderboards{}; std::map stats{}; - uint16 port{}; // Listen port, default 47584 //supported languages std::set supported_languages_set{}; @@ -231,6 +237,9 @@ public: // setting this env var conflicts with Steam Input bool disable_steamoverlaygameid_env_var = false; + // enable owning Steam Applications IDs (mostly builtin apps + dedicated servers) + bool enable_builtin_preowned_ids = false; + std::map images{}; //subscribed lobby/group ids @@ -248,9 +257,6 @@ public: struct Controller_Settings controller_settings{}; std::string glyphs_directory{}; - //installed app ids, Steam_Apps::BIsAppInstalled() - std::set installed_app_ids{}; - bool assume_any_app_installed = true; // allow Steam_User_Stats::FindLeaderboard() to always succeed and create the given unknown leaderboard bool disable_leaderboards_create_unknown = false; @@ -312,12 +318,14 @@ public: //DLC stuff void unlockAllDLC(bool value); void addDLC(AppId_t appID, std::string name, bool available); - unsigned int DLCCount(); + unsigned int DLCCount() const; bool hasDLC(AppId_t appID); bool getDLC(unsigned int index, AppId_t &appID, bool &available, std::string &name); - bool allDLCUnlocked() const; - // add Steam Applications IDS (mostly builtin apps + dedicated servers) to the list - void addSteamPreownedIds(); + + //installed apps, used by Steam_Apps::BIsAppInstalled() + void assumeAnyAppInstalled(bool val); + void addInstalledApp(AppId_t appID); + bool isAppInstalled(AppId_t appID) const; //App Install paths void setAppInstallPath(AppId_t appID, const std::string &path); @@ -341,8 +349,6 @@ public: //images int add_image(const std::string &data, uint32 width, uint32 height); - bool appIsInstalled(AppId_t appID); - // overlay auto accept stuff void acceptAnyOverlayInvites(bool value); void addFriendToOverlayAutoAccept(uint64_t friend_id); diff --git a/dll/settings.cpp b/dll/settings.cpp index 86a1766a..f2ed6330 100644 --- a/dll/settings.cpp +++ b/dll/settings.cpp @@ -171,27 +171,6 @@ void Settings::set_port(uint16 port) this->port = port; } -void Settings::unlockAllDLC(bool value) -{ - this->unlockAllDLCs = value; -} - -void Settings::addDLC(AppId_t appID, std::string name, bool available) -{ - auto f = std::find_if(DLCs.begin(), DLCs.end(), [&appID](DLC_entry const& item) { return item.appID == appID; }); - if (DLCs.end() != f) { - f->name = name; - f->available = available; - return; - } - - DLC_entry new_entry; - new_entry.appID = appID; - new_entry.name = name; - new_entry.available = available; - DLCs.push_back(new_entry); -} - void Settings::addMod(PublishedFileId_t id, const std::string &title, const std::string &path) { auto f = std::find_if(mods.begin(), mods.end(), [&id](Mod_entry const& item) { return item.id == id; }); @@ -269,9 +248,30 @@ std::set Settings::modSet() return ret_set; } -unsigned int Settings::DLCCount() +void Settings::unlockAllDLC(bool value) { - return this->DLCs.size(); + this->unlockAllDLCs = value; +} + +void Settings::addDLC(AppId_t appID, std::string name, bool available) +{ + auto f = std::find_if(DLCs.begin(), DLCs.end(), [&appID](DLC_entry const& item) { return item.appID == appID; }); + if (DLCs.end() != f) { + f->name = name; + f->available = available; + return; + } + + DLC_entry new_entry{}; + new_entry.appID = appID; + new_entry.name = name; + new_entry.available = available; + DLCs.push_back(new_entry); +} + +unsigned int Settings::DLCCount() const +{ + return static_cast(this->DLCs.size()); } bool Settings::hasDLC(AppId_t appID) @@ -279,10 +279,11 @@ bool Settings::hasDLC(AppId_t appID) if (this->unlockAllDLCs) return true; auto f = std::find_if(DLCs.begin(), DLCs.end(), [&appID](DLC_entry const& item) { return item.appID == appID; }); - if (DLCs.end() == f) - return false; + if (DLCs.end() != f) return f->available; - return f->available; + if (enable_builtin_preowned_ids && steam_preowned_app_ids.count(appID)) return true; + + return false; } bool Settings::getDLC(unsigned int index, AppId_t &appID, bool &available, std::string &name) @@ -295,17 +296,23 @@ bool Settings::getDLC(unsigned int index, AppId_t &appID, bool &available, std:: return true; } -bool Settings::allDLCUnlocked() const +void Settings::assumeAnyAppInstalled(bool val) { - return this->unlockAllDLCs; + assume_any_app_installed = val; } -void Settings::addSteamPreownedIds() +void Settings::addInstalledApp(AppId_t appID) { - for (const auto &id_pair : steam_preowned_app_ids) { - addDLC(id_pair.first, id_pair.second, true); - installed_app_ids.insert(id_pair.first); - } + installed_app_ids.insert(appID); +} + +bool Settings::isAppInstalled(AppId_t appID) const +{ + if (assume_any_app_installed) return true; + if (installed_app_ids.count(appID)) return true; + if (enable_builtin_preowned_ids && steam_preowned_app_ids.count(appID)) return true; + + return false; } void Settings::setAppInstallPath(AppId_t appID, const std::string &path) @@ -354,13 +361,6 @@ int Settings::add_image(const std::string &data, uint32 width, uint32 height) return last; } -bool Settings::appIsInstalled(AppId_t appID) -{ - if (this->assume_any_app_installed) return true; - - return !!installed_app_ids.count(appID); -} - void Settings::acceptAnyOverlayInvites(bool value) { diff --git a/dll/settings_parser.cpp b/dll/settings_parser.cpp index eb3c27e0..d21bbf5c 100644 --- a/dll/settings_parser.cpp +++ b/dll/settings_parser.cpp @@ -866,8 +866,8 @@ static void parse_installed_app_Ids(class Settings *settings_client, class Setti std::string installed_apps_list_path = Local_Storage::get_game_settings_path() + "installed_app_ids.txt"; std::ifstream input( utf8_decode(installed_apps_list_path) ); if (input.is_open()) { - settings_client->assume_any_app_installed = false; - settings_server->assume_any_app_installed = false; + settings_client->assumeAnyAppInstalled(false); + settings_server->assumeAnyAppInstalled(false); PRINT_DEBUG("Limiting/Locking installed apps"); common_helpers::consume_bom(input); for( std::string line; getline( input, line ); ) { @@ -881,14 +881,14 @@ static void parse_installed_app_Ids(class Settings *settings_client, class Setti try { AppId_t app_id = std::stoul(line); - settings_client->installed_app_ids.insert(app_id); - settings_server->installed_app_ids.insert(app_id); + settings_client->addInstalledApp(app_id); + settings_server->addInstalledApp(app_id); PRINT_DEBUG("Added installed app with ID %u", app_id); } catch (...) {} } } else { - settings_client->assume_any_app_installed = true; - settings_server->assume_any_app_installed = true; + settings_client->assumeAnyAppInstalled(true); + settings_server->assumeAnyAppInstalled(true); PRINT_DEBUG("Assuming any app is installed"); } @@ -1212,17 +1212,6 @@ static void parse_overlay_general_config(class Settings *settings_client, class } -// main::misc::disable_steam_preowned_ids -static void parse_steam_preowned_ids(class Settings *settings_client, class Settings *settings_server) -{ - bool disable_steam_preowned_ids = ini.GetBoolValue("main::misc", "disable_steam_preowned_ids", false); - if (!disable_steam_preowned_ids) { - settings_client->addSteamPreownedIds(); - settings_server->addSteamPreownedIds(); - PRINT_DEBUG("added Steam preowned IDs"); - } -} - // mainly enable/disable features static void parse_simple_features(class Settings *settings_client, class Settings *settings_server) { @@ -1295,6 +1284,8 @@ static void parse_simple_features(class Settings *settings_client, class Setting settings_client->disable_steamoverlaygameid_env_var = ini.GetBoolValue("main::misc", "disable_steamoverlaygameid_env_var", settings_client->disable_steamoverlaygameid_env_var); settings_server->disable_steamoverlaygameid_env_var = ini.GetBoolValue("main::misc", "disable_steamoverlaygameid_env_var", settings_server->disable_steamoverlaygameid_env_var); + settings_client->enable_builtin_preowned_ids = ini.GetBoolValue("main::misc", "enable_steam_preowned_ids", settings_client->enable_builtin_preowned_ids); + settings_server->enable_builtin_preowned_ids = ini.GetBoolValue("main::misc", "enable_steam_preowned_ids", settings_server->enable_builtin_preowned_ids); } @@ -1556,7 +1547,6 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s parse_dlc(settings_client, settings_server); parse_installed_app_Ids(settings_client, settings_server); parse_app_paths(settings_client, settings_server, program_path); - parse_steam_preowned_ids(settings_client, settings_server); parse_leaderboards(settings_client, settings_server); parse_stats(settings_client, settings_server); diff --git a/dll/steam_apps.cpp b/dll/steam_apps.cpp index 2b725738..364e5d09 100644 --- a/dll/steam_apps.cpp +++ b/dll/steam_apps.cpp @@ -329,7 +329,7 @@ bool Steam_Apps::BIsAppInstalled( AppId_t appID ) // the docs say that this function won't work on DLCs, but HITMAN 3 uses it on every DLC if (settings->hasDLC(appID)) return true; - return settings->appIsInstalled(appID); + return settings->isAppInstalled(appID); } // returns the SteamID of the original owner. If different from current user, it's borrowed diff --git a/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini b/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini index 833929b6..103aa608 100644 --- a/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini +++ b/post_build/steam_settings.EXAMPLE/configs.main.EXAMPLE.ini @@ -67,4 +67,4 @@ disable_steamoverlaygameid_env_var=0 # https://developer.valvesoftware.com/wiki/Steam_Application_IDs # https://developer.valvesoftware.com/wiki/Dedicated_Servers_List # default=0 -disable_steam_preowned_ids=0 +enable_steam_preowned_ids=0