mirror of
https://github.com/BepInEx/BepInEx.git
synced 2026-10-19 15:51:45 +00:00
Fix GameDataPath exception in non-Unity3D games (#1416)
When `GameDataPath` is invalid, do not throw an exception; instead, set both `GameDataPath` and `ManagedPath` to `null`.
This commit is contained in:
1 parent
5b766a3b7f
commit
6cea286d20
1 file changed
+5
-5
@@ -125,11 +125,11 @@ public static class Paths
|
|||||||
if (!Directory.Exists(GameDataPath))
|
if (!Directory.Exists(GameDataPath))
|
||||||
GameDataPath = Path.Combine(GameRootPath, "Data");
|
GameDataPath = Path.Combine(GameRootPath, "Data");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(GameDataPath) || !Directory.Exists(GameDataPath))
|
|
||||||
throw new DirectoryNotFoundException("Failed to extract valid GameDataPath from executablePath: " + executablePath);
|
|
||||||
|
|
||||||
ManagedPath = managedPath ?? Path.Combine(GameDataPath, "Managed");
|
if (string.IsNullOrEmpty(GameDataPath) || !Directory.Exists(GameDataPath))
|
||||||
|
GameDataPath = null;
|
||||||
|
|
||||||
|
ManagedPath = managedPath ?? (GameDataPath != null ? Path.Combine(GameDataPath, "Managed") : null);
|
||||||
BepInExRootPath = bepinRootPath ?? Path.Combine(GameRootPath, "BepInEx");
|
BepInExRootPath = bepinRootPath ?? Path.Combine(GameRootPath, "BepInEx");
|
||||||
ConfigPath = Path.Combine(BepInExRootPath, "config");
|
ConfigPath = Path.Combine(BepInExRootPath, "config");
|
||||||
BepInExConfigPath = Path.Combine(ConfigPath, "BepInEx.cfg");
|
BepInExConfigPath = Path.Combine(ConfigPath, "BepInEx.cfg");
|
||||||
@@ -139,7 +139,7 @@ public static class Paths
|
|||||||
BepInExAssemblyPath = Path.Combine(BepInExAssemblyDirectory,
|
BepInExAssemblyPath = Path.Combine(BepInExAssemblyDirectory,
|
||||||
$"{Assembly.GetExecutingAssembly().GetName().Name}.dll");
|
$"{Assembly.GetExecutingAssembly().GetName().Name}.dll");
|
||||||
CachePath = Path.Combine(BepInExRootPath, "cache");
|
CachePath = Path.Combine(BepInExRootPath, "cache");
|
||||||
DllSearchPaths = (dllSearchPath ?? new string[0]).Concat(new[] { ManagedPath }).Distinct().ToArray();
|
DllSearchPaths = (dllSearchPath ?? new string[0]).Concat(new[] { ManagedPath }).Where(p => p != null).Distinct().ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void SetPluginPath(string pluginPath) =>
|
internal static void SetPluginPath(string pluginPath) =>
|
||||||
|
|||||||
Reference in new issue
Block a user