Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaned up build scripts and used AssemblyResolve event instead of copying all dlls #1098

Merged
merged 39 commits into from
May 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ea4bacc
Cleaned up NitroxModel and NitroxServer to use as little of UnityEngi…
Measurity May 12, 2020
444dcfc
Used Nitrox.Bootstrapper to launch Nitrox at runtime through reflection
Measurity May 13, 2020
c25174c
Fixed the surrogates again after moving them to NitroxModel-Subnautica
Measurity May 13, 2020
558cee9
Allowed game to start when server is running (again) by loading assem…
Measurity May 13, 2020
35be5ed
Fixed wrong output copy for launcher
Measurity May 13, 2020
07f951b
Small cleanup of server related code
Measurity May 13, 2020
4bc13aa
Fixed assembly load from bytes loading the same dll multiple times
Measurity May 13, 2020
432c365
Fixed log format exception
Measurity May 13, 2020
7feaf4c
Reverted LiteNetLib to upstream 0.8
Measurity May 13, 2020
0ab4e48
Removed .csproj framework version property from Nitrox.Bootloader bec…
Measurity May 13, 2020
fe25540
Removed unused imports in NitroxPatcher.Main
Measurity May 13, 2020
07ab213
Fixed build for test project by copying all references over from game…
Measurity May 14, 2020
493e026
Removed all UnityEngine references from NitroxModel
Measurity May 14, 2020
1474cf6
Removed all references to UnityEngine from NitroxServer
Measurity May 14, 2020
1f3c565
Removed default value for prop in NitroxModel.csproj
Measurity May 14, 2020
20a0f59
Reverted changes to NitroxModel namespaces because it's now UnityEngi…
Measurity May 14, 2020
fa78362
Reverted namespace usages in NitroxServer since it's now UnityEngine …
Measurity May 14, 2020
1ee36bf
Added protomember attributes to NitroxColor members
Measurity May 14, 2020
0be6d24
Small unrelated performance fix in BaseDebugger
Measurity May 15, 2020
c3d6660
Used an environment variable to set the Nitrox launcher path instead …
Measurity May 15, 2020
cfbef67
Disabled loading of Nitrox if QModManager's assembly is loaded too
Measurity May 15, 2020
b29af07
Forgot the use the variable after refactor to Bootloader.Main
Measurity May 15, 2020
89c7022
Added AliveOrNull before Vehicles.GetColors calls
Measurity May 16, 2020
1de82f2
Removed dead code
Measurity May 16, 2020
20b7ffa
Removed blank line in TextureScaler.cs
Measurity May 16, 2020
1325b1a
Added seamoth colors for VehicleHelper
Measurity May 16, 2020
be1d7a6
Removed newline in RandomColorGenerator
Measurity May 16, 2020
b0b9339
Reverted autoformat change in SubnauticaAutoFacRegistrar
Measurity May 16, 2020
d450a20
Removed template comment in Nitrox.Bootloader.csproj
Measurity May 16, 2020
d09ae58
Removed whitespace
Measurity May 16, 2020
ef58991
Removed x86 build support
Measurity May 16, 2020
0a59094
Changed Nitrox.Bootloader error check to method and fixed return type
Measurity May 16, 2020
e2a9f0d
Cleaned up RetryWait code
Measurity May 16, 2020
58ed46d
Added error log to exception for launcherpath.txt delete call
Measurity May 16, 2020
ad9a6dc
Removed newline in BatchEntitySpawner
Measurity May 17, 2020
73f79fb
Fixed RetryWait
Measurity May 17, 2020
77d6864
Formatted QuaternionSurrogate
Measurity May 17, 2020
23b5a3d
Removed using rename for TechType in PDAStateData
Measurity May 17, 2020
b82e33d
Renamed NitroxModel's TechType to NitroxTechType
Measurity May 17, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Disabled loading of Nitrox if QModManager's assembly is loaded too
  • Loading branch information
Measurity committed May 17, 2020
commit cfbef676afc031e2f254acf08a4b30313876d901
50 changes: 35 additions & 15 deletions Nitrox.Bootloader/Main.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

Expand All @@ -23,6 +24,18 @@ public static class Main
try
{
string valueInFile = File.ReadAllText(nitroxLauncherPathFile).Trim();
Task.Factory.StartNew(() =>
{
try
{
// Delete the path so that the launcher should be used to launch Nitrox
File.Delete(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Nitrox"), "launcherpath.txt"));
}
catch (Exception)
{
// ignored
}
});
return Directory.Exists(valueInFile) ? valueInFile : null;
}
catch
Expand All @@ -34,26 +47,15 @@ public static class Main

public static void Execute()
{
if (nitroxLauncherDir.Value == null)
string error = NitroxLoadError;
if (error != null)
{
Console.WriteLine("Nitrox launcher path not set in AppData. Nitrox will not start.");
Console.WriteLine(error);
return;
}

Environment.SetEnvironmentVariable("NITROX_LAUNCHER_PATH", nitroxLauncherDir.Value);
Task.Factory.StartNew(() =>
{
try
{
// Delete the path so that the launcher should be used to launch Nitrox
File.Delete(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Nitrox"), "launcherpath.txt"));
}
catch (Exception)
{
// ignored
}
});


AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainOnAssemblyResolve;
AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += CurrentDomainOnAssemblyResolve;

Expand All @@ -67,6 +69,24 @@ private static void BootstrapNitrox()
mainType.InvokeMember("Execute", BindingFlags.Public | BindingFlags.Static | BindingFlags.InvokeMethod, null, null, null);
}


private static string NitroxLoadError
Measurity marked this conversation as resolved.
Show resolved Hide resolved
{
get
{
if (nitroxLauncherDir.Value == null)
{
return "Nitrox launcher path not set in AppData. Nitrox will not start.";
}
if (AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.FullName.StartsWith("QMod", StringComparison.Ordinal)) != null)
{
return "Nitrox will not start because QModManager is active.";
}

return "";
}
}

private static Assembly CurrentDomainOnAssemblyResolve(object sender, ResolveEventArgs args)
{
string dllFileName = args.Name.Split(',')[0];
Expand Down
1 change: 0 additions & 1 deletion NitroxModel/Helper/NitroxAppData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ namespace NitroxModel.Helper
public class NitroxAppData
{
private static NitroxAppData instance;
private string launcherPath;

private NitroxAppData()
{
Expand Down