Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QModManager_BZ",
"version_number": "4.4.4",
"version_number": "4.5.0",
"website_url": "https://github.com/SubnauticaModding/QModManager",
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QModManager_BZ_Experimental",
"version_number": "4.4.4",
"version_number": "4.5.0",
"website_url": "https://github.com/SubnauticaModding/QModManager",
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QModManager",
"version_number": "4.4.4",
"version_number": "4.5.0",
"website_url": "https://github.com/SubnauticaModding/QModManager",
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QModManager_Experimental",
"version_number": "4.4.4",
"version_number": "4.5.0",
"website_url": "https://github.com/SubnauticaModding/QModManager",
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
"dependencies": [
Expand Down
2 changes: 1 addition & 1 deletion Data/latest-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.4.4.0
4.5.0.0
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.4.4")]
[assembly: AssemblyFileVersion("4.4.4")]
[assembly: AssemblyVersion("4.5.0")]
[assembly: AssemblyFileVersion("4.5.0")]
2 changes: 1 addition & 1 deletion QModManager/BepInex/Plugins/LogFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class LogFilter : BaseUnityPlugin
{
internal const string PluginGuid = "QModManager.LogFilter";
internal const string PluginName = PluginGuid;
internal const string PluginVersion = "4.4.4";
internal const string PluginVersion = "4.5.0";

private void Awake()
{
Expand Down
17 changes: 1 addition & 16 deletions QModManager/BepInex/Plugins/QMMLoader.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using BepInEx;
#if !SUBNAUTICA_STABLE
using HarmonyLib;
using System.Collections;
#endif
using System.Collections.Generic;
using UnityEngine;

Expand All @@ -23,7 +21,7 @@ public class QMMLoader : BaseUnityPlugin
{
internal const string PluginGuid = "QModManager.QMMLoader";
internal const string PluginName = "QMMLoader";
internal const string PluginVersion = "4.4.4";
internal const string PluginVersion = "4.5.0";

internal static List<QMod> QModsToLoad;
private static Initializer Initializer;
Expand Down Expand Up @@ -70,18 +68,6 @@ private void PreInitializeQMods()
Initializer.InitializeMods(QModsToLoad, PatchingOrder.MetaPreInitialize);
Initializer.InitializeMods(QModsToLoad, PatchingOrder.PreInitialize);

#if SUBNAUTICA_STABLE
Initializer.InitializeMods(QModsToLoad, PatchingOrder.NormalInitialize);
Initializer.InitializeMods(QModsToLoad, PatchingOrder.PostInitialize);
Initializer.InitializeMods(QModsToLoad, PatchingOrder.MetaPostInitialize);

SummaryLogger.ReportIssues(QModsToLoad);
SummaryLogger.LogSummaries(QModsToLoad);
foreach (Dialog dialog in Patcher.Dialogs)
{
dialog.Show();
}
#else
var harmony = new Harmony(PluginGuid);
harmony.Patch(
AccessTools.Method(
Expand Down Expand Up @@ -115,7 +101,6 @@ private static IEnumerator InitializeQMods(IEnumerator result)
{
dialog.Show();
}
#endif
}
}
}
2 changes: 0 additions & 2 deletions QModManager/HarmonyPatches/DisableDevErrorReporting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ internal static bool Prefix(SentrySdk __instance)
return false;
}

#if !SUBNAUTICA_STABLE
[HarmonyPostfix]
[HarmonyPatch(typeof(SystemsSpawner), nameof(SystemsSpawner.SetupSingleton))]
internal static IEnumerator Postfix(IEnumerator enumerator)
{
yield return null;
yield break;
}
#endif
}
}
27 changes: 0 additions & 27 deletions QModManager/HarmonyPatches/EnableConsoleSetting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{
using HarmonyLib;
using QModManager.Utility;
using UnityEngine;

[HarmonyPatch(typeof(DevConsole), nameof(DevConsole.Awake))]
internal static class DevConsole_Awake_Patch
Expand All @@ -12,36 +11,10 @@ internal static class DevConsole_Awake_Patch
[HarmonyPostfix]
internal static void Postfix()
{
#if !SUBNAUTICA_STABLE
if (PlatformUtils.GetDevToolsEnabled() != Config.EnableConsole)
#else
if (DevConsole.disableConsole != !Config.EnableConsole)
#endif
{
#if !SUBNAUTICA_STABLE
PlatformUtils.SetDevToolsEnabled(Config.EnableConsole);
#else
DevConsole.disableConsole = !Config.EnableConsole;
PlayerPrefs.SetInt("UWE.DisableConsole", Config.EnableConsole ? 0 : 1);
#endif
}
}
}

