Skip to content

Commit db1fd4e

Browse files
committed
Refactored inner method "GetBepInExModCount" to parent method code
1 parent 8cc6b7d commit db1fd4e

1 file changed

Lines changed: 19 additions & 22 deletions

File tree

Nitrox.Launcher/Models/Utils/GameInspect.cs

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,36 +64,33 @@ public static bool WarnIfGameProcessExists(GameInfo game)
6464

6565
public static void WarnIfBepInExMods(string gameDir)
6666
{
67-
if (GetBepInExModCount(gameDir) is var count and > 0)
67+
if (string.IsNullOrWhiteSpace(gameDir) || !Directory.Exists(gameDir))
6868
{
69-
Log.Warn($"BepInEx plugins detected: {count}");
70-
LauncherNotifier.Warning($"BepInEx mod(s) were detected ({count}). Nitrox multiplayer does not support mods and they may cause instability.");
69+
return;
70+
}
71+
string bepRoot = Path.Combine(gameDir, "BepInEx");
72+
if (!Directory.Exists(bepRoot))
73+
{
74+
return;
7175
}
7276

73-
static int GetBepInExModCount(string gameDir)
77+
int modDllCount = GetDllPaths(Path.Combine(bepRoot, "plugins")).Count();
78+
modDllCount += GetDllPaths(Path.Combine(bepRoot, "patchers")).Count();
79+
if (modDllCount > 0)
7480
{
75-
if (string.IsNullOrWhiteSpace(gameDir) || !Directory.Exists(gameDir))
76-
{
77-
return 0;
78-
}
81+
Log.Warn($"BepInEx plugins detected: {modDllCount}");
82+
LauncherNotifier.Warning($"BepInEx mod(s) were detected ({modDllCount}). Nitrox multiplayer does not support mods and they may cause instability.");
83+
}
7984

80-
string bepRoot = Path.Combine(gameDir, "BepInEx");
81-
if (!Directory.Exists(bepRoot))
85+
static IEnumerable<string> GetDllPaths(string path)
86+
{
87+
try
8288
{
83-
return 0;
89+
return Directory.EnumerateFiles(path, "*.dll", SearchOption.AllDirectories);
8490
}
85-
return GetDllPaths(Path.Combine(bepRoot, "plugins")).Count() + GetDllPaths(Path.Combine(bepRoot, "patchers")).Count();
86-
87-
static IEnumerable<string> GetDllPaths(string path)
91+
catch (IOException)
8892
{
89-
try
90-
{
91-
return Directory.EnumerateFiles(path, "*.dll", SearchOption.AllDirectories);
92-
}
93-
catch (IOException)
94-
{
95-
return [];
96-
}
93+
return [];
9794
}
9895
}
9996
}

0 commit comments

Comments
 (0)