* don't merge steam preowned ids with user dlc list or installed apps list

* disable steam preowned ids by default and make it an opt-in option
* deprecate `disable_steam_preowned_ids` in favor of `enable_steam_preowned_ids`
This commit is contained in:
otavepto 2024-04-27 23:19:10 +03:00 committed by otavepto
parent 9f1e09b97a
commit 303cdd2878
5 changed files with 68 additions and 72 deletions

View File

@ -174,14 +174,20 @@ class Settings {
std::string language{}; // default "english" std::string language{}; // default "english"
CSteamID lobby_id = k_steamIDNil; CSteamID lobby_id = k_steamIDNil;
bool unlockAllDLCs = true;
bool offline = false; bool offline = false;
uint16 port{}; // Listen port, default 47584
bool unlockAllDLCs = true;
std::vector<struct DLC_entry> DLCs{}; std::vector<struct DLC_entry> DLCs{};
std::vector<struct Mod_entry> mods{};
//installed app ids, Steam_Apps::BIsAppInstalled()
bool assume_any_app_installed = true;
std::set<AppId_t> installed_app_ids{};
std::map<AppId_t, std::string> app_paths{}; std::map<AppId_t, std::string> app_paths{};
std::vector<struct Mod_entry> mods{};
std::map<std::string, Leaderboard_config> leaderboards{}; std::map<std::string, Leaderboard_config> leaderboards{};
std::map<std::string, Stat_config> stats{}; std::map<std::string, Stat_config> stats{};
uint16 port{}; // Listen port, default 47584
//supported languages //supported languages
std::set<std::string> supported_languages_set{}; std::set<std::string> supported_languages_set{};
@ -231,6 +237,9 @@ public:
// setting this env var conflicts with Steam Input // setting this env var conflicts with Steam Input
bool disable_steamoverlaygameid_env_var = false; bool disable_steamoverlaygameid_env_var = false;
// enable owning Steam Applications IDs (mostly builtin apps + dedicated servers)
bool enable_builtin_preowned_ids = false;
std::map<int, struct Image_Data> images{}; std::map<int, struct Image_Data> images{};
//subscribed lobby/group ids //subscribed lobby/group ids
@ -248,9 +257,6 @@ public:
struct Controller_Settings controller_settings{}; struct Controller_Settings controller_settings{};
std::string glyphs_directory{}; std::string glyphs_directory{};
//installed app ids, Steam_Apps::BIsAppInstalled()
std::set<AppId_t> installed_app_ids{};
bool assume_any_app_installed = true;
// allow Steam_User_Stats::FindLeaderboard() to always succeed and create the given unknown leaderboard // allow Steam_User_Stats::FindLeaderboard() to always succeed and create the given unknown leaderboard
bool disable_leaderboards_create_unknown = false; bool disable_leaderboards_create_unknown = false;
@ -312,12 +318,14 @@ public:
//DLC stuff //DLC stuff
void unlockAllDLC(bool value); void unlockAllDLC(bool value);
void addDLC(AppId_t appID, std::string name, bool available); void addDLC(AppId_t appID, std::string name, bool available);
unsigned int DLCCount(); unsigned int DLCCount() const;
bool hasDLC(AppId_t appID); bool hasDLC(AppId_t appID);
bool getDLC(unsigned int index, AppId_t &appID, bool &available, std::string &name); 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 //installed apps, used by Steam_Apps::BIsAppInstalled()
void addSteamPreownedIds(); void assumeAnyAppInstalled(bool val);
void addInstalledApp(AppId_t appID);
bool isAppInstalled(AppId_t appID) const;
//App Install paths //App Install paths
void setAppInstallPath(AppId_t appID, const std::string &path); void setAppInstallPath(AppId_t appID, const std::string &path);
@ -341,8 +349,6 @@ public:
//images //images
int add_image(const std::string &data, uint32 width, uint32 height); int add_image(const std::string &data, uint32 width, uint32 height);
bool appIsInstalled(AppId_t appID);
// overlay auto accept stuff // overlay auto accept stuff
void acceptAnyOverlayInvites(bool value); void acceptAnyOverlayInvites(bool value);
void addFriendToOverlayAutoAccept(uint64_t friend_id); void addFriendToOverlayAutoAccept(uint64_t friend_id);

View File

@ -171,27 +171,6 @@ void Settings::set_port(uint16 port)
this->port = 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) 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; }); auto f = std::find_if(mods.begin(), mods.end(), [&id](Mod_entry const& item) { return item.id == id; });
@ -269,9 +248,30 @@ std::set<PublishedFileId_t> Settings::modSet()
return ret_set; 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<unsigned int>(this->DLCs.size());
} }
bool Settings::hasDLC(AppId_t appID) bool Settings::hasDLC(AppId_t appID)
@ -279,10 +279,11 @@ bool Settings::hasDLC(AppId_t appID)
if (this->unlockAllDLCs) return true; if (this->unlockAllDLCs) return true;
auto f = std::find_if(DLCs.begin(), DLCs.end(), [&appID](DLC_entry const& item) { return item.appID == appID; }); auto f = std::find_if(DLCs.begin(), DLCs.end(), [&appID](DLC_entry const& item) { return item.appID == appID; });
if (DLCs.end() == f) if (DLCs.end() != f) return f->available;
return false;
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) 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; 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) { installed_app_ids.insert(appID);
addDLC(id_pair.first, id_pair.second, true);
installed_app_ids.insert(id_pair.first);
} }
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) 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; 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) void Settings::acceptAnyOverlayInvites(bool value)
{ {

View File

@ -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::string installed_apps_list_path = Local_Storage::get_game_settings_path() + "installed_app_ids.txt";
std::ifstream input( utf8_decode(installed_apps_list_path) ); std::ifstream input( utf8_decode(installed_apps_list_path) );
if (input.is_open()) { if (input.is_open()) {
settings_client->assume_any_app_installed = false; settings_client->assumeAnyAppInstalled(false);
settings_server->assume_any_app_installed = false; settings_server->assumeAnyAppInstalled(false);
PRINT_DEBUG("Limiting/Locking installed apps"); PRINT_DEBUG("Limiting/Locking installed apps");
common_helpers::consume_bom(input); common_helpers::consume_bom(input);
for( std::string line; getline( input, line ); ) { for( std::string line; getline( input, line ); ) {
@ -881,14 +881,14 @@ static void parse_installed_app_Ids(class Settings *settings_client, class Setti
try { try {
AppId_t app_id = std::stoul(line); AppId_t app_id = std::stoul(line);
settings_client->installed_app_ids.insert(app_id); settings_client->addInstalledApp(app_id);
settings_server->installed_app_ids.insert(app_id); settings_server->addInstalledApp(app_id);
PRINT_DEBUG("Added installed app with ID %u", app_id); PRINT_DEBUG("Added installed app with ID %u", app_id);
} catch (...) {} } catch (...) {}
} }
} else { } else {
settings_client->assume_any_app_installed = true; settings_client->assumeAnyAppInstalled(true);
settings_server->assume_any_app_installed = true; settings_server->assumeAnyAppInstalled(true);
PRINT_DEBUG("Assuming any app is installed"); 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 // mainly enable/disable features
static void parse_simple_features(class Settings *settings_client, class Settings *settings_server) 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_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_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_dlc(settings_client, settings_server);
parse_installed_app_Ids(settings_client, settings_server); parse_installed_app_Ids(settings_client, settings_server);
parse_app_paths(settings_client, settings_server, program_path); parse_app_paths(settings_client, settings_server, program_path);
parse_steam_preowned_ids(settings_client, settings_server);
parse_leaderboards(settings_client, settings_server); parse_leaderboards(settings_client, settings_server);
parse_stats(settings_client, settings_server); parse_stats(settings_client, settings_server);

View File

@ -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 // 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; 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 // returns the SteamID of the original owner. If different from current user, it's borrowed

View File

@ -67,4 +67,4 @@ disable_steamoverlaygameid_env_var=0
# https://developer.valvesoftware.com/wiki/Steam_Application_IDs # https://developer.valvesoftware.com/wiki/Steam_Application_IDs
# https://developer.valvesoftware.com/wiki/Dedicated_Servers_List # https://developer.valvesoftware.com/wiki/Dedicated_Servers_List
# default=0 # default=0
disable_steam_preowned_ids=0 enable_steam_preowned_ids=0