#if SUBNAUTICA_STABLE // the toggle is removed in Subnautica.exp and BelowZero
[HarmonyPatch(typeof(PlayerPrefsUtils), nameof(PlayerPrefsUtils.PrefsToggle))]
internal static class PlayerPrefsUtils_PrefsToggle_Patch
{
// This patch syncronizes the "Disable console" UI element in the F3 debug menu

[HarmonyPostfix]
public static void Postfix(bool defaultVal, string key, string label, ref bool __result)
{
if (key == "UWE.DisableConsole")
{
Config.EnableConsole = !__result;
}
}
}
#endif
}
71 changes: 37 additions & 34 deletions QModManager/HarmonyPatches/MaskTelemetryLogging.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,54 @@
namespace QModManager.HarmonyPatches
{
using HarmonyLib;
using QModManager.Utility;
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;

//transpiller
using System.Collections.Generic;
using System.Reflection.Emit;

#if BELOWZERO
[HarmonyPatch(typeof(Telemetry),MethodType.Enumerator)]
[HarmonyPatch(nameof(Telemetry.SendSesionStart))]
[HarmonyPatch(typeof(Telemetry), nameof(Telemetry.SendSesionStart))]
static class MaskTelemetryLogging
{
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
public static IEnumerator Postfix(IEnumerator values, Telemetry __instance, string setPlatformName, string setUserId)
{
string thistranspiler = "Telemetry_SendSesionStart";
Logger.Log(Logger.Level.Debug, $"{thistranspiler} - Start Transpiler");
var Index = -1;
var codes = new List<CodeInstruction>(instructions);

//analyse the code to find the right place for injection
for (var i = 0; i < codes.Count; i++)
yield return __instance.platformServices.TryEnsureServerAccessAsync(false);
if (!__instance.platformServices.CanAccessServers())
{
//determinde the check to find the right place and not missmatch it accidentally with a other one
if (codes[i].opcode == OpCodes.Ldstr && codes[i + 17].opcode == OpCodes.Box && codes[i + 21].opcode == OpCodes.Ret)
{
Index = i;
break;
}
yield break;
}

//Check if Index was changed to any other Value. If yes the Position was likely found.
if (Index > -1)
__instance.platformName = (string.IsNullOrEmpty(setPlatformName) ? "Null" : setPlatformName);
__instance.userId = (string.IsNullOrEmpty(setUserId) ? "Null" : setUserId);
__instance.csId = SNUtils.GetPlasticChangeSetOfBuild(0);
WWWForm wwwform = new WWWForm();
wwwform.AddField("product_id", Telemetry.productId);
wwwform.AddField("platform", __instance.platformName);
wwwform.AddField("platform_user_id", __instance.userId);
wwwform.AddField("cs_id", __instance.csId);
wwwform.AddField("language", Language.main.GetCurrentLanguage());
wwwform.AddField("arguments", string.Join(", ", Environment.GetCommandLineArgs()));
wwwform.AddField("used_cheats", DevConsole.HasUsedConsole().ToString());
wwwform.AddField("gpu_name", SystemInfo.graphicsDeviceName);
wwwform.AddField("gpu_memory", SystemInfo.graphicsMemorySize);
wwwform.AddField("gpu_api", SystemInfo.graphicsDeviceType.ToString());
wwwform.AddField("cpu_name", SystemInfo.processorType);
wwwform.AddField("system_memory", SystemInfo.systemMemorySize);
wwwform.AddField("system_os", SystemInfo.operatingSystem);
wwwform.AddField("quality", QualitySettings.GetQualityLevel());
wwwform.AddField("res_x", Screen.width);
wwwform.AddField("res_y", Screen.height);
UnityWebRequest webRequest = UnityWebRequest.Post(string.Format("{0}/session-start", "https://analytics.unknownworlds.com/api"), wwwform);
yield return webRequest.SendWebRequest();
if (webRequest.isNetworkError || webRequest.isHttpError)
{
Logger.Log(Logger.Level.Debug, $"{thistranspiler} - Transpiler injection position found");
codes[Index] = new CodeInstruction(OpCodes.Ldstr, "Telemetry session started. Platform: '{0}', UserId: ->Masked by QModManager for privacy Reason<-, SessionId: {1}");
codes.RemoveRange(Index, 0);
codes.RemoveRange(Index+10, 5);
Debug.LogError(webRequest.error);
}
else
{
Logger.Log(Logger.Level.Error, $"{thistranspiler} - Index was not found");
SessionStartResponse sessionStartResponse = SessionStartResponse.CreateFromJSON(webRequest.downloadHandler.text);
__instance.sessionId = sessionStartResponse.session_id;
Debug.LogFormat("Telemetry session started. Platform: '{0}', UserId: ->Masked by QModManager for privacy reason<-, SessionId: {1}", new object[] { __instance.platformName, __instance.sessionId });
}

return codes;
yield break;
}
}
#endif
}
10 changes: 0 additions & 10 deletions QModManager/OptionsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@ internal static void Postfix(uGUI_OptionsPanel __instance)
AddToggleOption.Invoke(__instance, new object[] { ModsTab, "Enable console", Config.EnableConsole, new UnityAction<bool>(value =>
{
Config.EnableConsole = value;
#if SUBNAUTICA_STABLE
DevConsole.disableConsole = !value;
UnityEngine.PlayerPrefs.SetInt("UWE.DisableConsole", value ? 0 : 1);
#elif BELOWZERO || SUBNAUTICA_EXP
PlatformUtils.SetDevToolsEnabled(value);
#endif
}) });

