Improve shutdown handling and disable virtualizing when no Assembly is available.

This commit is contained in:
Eusth 2017-04-22 21:15:36 +02:00
parent ffd259040f
commit 0df8b1ecb8
2 changed files with 20 additions and 8 deletions

View file

@ -48,7 +48,7 @@ namespace IPA
private static void Validate(PatchContext c) private static void Validate(PatchContext c)
{ {
if (!File.Exists(c.LauncherPathSrc)) Fail("Couldn't find DLLs! Make sure you extracted all contents of the release archive."); if (!File.Exists(c.LauncherPathSrc)) Fail("Couldn't find DLLs! Make sure you extracted all contents of the release archive.");
if (!Directory.Exists(c.DataPathDst) || !File.Exists(c.EngineFile) || !File.Exists(c.AssemblyFile)) if (!Directory.Exists(c.DataPathDst) || !File.Exists(c.EngineFile))
{ {
Fail("Game does not seem to be a Unity project. Could not find the libraries to patch."); Fail("Game does not seem to be a Unity project. Could not find the libraries to patch.");
} }
@ -86,13 +86,16 @@ namespace IPA
} }
// Virtualizing // Virtualizing
var virtualizedModule = VirtualizedModule.Load(context.AssemblyFile); if (File.Exists(context.AssemblyFile))
if (!virtualizedModule.IsVirtualized)
{ {
Console.Write("Virtualizing Assembly-Csharp.dll... "); var virtualizedModule = VirtualizedModule.Load(context.AssemblyFile);
backup.Add(context.AssemblyFile); if (!virtualizedModule.IsVirtualized)
virtualizedModule.Virtualize(); {
Console.WriteLine("Done!"); Console.Write("Virtualizing Assembly-Csharp.dll... ");
backup.Add(context.AssemblyFile);
virtualizedModule.Virtualize();
Console.WriteLine("Done!");
}
} }
// Creating shortcut // Creating shortcut

View file

@ -9,6 +9,7 @@ namespace IllusionInjector
{ {
private CompositePlugin plugins; private CompositePlugin plugins;
private bool freshlyLoaded = false; private bool freshlyLoaded = false;
private bool quitting = false;
public static PluginComponent Create() public static PluginComponent Create()
{ {
@ -49,10 +50,18 @@ namespace IllusionInjector
} }
void OnDestroy() void OnDestroy()
{
if (!quitting)
{
Create();
}
}
void OnApplicationQuit()
{ {
plugins.OnApplicationQuit(); plugins.OnApplicationQuit();
Create(); quitting = true;
} }
void OnLevelWasLoaded(int level) void OnLevelWasLoaded(int level)