aboutsummaryrefslogtreecommitdiff
path: root/src/steam.c
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-07-22 21:57:16 +0200
committerJan200101 <sentrycraft123@gmail.com>2022-07-22 21:57:39 +0200
commit91f695797fac3e1c2d20bea70f8c877d7df03b68 (patch)
tree09eda542a792e33a458fb46f26bb503c47816e15 /src/steam.c
parent1de8b89807222b5673505fea2bec1af4c0af8c7d (diff)
downloadOFQT-91f695797fac3e1c2d20bea70f8c877d7df03b68.tar.gz
OFQT-91f695797fac3e1c2d20bea70f8c877d7df03b68.zip
give vdf functions const argments, allow fetching arbitrary app installs
Diffstat (limited to 'src/steam.c')
-rw-r--r--src/steam.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/steam.c b/src/steam.c
index f8a809b..387c9b9 100644
--- a/src/steam.c
+++ b/src/steam.c
@@ -109,13 +109,13 @@ char* getOpenFortressDir(void)
return sm_dir;
}
-char* getSourceSDK2013MpDir(void)
+char* getAppInstallDir(const char* appid)
{
char* librayfolders = getSteamDir();
if (!librayfolders)
return NULL;
- librayfolders = realloc(librayfolders, strlen(librayfolders) + strlen(OS_PATH_SEP) + strlen(STEAMAPPS) + strlen(OS_PATH_SEP) + strlen(SOURCESDK_MANIFEST) + 1);
+ librayfolders = realloc(librayfolders, strlen(librayfolders) + strlen(OS_PATH_SEP) + strlen(STEAMAPPS) + strlen(OS_PATH_SEP) + strlen(LIBARYFOLDERS_VDF) + 1);
strcat(librayfolders, OS_PATH_SEP);
strcat(librayfolders, STEAMAPPS);
@@ -134,14 +134,17 @@ char* getSourceSDK2013MpDir(void)
struct vdf_object* library = vdf_object_index_array(o, i);
struct vdf_object* apps = vdf_object_index_array_str(library, "apps");
- if (vdf_object_index_array_str(apps, SOURCESDK_APPID))
+ if (vdf_object_index_array_str(apps, appid))
{
+ char* manifest = malloc(strlen(appid) + strlen(STEAM_MANIFEST) + 1);
+ sprintf(manifest, STEAM_MANIFEST, appid);
+
struct vdf_object* path = vdf_object_index_array_str(library, "path");
- size_t path_len = path->data.data_string.len + strlen(OS_PATH_SEP) + strlen(STEAMAPPS) + strlen(OS_PATH_SEP) + strlen(SOURCESDK_MANIFEST) + 1;
+ size_t path_len = path->data.data_string.len + strlen(OS_PATH_SEP) + strlen(STEAMAPPS) + strlen(OS_PATH_SEP) + strlen(manifest) + 1;
char* path_str = malloc(path_len);
- snprintf(path_str, path_len, "%s%s%s%s%s", vdf_object_get_string(path), OS_PATH_SEP, STEAMAPPS, OS_PATH_SEP, SOURCESDK_MANIFEST);
+ snprintf(path_str, path_len, "%s%s%s%s%s", vdf_object_get_string(path), OS_PATH_SEP, STEAMAPPS, OS_PATH_SEP, manifest);
struct vdf_object* k = vdf_parse_file(path_str);
free(path_str);
@@ -158,6 +161,8 @@ char* getSourceSDK2013MpDir(void)
vdf_free_object(k);
}
+
+ free(manifest);
}
}
@@ -167,6 +172,11 @@ char* getSourceSDK2013MpDir(void)
return sdkdir;
}
+char* getSourceSDK2013MpDir(void)
+{
+ return getAppInstallDir(SOURCESDK_APPID);
+}
+
/**
* function to fetch the PID of a running Steam process.
* If none were found returns -1