AddToggleOption.Invoke(__instance, new object[] { ModsTab, "Enable debug logs", Config.EnableDebugLogs, new UnityAction<bool>(value => Config.EnableDebugLogs = value) });
Expand All @@ -49,12 +44,7 @@ internal static void Postfix(uGUI_OptionsPanel __instance)
AddToggleOption.Invoke(__instance, new object[] { ModsTab, "Enable console", Config.EnableConsole, new UnityAction<bool>(value =>
{
Config.EnableConsole = value;
#if SUBNAUTICA_STABLE
DevConsole.disableConsole = !value;
UnityEngine.PlayerPrefs.SetInt("UWE.DisableConsole", value ? 0 : 1);
#elif BELOWZERO || SUBNAUTICA_EXP
PlatformUtils.SetDevToolsEnabled(value);
#endif
}), null });

AddToggleOption.Invoke(__instance, new object[] { ModsTab, "Enable debug logs", Config.EnableDebugLogs, new UnityAction<bool>(value => Config.EnableDebugLogs = value), null });
Expand Down
6 changes: 1 addition & 5 deletions QModManager/Patching/GameDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ internal class GameDetector
/// </summary>
private static readonly Dictionary<QModGame, int> SupportedGameVersions = new Dictionary<QModGame, int>
{
#if SUBNAUTICA_STABLE
{ QModGame.Subnautica, 65786 }
#else
{ QModGame.BelowZero, 49184 },
{ QModGame.Subnautica, 68186 }
#endif
{ QModGame.Subnautica, 71137 }
};

