Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dll/dll/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ class Settings {

//App Install paths
void setAppInstallPath(AppId_t appID, const std::string &path);
std::string getAppInstallPath(AppId_t appID);
bool getAppInstallPath(AppId_t appID, std::string &path);

//mod stuff
void addMod(PublishedFileId_t id, const std::string &title, const std::string &path);
Expand Down
11 changes: 9 additions & 2 deletions dll/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,16 @@ void Settings::setAppInstallPath(AppId_t appID, const std::string &path)
app_paths[appID] = path;
}

std::string Settings::getAppInstallPath(AppId_t appID)
bool Settings::getAppInstallPath(AppId_t appID, std::string &path)
{
return app_paths[appID];
auto app_path = app_paths.find(appID);
if (app_paths.end() != app_path)
{
path = app_path->second;
return true;
}

return false;
}

void Settings::setLeaderboard(const std::string &leaderboard, enum ELeaderboardSortMethod sort_method, enum ELeaderboardDisplayType display_type)
Expand Down
11 changes: 7 additions & 4 deletions dll/settings_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,15 +767,18 @@ static void parse_app_paths(class Settings *settings_client, Settings *settings_

for (const auto &id : ids) {
auto val_ptr = ini.GetValue("app::paths", id.pItem);
if (!val_ptr || !val_ptr[0]) continue;
// NOTE: empty path means we actively disable the path to the appid specified
if (!val_ptr) continue;

AppId_t appid = (AppId_t)std::stoul(id.pItem);
std::string rel_path(val_ptr);
std::string path = canonical_path(program_path + rel_path);
std::string path{};
if (rel_path.size())
path = canonical_path(program_path + rel_path);

if (appid) {
if (path.size()) {
PRINT_DEBUG("Adding app path: %u|%s|", appid, path.c_str());
if (!rel_path.size() || path.size()) {
PRINT_DEBUG("Adding app path: %u|%s|%s", appid, rel_path.c_str(), path.c_str());
settings_client->setAppInstallPath(appid, path);
settings_server->setAppInstallPath(appid, path);
} else {
Expand Down
7 changes: 5 additions & 2 deletions dll/steam_apps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
PRINT_DEBUG("%u %p %u", appID, pchFolder, cchFolderBufferSize);
std::lock_guard<std::recursive_mutex> lock(global_mutex);
//TODO return real path instead of dll path
std::string installed_path = settings->getAppInstallPath(appID);
std::string installed_path;

if (installed_path.empty()) {
if (!settings->getAppInstallPath(appID, installed_path)) {
std::string dll_path = get_full_program_path();
std::string current_path = get_current_path();
PRINT_DEBUG(" dll: '%s', current: '%s'", dll_path.c_str(), current_path.c_str());
Expand All @@ -335,6 +335,9 @@ uint32 Steam_Apps::GetAppInstallDir( AppId_t appID, char *pchFolder, uint32 cchF
installed_path = dll_path;
}
}
else if (installed_path.empty()) {
return 0; // NOTE: empty path means we actively disable the path to the appid specified
}

PRINT_DEBUG(" final path '%s'", installed_path.c_str());
if (pchFolder && cchFolderBufferSize) {
Expand Down
6 changes: 6 additions & 0 deletions post_build/steam_settings.EXAMPLE/configs.app.EXAMPLE.ini
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ unlock_all=0
56789=This is another example DLC name

[app::paths]
# some rare games might need to be provided one or more paths to appids
# for example the path to where a DLC is installed
# this sets the paths returned by the Steam_Apps::GetAppInstallDir function
556760=../DLCRoot0
1234=./folder_where_steam_api_is
3456=../folder_one_level_above_where_steam_api_is
5678=../../folder_two_levels_above_where_steam_api_is
# however some other games might expect this function to return empty paths to properly load DLCs
# you can deliberately set the path to be empty to specify this behavior like lines below
1337=