Skip to content

Commit

Permalink
Merge pull request #237 from SubnauticaModding/Dev
Browse files Browse the repository at this point in the history
QModManager 4.1.4 Patch time and Logging hotfixes
  • Loading branch information
MrPurple6411 authored Jun 1, 2021
2 parents 164348e + 18b6a3e commit c976a95
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Data/latest-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.1.3
4.1.4.0
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.1.3")]
[assembly: AssemblyFileVersion("4.1.3")]
[assembly: AssemblyVersion("4.1.4")]
[assembly: AssemblyFileVersion("4.1.4")]
2 changes: 1 addition & 1 deletion Installer/BZ.EXP.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.1.3"
#define Version "4.1.4"
#define Author "QModManager"
#define URL "https://github.com/QModManager/QModManager"
#define SupportURL "https://discord.gg/UpWuWwq"
Expand Down
2 changes: 1 addition & 1 deletion Installer/BZ.STABLE.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.1.3"
#define Version "4.1.4"
#define Author "QModManager"
#define URL "https://github.com/QModManager/QModManager"
#define SupportURL "https://discord.gg/UpWuWwq"
Expand Down
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.1.3")]
[assembly: AssemblyFileVersion("4.1.3")]
[assembly: AssemblyVersion("4.1.4")]
[assembly: AssemblyFileVersion("4.1.4")]
2 changes: 1 addition & 1 deletion Installer/SN.EXP.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.1.3"
#define Version "4.1.4"
#define Author "QModManager"
#define URL "https://github.com/QModManager/QModManager"
#define SupportURL "https://discord.gg/UpWuWwq"
Expand Down
2 changes: 1 addition & 1 deletion Installer/SN.STABLE.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.1.3"
#define Version "4.1.4"
#define Author "QModManager"
#define URL "https://github.com/QModManager/QModManager"
#define SupportURL "https://discord.gg/UpWuWwq"
Expand Down
4 changes: 2 additions & 2 deletions OculusNewtonsoftRedirect/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.1.3")]
[assembly: AssemblyFileVersion("4.1.3")]
[assembly: AssemblyVersion("4.1.4")]
[assembly: AssemblyFileVersion("4.1.4")]
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.1.3")]
[assembly: AssemblyFileVersion("4.1.3")]
[assembly: AssemblyVersion("4.1.4")]
[assembly: AssemblyFileVersion("4.1.4")]

