Skip to content

Commit

Permalink
Merge pull request #191 from SubnauticaModding/dev
Browse files Browse the repository at this point in the history
QModManager 4.0.2.3
  • Loading branch information
toebeann authored Sep 19, 2020
2 parents afcf7cf + c73a18a commit 77217a2
Show file tree
Hide file tree
Showing 24 changed files with 120 additions and 33 deletions.
Binary file modified Build/InstallerExtensions.dll
Binary file not shown.
Binary file modified Build/QModInstaller.dll
Binary file not shown.
Binary file modified Build/QModManager.QMMHarmonyShimmer.dll
Binary file not shown.
Binary file modified Build/QModManager.QMMLoader.dll
Binary file not shown.
Binary file modified Build/QModManager.QModPluginGenerator.dll
Binary file not shown.
Binary file modified Build/QModManager.UnityAudioFixer.dll
Binary file not shown.
Binary file modified Build/QModManager.exe
Binary file not shown.
Binary file removed Build/QModManager.zip
Binary file not shown.
Binary file modified Build/QModManager_Setup.exe
Binary file not shown.
Binary file removed Build/VortexPackage.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion Data/latest-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0.2.2
4.0.2.3
68 changes: 68 additions & 0 deletions Executable/CleanUp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using Mono.Cecil;
using System;
using System.IO;

