Skip to content

Commit 77217a2

Browse files
authored
Merge pull request #191 from SubnauticaModding/dev
QModManager 4.0.2.3
2 parents afcf7cf + c73a18a commit 77217a2

24 files changed

+120
-33
lines changed

Build/InstallerExtensions.dll

0 Bytes
Binary file not shown.

Build/QModInstaller.dll

-512 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Build/QModManager.QMMLoader.dll

0 Bytes
Binary file not shown.
-512 Bytes
Binary file not shown.

Build/QModManager.UnityAudioFixer.dll

0 Bytes
Binary file not shown.

Build/QModManager.exe

1.5 KB
Binary file not shown.

Build/QModManager.zip

-2.34 MB
Binary file not shown.

Build/QModManager_Setup.exe

408 Bytes
Binary file not shown.

Build/VortexPackage.zip

-711 KB
Binary file not shown.

Data/latest-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.2.2
1+
4.0.2.3

Executable/CleanUp.cs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
using Mono.Cecil;
2+
using System;
3+
using System.IO;
4+
5+
namespace QModManager
6+
{
7+
internal static class CleanUp
8+
{
9+
private static bool IsChildOf(this DirectoryInfo child, DirectoryInfo parent, bool recursive = false)
10+
{
11+
if (child.Parent == null)
12+
return false;
13+
14+
return child.Parent.FullName == parent.FullName || (recursive && child.Parent.IsChildOf(parent, recursive));
15+
}
16+
17+
private static bool IsChildOf(this FileInfo child, DirectoryInfo parent, bool recursive = true)
18+
{
19+
if (child.Directory == null)
20+
return false;
21+
22+
return child.Directory.FullName == parent.FullName || (recursive && child.Directory.IsChildOf(parent, recursive));
23+
}
24+
private static bool IsChildOf(this FileInfo child, string parentPath, bool recursive = true)
25+
=> child.IsChildOf(new DirectoryInfo(parentPath), recursive);
26+
27+
internal static void Initialize(string gameRootDirectory, string managedDirectory)
28+
{
29+
string qmodsDirectory = Path.Combine(gameRootDirectory, "QMods");
30+
string bepinexCoreDirectory = Path.Combine(gameRootDirectory, "BepInEx", "core");
31+
32+
string[] pathsToCheck = new[] { managedDirectory, qmodsDirectory };
33+
34+
foreach (var path in pathsToCheck)
35+
{
36+
foreach (var file in Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories))
37+
{
38+
var fileInfo = new FileInfo(file);
39+
if (fileInfo.FullName.Contains("system32") || fileInfo.FullName.Contains("Windows") || fileInfo.IsChildOf(bepinexCoreDirectory, true))
40+
{
41+
Console.WriteLine($"Path is unsafe! {path}");
42+
continue;
43+
}
44+
45+
try
46+
{
47+
using (var stream = new MemoryStream(File.ReadAllBytes(file)))
48+
{
49+
if (AssemblyDefinition.ReadAssembly(stream).MainModule.Name == "0Harmony" && File.Exists(file))
50+
{
51+
File.Delete(file);
52+
Console.WriteLine($"Deleted {new DirectoryInfo(file).FullName}...");
53+
}
54+
}
55+
}
56+
catch (BadImageFormatException)
57+
{
58+
if (Path.GetFileName(file).StartsWith("0Harmony") && File.Exists(file))
59+
{
60+
File.Delete(file);
61+
Console.WriteLine($"Deleted {new DirectoryInfo(file).FullName}...");
62+
}
63+
}
64+
}
65+
}
66+
}
67+
}
68+
}

Executable/Executable.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
8383
</PropertyGroup>
8484
<ItemGroup>
85+
<Reference Include="Mono.Cecil">
86+
<HintPath>..\Dependencies\BepInEx\BepInEx\core\Mono.Cecil.dll</HintPath>
87+
<Private>False</Private>
88+
</Reference>
8589
<Reference Include="QModManager.UnityAudioFixer, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
8690
<SpecificVersion>False</SpecificVersion>
8791
<HintPath>..\Build\QModManager.UnityAudioFixer.dll</HintPath>
@@ -90,6 +94,7 @@
9094
<Reference Include="System" />
9195
</ItemGroup>
9296
<ItemGroup>
97+
<Compile Include="CleanUp.cs" />
9398
<Compile Include="Program.cs" />
9499
<Compile Include="Properties\AssemblyInfo.cs">
95100
<SubType>Code</SubType>