[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.1.3")]
[assembly: AssemblyFileVersion("4.1.3")]
[assembly: AssemblyVersion("4.1.4")]
[assembly: AssemblyFileVersion("4.1.4")]
[assembly: NeutralResourcesLanguage("en")]

[assembly: InternalsVisibleTo("QModManager.QMMLoader")]
87 changes: 48 additions & 39 deletions QModPluginEmulator/QModPluginGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
using Newtonsoft.Json;
#endif
using QModManager.API;
using QModManager.Patching;
using QModManager.Utility;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using QModManager.API.ModLoading;
using TypeloaderCache = System.Collections.Generic.Dictionary<string, BepInEx.Bootstrap.CachedAssembly<BepInEx.PluginInfo>>;
using QMMAssemblyCache = System.Collections.Generic.Dictionary<string, long>;
using QModManager.API.ModLoading;
using System.Collections;

namespace QModManager
{
Expand Down Expand Up @@ -57,14 +58,14 @@ public static void Finish()
{
PluginCache = GetPluginCache();
Harmony = new Harmony("QModManager.QModPluginGenerator");
foreach(Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
{
if(assembly?.GetName()?.Name?.Contains("MirrorInternalLogs") ?? false)
if (assembly?.GetName()?.Name?.Contains("MirrorInternalLogs") ?? false)
{
Type type = AccessTools.TypeByName("MirrorInternalLogs.Util.LibcHelper");
var method = type?.GetMethod("Format");

if(method != null)
if (method != null)
Harmony.Patch(method, postfix: new HarmonyMethod(typeof(QModPluginGenerator), nameof(QModPluginGenerator.LibcHelper_Format_Postfix)));
break;
}
Expand All @@ -82,44 +83,51 @@ public static void Finish()
}
}

public static List<string> DirtyStartStrings = new List<string>()
{
"Resetting cell with", "Replacing cell",
"PerformGarbage", "Fallback handler could not load"
};

public static List<string> DirtyMidStrings = new List<string>()
{
"\n(Filename",
private readonly static List<Regex> DirtyRegexPatterns = new List<Regex>() {
new Regex(@"([\r\n]+)?(\(Filename: .*\))$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(Replacing cell.*)$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(Resetting cell with.*)$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(PerformGarbage.*)$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(Fallback handler could not load.*)$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(Heartbeat CSV.*,[0-9])$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(L0: PerformGarbageCollection ->.*)$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(L0: CellManager::EstimateBytes.*)$", RegexOptions.Compiled | RegexOptions.Multiline),
new Regex(@"^(Kinematic body only supports Speculative Continuous collision detection.*)$", RegexOptions.Compiled | RegexOptions.Multiline),
};

private static void LibcHelper_Format_Postfix(ref string __result)
{
foreach(string dirtyString in DirtyStartStrings)
foreach (Regex pattern in DirtyRegexPatterns)
{
if(__result.StartsWith(dirtyString))
{
__result = "";
return;
}
}

foreach(string dirtyString in DirtyMidStrings)
{
int i = __result.IndexOf(dirtyString);
if(i >= 0)
{
__result = __result.Remove(i);
return;
}
__result = pattern.Replace(__result, string.Empty).Trim();
}
}

#if SUBNAUTICA_STABLE
[HarmonyPatch(typeof(SystemsSpawner), nameof(SystemsSpawner.Awake))]
[HarmonyPrefix]
private static void PreInitializeQMM()
{
Patcher.Patch(); // Run QModManager patch

ModsToLoad = QModsToLoad.ToList();
Initializer = new Initializer(Patcher.CurrentlyRunningGame);
Initializer.InitializeMods(ModsToLoad, PatchingOrder.MetaPreInitialize);
Initializer.InitializeMods(ModsToLoad, PatchingOrder.PreInitialize);
Initializer.InitializeMods(ModsToLoad, PatchingOrder.NormalInitialize);
Initializer.InitializeMods(ModsToLoad, PatchingOrder.PostInitialize);
Initializer.InitializeMods(ModsToLoad, PatchingOrder.MetaPostInitialize);

SummaryLogger.ReportIssues(ModsToLoad);
SummaryLogger.LogSummaries(ModsToLoad);
foreach(Dialog dialog in Patcher.Dialogs)
{
dialog.Show();
}

}
#else
[HarmonyPatch(typeof(PreStartScreen), nameof(PreStartScreen.Start))]
#endif
[HarmonyPrefix]
private static void PreInitializeQMM()
{
Expand All @@ -142,10 +150,10 @@ private static void PreInitializeQMM()
), postfix: new HarmonyMethod(AccessTools.Method(typeof(QModPluginGenerator), nameof(QModPluginGenerator.InitializeQMM))));
}

#if SUBNAUTICA
#if SUBNAUTICA_EXP
private static IEnumerator InitializeQMM(IEnumerator result)
{
if(ModsToLoad != null)
if (ModsToLoad != null)
{
yield return result;

Expand All @@ -155,7 +163,7 @@ private static IEnumerator InitializeQMM(IEnumerator result)

SummaryLogger.ReportIssues(ModsToLoad);
SummaryLogger.LogSummaries(ModsToLoad);
foreach(Dialog dialog in Patcher.Dialogs)
foreach (Dialog dialog in Patcher.Dialogs)
{
dialog.Show();
}
Expand All @@ -165,7 +173,7 @@ private static IEnumerator InitializeQMM(IEnumerator result)
#elif BELOWZERO
private static void InitializeQMM()
{
if(ModsToLoad != null)
if (ModsToLoad != null)
{
Initializer.InitializeMods(ModsToLoad, PatchingOrder.NormalInitialize);
Initializer.InitializeMods(ModsToLoad, PatchingOrder.PostInitialize);
Expand All @@ -174,12 +182,13 @@ private static void InitializeQMM()
SummaryLogger.ReportIssues(ModsToLoad);
SummaryLogger.LogSummaries(ModsToLoad);

foreach(Dialog dialog in Patcher.Dialogs)
foreach (Dialog dialog in Patcher.Dialogs)
{
dialog.Show();
}
}
}
#endif
#endif

private static string[] QMMKnownAssemblyPaths = new[] {
Expand Down Expand Up @@ -254,7 +263,7 @@ private static void SaveQMMAssemblyCache()

using (var ms = new MemoryStream())
using (var writer = new StreamWriter(ms))
using(var jsreader = new JsonTextWriter(writer))
using (var jsreader = new JsonTextWriter(writer))
{
var serializer = new JsonSerializer();
serializer.Serialize(jsreader, QMMAssemblyCache);
Expand Down Expand Up @@ -283,7 +292,7 @@ private static void ClearBepInExCache()
{
Directory.Delete(BepInExCachePath, true);
}
catch(IOException e)
catch (IOException e)
{
Logger.LogDebug($"Clearing BepInEx cache failed with exception. \n{e}");
}
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.1.3")]
[assembly: AssemblyFileVersion("4.1.3")]
[assembly: AssemblyVersion("4.1.4")]
[assembly: AssemblyFileVersion("4.1.4")]

0 comments on commit c976a95

Please sign in to comment.