namespace QModManager
{
internal static class CleanUp
{
private static bool IsChildOf(this DirectoryInfo child, DirectoryInfo parent, bool recursive = false)
{
if (child.Parent == null)
return false;

return child.Parent.FullName == parent.FullName || (recursive && child.Parent.IsChildOf(parent, recursive));
}

private static bool IsChildOf(this FileInfo child, DirectoryInfo parent, bool recursive = true)
{
if (child.Directory == null)
return false;

return child.Directory.FullName == parent.FullName || (recursive && child.Directory.IsChildOf(parent, recursive));
}
private static bool IsChildOf(this FileInfo child, string parentPath, bool recursive = true)
=> child.IsChildOf(new DirectoryInfo(parentPath), recursive);

internal static void Initialize(string gameRootDirectory, string managedDirectory)
{
string qmodsDirectory = Path.Combine(gameRootDirectory, "QMods");
string bepinexCoreDirectory = Path.Combine(gameRootDirectory, "BepInEx", "core");

string[] pathsToCheck = new[] { managedDirectory, qmodsDirectory };

foreach (var path in pathsToCheck)
{
foreach (var file in Directory.GetFiles(path, "*.dll", SearchOption.AllDirectories))
{
var fileInfo = new FileInfo(file);
if (fileInfo.FullName.Contains("system32") || fileInfo.FullName.Contains("Windows") || fileInfo.IsChildOf(bepinexCoreDirectory, true))
{
Console.WriteLine($"Path is unsafe! {path}");
continue;
}

try
{
using (var stream = new MemoryStream(File.ReadAllBytes(file)))
{
if (AssemblyDefinition.ReadAssembly(stream).MainModule.Name == "0Harmony" && File.Exists(file))
{
File.Delete(file);
Console.WriteLine($"Deleted {new DirectoryInfo(file).FullName}...");
}
}
}
catch (BadImageFormatException)
{
if (Path.GetFileName(file).StartsWith("0Harmony") && File.Exists(file))
{
File.Delete(file);
Console.WriteLine($"Deleted {new DirectoryInfo(file).FullName}...");
}
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions Executable/Executable.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Cecil">
<HintPath>..\Dependencies\BepInEx\BepInEx\core\Mono.Cecil.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="QModManager.UnityAudioFixer, Version=4.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Build\QModManager.UnityAudioFixer.dll</HintPath>
Expand All @@ -90,6 +94,7 @@
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="CleanUp.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
Expand Down
24 changes: 23 additions & 1 deletion Executable/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal enum Action
Install,
Uninstall,
RunByUser,
CleanUp
}

[Flags]
Expand Down Expand Up @@ -46,6 +47,8 @@ internal static void Main(string[] args)
action = Action.Install;
else if (arg == "-u")
action = Action.Uninstall;
else if (arg == "-c")
action = Action.CleanUp;
}

string gameRootDirectory = Path.Combine(Environment.CurrentDirectory, "../../..");
Expand Down Expand Up @@ -125,12 +128,31 @@ internal static void Main(string[] args)
Console.WriteLine("Unity audio disabled.");
Environment.Exit(0);
}
else if (action == Action.CleanUp)
{
Console.WriteLine("Attempting to clean up Nitrox and previous QMM installs...");
CleanUp.Initialize(gameRootDirectory, managedDirectory);
Console.WriteLine("Clean-up complete.");
Environment.Exit(0);
}
else
{
Console.Write("Enable Unity sound? [Y/N] > ");
Console.Write("Clean up install? [Y/N] > ");
ConsoleKey key = Console.ReadKey().Key;
Console.WriteLine();

if (key == ConsoleKey.Y)
{
Console.WriteLine("Attempting to clean up Nitrox and previous QMM installs...");
CleanUp.Initialize(gameRootDirectory, managedDirectory);
Console.WriteLine("Clean-up complete.");
Console.WriteLine();
}

Console.Write("Enable Unity sound? [Y/N] > ");
key = Console.ReadKey().Key;
Console.WriteLine();

if (key == ConsoleKey.Y)
{
Console.WriteLine("Attempting to enable Unity audio...");
Expand Down
4 changes: 2 additions & 2 deletions Executable/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@

[assembly: ComVisible(false)]

[assembly: AssemblyVersion("4.0.2.2")]
[assembly: AssemblyFileVersion("4.0.2.2")]
[assembly: AssemblyVersion("4.0.2.3")]
[assembly: AssemblyFileVersion("4.0.2.3")]
4 changes: 2 additions & 2 deletions Installer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

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

[assembly: AssemblyVersion("4.0.2.2")]
[assembly: AssemblyFileVersion("4.0.2.2")]
[assembly: AssemblyVersion("4.0.2.3")]
[assembly: AssemblyFileVersion("4.0.2.3")]
10 changes: 8 additions & 2 deletions Installer/QModsInstallerScript.iss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#endif

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

[Dirs]
Name: "{app}\QMods"

[Run]
Filename: "{app}\BepInEx\patchers\QModManager\QModManager.exe"; Parameters: "-c"; Tasks: cleanup

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

[Tasks]
Name: "cleanup"; Description: "(Recommended) Clean up after previous Nitrox and QMM installs";

[Code]
// Import stuff from InstallerExtensions.dll
function PathsEqual(pathone, pathtwo: WideString): Boolean; external 'PathsEqual@files:InstallerExtensions.dll stdcall setuponly delayload';
Expand Down Expand Up @@ -537,7 +543,7 @@ begin
end
end;
function IsPreviousVersionInstalled: boolean; // Returns true for previus versions < 4.0 (prior to the change to BepInEx)
function IsPreviousVersionInstalled: Boolean; // Returns true for previus versions < 4.0 (prior to the change to BepInEx)
var
uninstallRegKey: String;
previousVersion: String;
Expand Down
4 changes: 2 additions & 2 deletions QMMHarmonyShimmer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.2.2")]
[assembly: AssemblyFileVersion("4.0.2.2")]
[assembly: AssemblyVersion("4.0.2.3")]
[assembly: AssemblyFileVersion("4.0.2.3")]
[assembly: NeutralResourcesLanguage("en")]
4 changes: 2 additions & 2 deletions QMMLoader/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.2.2")]
[assembly: AssemblyFileVersion("4.0.2.2")]
[assembly: AssemblyVersion("4.0.2.3")]
[assembly: AssemblyFileVersion("4.0.2.3")]
[assembly: NeutralResourcesLanguage("en")]
11 changes: 1 addition & 10 deletions QModManager/Patching/Patcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,7 @@ internal static class Patcher
{
internal const string IDRegex = "[^0-9a-zA-Z_]";

internal static string QModBaseDir
{
get
{
if (Environment.CurrentDirectory.Contains("system32") && Environment.CurrentDirectory.Contains("Windows"))
return null;
else
return Path.Combine(Environment.CurrentDirectory, "QMods");
}
}
internal static string QModBaseDir => Path.Combine(Environment.CurrentDirectory, "QMods");

private static bool Patched = false;
internal static QModGame CurrentlyRunningGame { get; private set; } = QModGame.None;
Expand Down
4 changes: 2 additions & 2 deletions QModManager/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

[assembly: ComVisible(false)]

[assembly: AssemblyVersion("4.0.2.2")]
[assembly: AssemblyFileVersion("4.0.2.2")]
[assembly: AssemblyVersion("4.0.2.3")]
[assembly: AssemblyFileVersion("4.0.2.3")]

[assembly: InternalsVisibleTo("QMMTests")]
[assembly: InternalsVisibleTo("QModManager")]
Expand Down
4 changes: 2 additions & 2 deletions QModPluginEmulator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.2.2")]
[assembly: AssemblyFileVersion("4.0.2.2")]
[assembly: AssemblyVersion("4.0.2.3")]
[assembly: AssemblyFileVersion("4.0.2.3")]
[assembly: NeutralResourcesLanguage("en")]

[assembly: InternalsVisibleTo("QModManager.QMMLoader")]
5 changes: 0 additions & 5 deletions QModPluginEmulator/QModPluginGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,6 @@ private static void SaveQMMAssemblyCache()

private static void ClearBepInExCache()
{
if (BepInExCachePath.Contains("system32") || BepInExCachePath.Contains("Windows"))
{
throw new InvalidOperationException($"BepInEx Cache Path invalid! ({BepInExCachePath})");
}

if (!Directory.Exists(BepInExCachePath))
return;

Expand Down
4 changes: 2 additions & 2 deletions UnityAudioFixer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("4.0.2.2")]
[assembly: AssemblyFileVersion("4.0.2.2")]
[assembly: AssemblyVersion("4.0.2.3")]
[assembly: AssemblyFileVersion("4.0.2.3")]

0 comments on commit 77217a2

Please sign in to comment.