Executable/Program.cs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ internal enum Action
1212
Install,
1313
Uninstall,
1414
RunByUser,
15+
CleanUp
1516
}
1617

1718
[Flags]
@@ -46,6 +47,8 @@ internal static void Main(string[] args)
4647
action = Action.Install;
4748
else if (arg == "-u")
4849
action = Action.Uninstall;
50+
else if (arg == "-c")
51+
action = Action.CleanUp;
4952
}
5053

5154
string gameRootDirectory = Path.Combine(Environment.CurrentDirectory, "../../..");
@@ -125,12 +128,31 @@ internal static void Main(string[] args)
125128
Console.WriteLine("Unity audio disabled.");
126129
Environment.Exit(0);
127130
}
131+
else if (action == Action.CleanUp)
132+
{
133+
Console.WriteLine("Attempting to clean up Nitrox and previous QMM installs...");
134+
CleanUp.Initialize(gameRootDirectory, managedDirectory);
135+
Console.WriteLine("Clean-up complete.");
136+
Environment.Exit(0);
137+
}
128138
else
129139
{
130-
Console.Write("Enable Unity sound? [Y/N] > ");
140+
Console.Write("Clean up install? [Y/N] > ");
131141
ConsoleKey key = Console.ReadKey().Key;
132142
Console.WriteLine();
133143

144+
if (key == ConsoleKey.Y)
145+
{
146+
Console.WriteLine("Attempting to clean up Nitrox and previous QMM installs...");
147+
CleanUp.Initialize(gameRootDirectory, managedDirectory);
148+
Console.WriteLine("Clean-up complete.");
149+
Console.WriteLine();
150+
}
151+
152+
Console.Write("Enable Unity sound? [Y/N] > ");
153+
key = Console.ReadKey().Key;
154+
Console.WriteLine();
155+
134156
if (key == ConsoleKey.Y)
135157
{
136158
Console.WriteLine("Attempting to enable Unity audio...");

Executable/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
[assembly: ComVisible(false)]
1414

15-
[assembly: AssemblyVersion("4.0.2.2")]
16-
[assembly: AssemblyFileVersion("4.0.2.2")]
15+
[assembly: AssemblyVersion("4.0.2.3")]
16+
[assembly: AssemblyFileVersion("4.0.2.3")]

Installer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414

1515
[assembly: Guid("8c6c9a0b-80c4-43d2-89f2-749e6f09fdda")]
1616

17-
[assembly: AssemblyVersion("4.0.2.2")]
18-
[assembly: AssemblyFileVersion("4.0.2.2")]
17+
[assembly: AssemblyVersion("4.0.2.3")]
18+
[assembly: AssemblyFileVersion("4.0.2.3")]

Installer/QModsInstallerScript.iss

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#endif
66

77
#define Name "QModManager" ; The name of the game will be added after it
8-
#define Version "4.0.2.2"
8+
#define Version "4.0.2.3"
99
#define Author "QModManager"
1010
#define URL "https://github.com/QModManager/QModManager"
1111
#define SupportURL "https://discord.gg/UpWuWwq"
@@ -73,6 +73,9 @@ Source: "..\Dependencies\BepInEx\*"; DestDir: "{app}"; Flags: recursesubdirs cre
7373

7474
[Dirs]
7575
Name: "{app}\QMods"
76+
77+
[Run]
78+
Filename: "{app}\BepInEx\patchers\QModManager\QModManager.exe"; Parameters: "-c"; Tasks: cleanup
7679

7780
[UninstallRun]
7881
Filename: "{app}\BepInEx\patchers\QModManager\QModManager.exe"; Parameters: "-u";
@@ -97,6 +100,9 @@ Name: "qmm"; Description: "QModManager"; Flags: fixed; Types: select;
97100
Name: "qmm\sn"; Description: "Install for Subnautica"; Flags: exclusive fixed;
98101
Name: "qmm\bz"; Description: "Install for Below Zero"; Flags: exclusive fixed;
99102

103+
[Tasks]
104+
Name: "cleanup"; Description: "(Recommended) Clean up after previous Nitrox and QMM installs";
105+
100106
[Code]
101107
// Import stuff from InstallerExtensions.dll
102108
function PathsEqual(pathone, pathtwo: WideString): Boolean; external 'PathsEqual@files:InstallerExtensions.dll stdcall setuponly delayload';
@@ -537,7 +543,7 @@ begin
537543
end
538544
end;
539545
540-
function IsPreviousVersionInstalled: boolean; // Returns true for previus versions < 4.0 (prior to the change to BepInEx)
546+
function IsPreviousVersionInstalled: Boolean; // Returns true for previus versions < 4.0 (prior to the change to BepInEx)
541547
var
542548
uninstallRegKey: String;
543549
previousVersion: String;

QMMHarmonyShimmer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.0.2.2")]
37-
[assembly: AssemblyFileVersion("4.0.2.2")]
36+
[assembly: AssemblyVersion("4.0.2.3")]
37+
[assembly: AssemblyFileVersion("4.0.2.3")]
3838
[assembly: NeutralResourcesLanguage("en")]

QMMLoader/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.0.2.2")]
37-
[assembly: AssemblyFileVersion("4.0.2.2")]
36+
[assembly: AssemblyVersion("4.0.2.3")]
37+
[assembly: AssemblyFileVersion("4.0.2.3")]
3838
[assembly: NeutralResourcesLanguage("en")]

QModManager/Patching/Patcher.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,7 @@ internal static class Patcher
1212
{
1313
internal const string IDRegex = "[^0-9a-zA-Z_]";
1414

15-
internal static string QModBaseDir
16-
{
17-
get
18-
{
19-
if (Environment.CurrentDirectory.Contains("system32") && Environment.CurrentDirectory.Contains("Windows"))
20-
return null;
21-
else
22-
return Path.Combine(Environment.CurrentDirectory, "QMods");
23-
}
24-
}
15+
internal static string QModBaseDir => Path.Combine(Environment.CurrentDirectory, "QMods");
2516

2617
private static bool Patched = false;
2718
internal static QModGame CurrentlyRunningGame { get; private set; } = QModGame.None;

QModManager/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
[assembly: ComVisible(false)]
1515

16-
[assembly: AssemblyVersion("4.0.2.2")]
17-
[assembly: AssemblyFileVersion("4.0.2.2")]
16+
[assembly: AssemblyVersion("4.0.2.3")]
17+
[assembly: AssemblyFileVersion("4.0.2.3")]
1818

1919
[assembly: InternalsVisibleTo("QMMTests")]
2020
[assembly: InternalsVisibleTo("QModManager")]

QModPluginEmulator/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.0.2.2")]
37-
[assembly: AssemblyFileVersion("4.0.2.2")]
36+
[assembly: AssemblyVersion("4.0.2.3")]
37+
[assembly: AssemblyFileVersion("4.0.2.3")]
3838
[assembly: NeutralResourcesLanguage("en")]
3939

4040
[assembly: InternalsVisibleTo("QModManager.QMMLoader")]

QModPluginEmulator/QModPluginGenerator.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,6 @@ private static void SaveQMMAssemblyCache()
150150

151151
private static void ClearBepInExCache()
152152
{
153-
if (BepInExCachePath.Contains("system32") || BepInExCachePath.Contains("Windows"))
154-
{
155-
throw new InvalidOperationException($"BepInEx Cache Path invalid! ({BepInExCachePath})");
156-
}
157-
158153
if (!Directory.Exists(BepInExCachePath))
159154
return;
160155

UnityAudioFixer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("4.0.2.2")]
36-
[assembly: AssemblyFileVersion("4.0.2.2")]
35+
[assembly: AssemblyVersion("4.0.2.3")]
36+
[assembly: AssemblyFileVersion("4.0.2.3")]

0 commit comments

Comments
 (0)