internal bool IsValidGameRunning => SupportedGameVersions.ContainsKey(CurrentlyRunningGame);
Expand Down
4 changes: 0 additions & 4 deletions QModManager/Patching/QMod.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
namespace QModManager.Patching
{
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif
using QModManager.API;
using QModManager.DataStructures;
using System;
Expand Down
4 changes: 0 additions & 4 deletions QModManager/Patching/QModFactory.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
namespace QModManager.Patching
{
using BepInEx;
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif
using QModManager.API;
using QModManager.DataStructures;
using QModManager.Utility;
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.4.4")]
[assembly: AssemblyFileVersion("4.4.4")]
[assembly: AssemblyVersion("4.5.0")]
[assembly: AssemblyFileVersion("4.5.0")]

[assembly: InternalsVisibleTo("QMMTests")]
[assembly: InternalsVisibleTo("QModManager")]
Expand Down
4 changes: 0 additions & 4 deletions QModManager/Utility/Config.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
namespace QModManager.Utility
{
#if SUBNAUTICA_STABLE
using Oculus.Newtonsoft.Json;
#else
using Newtonsoft.Json;
#endif
using System;
using System.Collections.Generic;
using System.IO;
Expand Down
12 changes: 5 additions & 7 deletions QModManager/Utility/MainMenuMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,9 @@ static IEnumerator _waitForLoad()
yield return new WaitForSeconds(1f);

yield return new WaitWhile(() => SaveLoadManager.main.isLoading);
#if SUBNAUTICA_STABLE
float time = Time.time;
#else

float time = PDA.time;
#endif

messages.ForEach(msg => msg.timeEnd = time + 1f);
yield return new WaitForSeconds(1.1f); // wait for messages to dissapear

Expand Down Expand Up @@ -191,7 +189,7 @@ public static void Unpatch()
Patcher.hInstance.Unpatch(AccessTools.Method(typeof(ErrorMessage), nameof(ErrorMessage.Awake)),
HarmonyPatchType.Postfix, Patcher.hInstance.Id);

Patcher.hInstance.Unpatch(AccessTools.Method(typeof(ErrorMessage), nameof(ErrorMessage.OnUpdate)),
Patcher.hInstance.Unpatch(AccessTools.Method(typeof(ErrorMessage), nameof(ErrorMessage.OnLateUpdate)),
HarmonyPatchType.Transpiler, Patcher.hInstance.Id);
}

Expand All @@ -212,7 +210,7 @@ private static void ErrorMessage_Awake_Postfix()

// we changing result for 'float value = Mathf.Clamp01(MathExtensions.EvaluateLine(...' to 1.0f
// so text don't stay in the center of the screen (because of changed 'timeEnd')
[HarmonyTranspiler, HarmonyPatch(typeof(ErrorMessage), nameof(ErrorMessage.OnUpdate))]
[HarmonyTranspiler, HarmonyPatch(typeof(ErrorMessage), nameof(ErrorMessage.OnLateUpdate))]
private static IEnumerable<CodeInstruction> ErrorMessage_OnUpdate_Transpiler(IEnumerable<CodeInstruction> cins)
{
try
Expand All @@ -233,7 +231,7 @@ private static IEnumerable<CodeInstruction> ErrorMessage_OnUpdate_Transpiler(IEn
}
catch (Exception e)
{
Logger.Error($"Failed to patch ErrorMessage.OnUpdate() ({e})");
Logger.Error($"Failed to patch ErrorMessage.OnLateUpdate() ({e})");
return cins;
}
}
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.4.4")]
[assembly: AssemblyFileVersion("4.4.4")]
[assembly: AssemblyVersion("4.5.0")]
[assembly: AssemblyFileVersion("4.5.0")]
[assembly: NeutralResourcesLanguage("en")]

[assembly: InternalsVisibleTo("QModManager.QMMLoader")]
Loading