+ more accurate implementation for BIsAppInstalled, it now rejects uint32_max

+ allow behavior customizization via installed_app_ids.txt config file

+ limit/lock list of installed apps on an empty file (similar to dlc.txt)
This commit is contained in:
otavepto 2023-12-18 05:08:23 +02:00 committed by otavepto
parent 90b403fb3d
commit fa8f594207
5 changed files with 64 additions and 1 deletions

View File

@ -280,3 +280,14 @@ int Settings::add_image(std::string data, uint32 width, uint32 height)
images[last] = dt;
return last;
}
bool Settings::appIsInstalled(AppId_t appID)
{
if (this->assume_any_app_installed) return true;
auto f = std::find_if(installed_app_ids.begin(), installed_app_ids.end(), [&appID](AppId_t const& item) { return item == appID; });
if (installed_app_ids.end() == f)
return false;
return true;
}

View File

@ -206,6 +206,11 @@ public:
int add_image(std::string data, uint32 width, uint32 height);
bool disable_account_avatar = false;
//installed app ids, Steam_Apps::BIsAppInstalled()
std::set<AppId_t> installed_app_ids;
bool assume_any_app_installed = true;
bool appIsInstalled(AppId_t appID);
//controller
struct Controller_Settings controller_settings;
std::string glyphs_directory;

View File

@ -805,6 +805,37 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
}
}
{
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;
PRINT_DEBUG("Limiting/Locking installed apps\n");
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();
}
try {
AppId_t app_id = std::stoul(line);
settings_client->installed_app_ids.insert(app_id);
settings_server->installed_app_ids.insert(app_id);
PRINT_DEBUG("Added installed app with ID %u\n", app_id);
} catch (...) {}
}
} else {
settings_client->assume_any_app_installed = true;
settings_server->assume_any_app_installed = true;
PRINT_DEBUG("Assuming any app is installed\n");
}
}
load_subscribed_groups_clans(local_storage->get_global_settings_path() + "subscribed_groups_clans.txt", settings_client, settings_server);
load_subscribed_groups_clans(Local_Storage::get_game_settings_path() + "subscribed_groups_clans.txt", settings_client, settings_server);

View File

@ -240,10 +240,18 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
}
// returns true if that app is installed (not necessarily owned)
// "This only works for base applications, not Downloadable Content (DLC). Use BIsDlcInstalled for DLC instead"
// https://partner.steamgames.com/doc/api/ISteamApps
bool Steam_Apps::BIsAppInstalled( AppId_t appID )
{
PRINT_DEBUG("BIsAppInstalled %u\n", appID);
return true;
// is this true? it seems to indicate a non-steam game
if (appID == 0) return true;
// game LEGO® 2K Drive (app id 1451810) checks for a proper steam behavior by sending uint32_max and expects false in return
if (appID == UINT32_MAX) return false;
if (appID == settings->get_local_game_id().AppID()) return true;
return settings->appIsInstalled(appID);
}
// returns the SteamID of the original owner. If different from current user, it's borrowed

View File

@ -0,0 +1,8 @@
1. Rename this to: installed_app_ids.txt
2. Add all apps IDs (each on a separate line) that should be reported as insatlled, they could be NOT owned, that is allowed
3. Or, remove the file installed_app_ids.txt if it exists to:
* Allow app ID 0, this seems to be a special denotation to "non-steam apps"
* Allow app ID of the current game (you must create the file steam_appid.txt)
* Allow anything else
In all cases app ID 4294967295 is disallowed