Skip to content

Commit ccdaa38

Browse files
committed
fix: Try multiple paths if first discovered vrc path from libraryfiles.vdf is invalid
1 parent f191d30 commit ccdaa38

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

VRCFaceTracking.Core/VRChat.cs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public static void EnsureVRCOSCDirectory()
4949
var libraryFolders = ParseVdfFile(File.ReadAllText(steamLibrariesPath));
5050

5151
// From libraryFolders, find the one containing VRChat
52-
var vrchatPath = string.Empty;
52+
var vrchatPaths = new List<string>();
5353

5454
// libraryFolders should have a root "libraryfolders" dictionary
5555
if (libraryFolders.TryGetValue("libraryfolders", out var libraryFoldersDict) &&
@@ -62,27 +62,36 @@ public static void EnsureVRCOSCDirectory()
6262
libraryData.TryGetValue("path", out var pathObj) &&
6363
libraryData.TryGetValue("apps", out var appsObj))
6464
{
65-
string libraryPath = pathObj.ToString();
66-
6765
// Check if VRChat is in the apps dictionary
68-
if (appsObj is Dictionary<string, object> apps && apps.ContainsKey("438100"))
66+
if (appsObj is not Dictionary<string, object> apps || !apps.ContainsKey("438100"))
6967
{
70-
vrchatPath = libraryPath;
71-
break;
68+
continue;
7269
}
70+
71+
var libraryPath = pathObj.ToString();
72+
vrchatPaths.Add(libraryPath);
73+
break;
7374
}
7475
}
7576
}
7677

77-
if (string.IsNullOrEmpty(vrchatPath))
78+
if (!vrchatPaths.Any())
7879
{
7980
throw new InvalidProgramException(
8081
"Steam was detected, but VRChat was not detected on this system! Is it installed?");
8182
}
8283

83-
// 4) Finally, construct the path to the user's VRChat install
84-
VRCOSCDirectory = Path.Combine(vrchatPath, "steamapps", "compatdata", "438100", "pfx", "drive_c",
85-
"users", "steamuser", "AppData", "LocalLow", "VRChat", "VRChat", "OSC");
84+
// 4) Finally, construct the path to the user's VRChat install, check it exists and try the next path if not
85+
foreach (var vrchatPath in vrchatPaths)
86+
{
87+
VRCOSCDirectory = Path.Combine(vrchatPath, "steamapps", "compatdata", "438100", "pfx", "drive_c",
88+
"users", "steamuser", "AppData", "LocalLow", "VRChat", "VRChat", "OSC");
89+
90+
if (Directory.Exists(VRCOSCDirectory))
91+
{
92+
break;
93+
}
94+
}
8695
}
8796
}
8897

0 commit comments

Comments
 (0)