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

Improved Nitrox loading logging #1221

Merged
merged 3 commits into from
Aug 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
1 change: 1 addition & 0 deletions NitroxLauncher/LauncherLogic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public void Dispose()

gameProcess?.Dispose();
serverProcess?.Dispose();
serverProcess = null; // Indicate the process is dead now.
}

public async Task WriteToServerAsync(string inputText)
Expand Down
2 changes: 1 addition & 1 deletion NitroxModel/Logger/Log.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public static void Setup(bool performanceCritical = false)
ColoredConsoleTarget logConsole = new ColoredConsoleTarget(nameof(logConsole))
{
Layout = layout,
DetectConsoleAvailable = true
DetectConsoleAvailable = false
};

logConsole.RowHighlightingRules.Add(new ConsoleRowHighlightingRule
Expand Down
30 changes: 26 additions & 4 deletions NitroxPatcher/Main.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Autofac;
using Harmony;
Expand All @@ -11,6 +14,7 @@
using NitroxPatcher.Modules;
using NitroxPatcher.Patches;
using UnityEngine;
using Object = UnityEngine.Object;

namespace NitroxPatcher
{
Expand All @@ -28,16 +32,34 @@ public static void Execute()
{
Log.Setup(true);
Optional.ApplyHasValueCondition<Object>(o => (bool)o);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentially explicitly use UnityEngine.Object and remove the using Object = UnityEngine.Object to avoid possible conflation with C#'s object?

Log.Info($"Using Nitrox version {Assembly.GetExecutingAssembly().GetName().Version} built on {File.GetCreationTimeUtc(Assembly.GetExecutingAssembly().Location)}");

if (container != null)
{
Log.Warn($"Patches have already been detected! Call {nameof(Apply)} or {nameof(Restore)} instead.");
Log.Error($"Patches have already been detected! Call {nameof(Apply)} or {nameof(Restore)} instead.");
return;
}

Log.Info("Registering dependencies");
container = CreatePatchingContainer();
NitroxServiceLocator.InitializeDependencyContainer(new ClientAutoFacRegistrar());
try
{
NitroxServiceLocator.InitializeDependencyContainer(new ClientAutoFacRegistrar());
}
catch (ReflectionTypeLoadException ex)
{
Log.Error($"Failed to load one or more dependency types for Nitrox. Assembly: {ex.Types.FirstOrDefault()?.Assembly.FullName ?? "unknown"}");
foreach (Exception loaderEx in ex.LoaderExceptions)
{
Log.Error(loaderEx);
}
throw;
}
catch (Exception)
{
Log.Error("Error initializing and loading dependencies.");
Measurity marked this conversation as resolved.
Show resolved Hide resolved
throw;
}

InitPatches();
ApplyNitroxBehaviours();
Expand Down Expand Up @@ -96,7 +118,7 @@ private static void InitPatches()

Multiplayer.OnBeforeMultiplayerStart += Apply;
Multiplayer.OnAfterMultiplayerEnd += Restore;
Log.Info($"Completed patching using {Assembly.GetExecutingAssembly().FullName}");
Log.Info($"Completed patching");
}

private static IContainer CreatePatchingContainer()
Expand Down