Skip to content

Commit dc72b39

Browse files
authored
Merge pull request #284 from SubnauticaModding/Dev
2 parents 3986b1c + 4e1df40 commit dc72b39

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+399
-107
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -291,3 +291,5 @@ __pycache__/
291291

292292
# Game Assemblies
293293
[Dd]ependencies/**/[Aa]ssemblies/
294+
*.zip
295+
*.dll
Binary file not shown.

BepinexPackages/BelowZero_Packages/QModManager/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "QModManager_BZ",
3-
"version_number": "4.4.3",
3+
"version_number": "4.4.4",
44
"website_url": "https://github.com/SubnauticaModding/QModManager",
55
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
66
"dependencies": [

BepinexPackages/BelowZero_Packages/QModManager/plugins/QModManager/QModInstaller.xml

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.

BepinexPackages/BelowZero_Packages/QModManager_Exp/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "QModManager_BZ_Experimental",
3-
"version_number": "4.4.3",
3+
"version_number": "4.4.4",
44
"website_url": "https://github.com/SubnauticaModding/QModManager",
55
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
66
"dependencies": [
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

BepinexPackages/Subnautica_Packages/QModManager/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "QModManager",
3-
"version_number": "4.4.3",
3+
"version_number": "4.4.4",
44
"website_url": "https://github.com/SubnauticaModding/QModManager",
55
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
66
"dependencies": [

BepinexPackages/Subnautica_Packages/QModManager/plugins/QModManager/QModInstaller.xml

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BepinexPackages/Subnautica_Packages/QModManager_Exp/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "QModManager_Experimental",
3-
"version_number": "4.4.3",
3+
"version_number": "4.4.4",
44
"website_url": "https://github.com/SubnauticaModding/QModManager",
55
"description": "QModManager is an intermidiate loader for mods made for the QMM system.",
66
"dependencies": [
Binary file not shown.
Binary file not shown.

Data/latest-version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.4.3
1+
4.4.4.0

OculusNewtonsoftRedirect/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("4.4.3")]
36-
[assembly: AssemblyFileVersion("4.4.3")]
35+
[assembly: AssemblyVersion("4.4.4")]
36+
[assembly: AssemblyFileVersion("4.4.4")]

QModManager/API/IQModServices.cs

+9
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,14 @@ public interface IQModServices : IQModAPI
4747
/// <c>true</c> if Nitrox is being used; otherwise, <c>false</c>.
4848
/// </value>
4949
bool NitroxRunning { get; }
50+
51+
52+
/// <summary>
53+
/// Gets a value indicating whether Piracy was detected.
54+
/// </summary>
55+
/// <value>
56+
/// <c>true</c> if Piracy was detected; otherwise, <c>false</c>.
57+
/// </value>
58+
bool PirateDetected { get; }
5059
}
5160
}

QModManager/API/QModServices.cs

+8
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,13 @@ public void AddCriticalMessage(string msg, int size = MainMenuMessages.defaultSi
157157
/// <c>true</c> if Nitrox is being used; otherwise, <c>false</c>.
158158
/// </value>
159159
public bool NitroxRunning => NitroxCheck.IsRunning;
160+
161+
/// <summary>
162+
/// Gets a value indicating whether Piracy was detected.
163+
/// </summary>
164+
/// <value>
165+
/// <c>true</c> if Piracy was detected; otherwise, <c>false</c>.
166+
/// </value>
167+
public bool PirateDetected => PirateCheck.PirateDetected;
160168
}
161169
}

QModManager/BepInex/Plugins/LogFilter.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ internal class LogFilter : BaseUnityPlugin
1313
{
1414
internal const string PluginGuid = "QModManager.LogFilter";
1515
internal const string PluginName = PluginGuid;
16-
internal const string PluginVersion = "4.4.3";
16+
internal const string PluginVersion = "4.4.4";
1717

1818
private void Awake()
1919
{

QModManager/BepInex/Plugins/QMMLoader.cs

+19-6
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
namespace QModInstaller.BepInEx.Plugins
1010
{
1111
using QModManager.API.ModLoading;
12+
using QModManager.Checks;
1213
using QModManager.Patching;
1314
using QModManager.Utility;
15+
using System;
1416

1517
/// <summary>
1618
/// QMMLoader - simply fires up the QModManager entry point.
@@ -21,11 +23,20 @@ public class QMMLoader : BaseUnityPlugin
2123
{
2224
internal const string PluginGuid = "QModManager.QMMLoader";
2325
internal const string PluginName = "QMMLoader";
24-
internal const string PluginVersion = "4.4.3";
26+
internal const string PluginVersion = "4.4.4";
2527

2628
internal static List<QMod> QModsToLoad;
2729
private static Initializer Initializer;
2830

31+
/// <summary>
32+
/// "Only for use by Bepinex"
33+
/// </summary>
34+
[Obsolete("Only for use by Bepinex", true)]
35+
public QMMLoader()
36+
{
37+
PirateCheck.IsPirate();
38+
}
39+
2940
/// <summary>
3041
/// Prevents a default instance of the <see cref="QMMLoader"/> class from being created
3142
/// Also ensures the root bepinex object does not get destroyed if the game reloads for steam.
@@ -84,13 +95,15 @@ private static IEnumerator InitializeQMods(IEnumerator result)
8495
{
8596
while (result.MoveNext())
8697
{
87-
yield return result;
98+
yield return result.Current;
8899
}
89100

90-
#if BELOWZERO
91-
if(!SpriteManager.hasInitialized)
92-
yield return new WaitUntil(()=>SpriteManager.hasInitialized);
93-
#endif
101+
var hasInitializedField = typeof(SpriteManager).GetField("hasInitialized", System.Reflection.BindingFlags.Public|System.Reflection.BindingFlags.Static);
102+
if (hasInitializedField != null)
103+
{
104+
if (!(bool)hasInitializedField.GetValue(null))
105+
yield return new WaitUntil(() => (bool)hasInitializedField.GetValue(null));
106+
}
94107

95108
Initializer.InitializeMods(QModsToLoad, PatchingOrder.NormalInitialize);
96109
Initializer.InitializeMods(QModsToLoad, PatchingOrder.PostInitialize);

QModManager/Checks/NitroxCheck.cs

+2-28
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
1-
using HarmonyLib;
2-
using System.Collections.Generic;
3-
using System.Reflection;
4-
using System.Reflection.Emit;
1+
using System;
52

63
namespace QModManager.Checks
74
{
85
internal static class NitroxCheck
96
{
10-
internal static bool IsRunning { get; set; } = false;
11-
12-
13-
[HarmonyPatch(typeof(GameInput), nameof(GameInput.Awake))]
14-
internal static class AwakePatch
15-
{
16-
internal static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
17-
{
18-
foreach (CodeInstruction instruction in instructions)
19-
{
20-
if (instruction.opcode == OpCodes.Call)
21-
{
22-
MethodInfo method = (MethodInfo)instruction.operand;
23-
24-
if (method.DeclaringType.Name == "Main" && method.Name == "Execute")
25-
{
26-
IsRunning = true;
27-
}
28-
}
29-
}
30-
31-
return instructions;
32-
}
33-
}
7+
internal static bool IsRunning => Environment.GetEnvironmentVariable("NITROX_LAUNCHER_PATH") is not null;
348
}
359
}

QModManager/Checks/PirateCheck.cs

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using Logger = QModManager.Utility.Logger;
45

56
namespace QModManager.Checks
67
{
78
internal static class PirateCheck
89
{
9-
internal static void PirateDetected()
10-
{
11-
Logger.Warn("Ahoy, matey! Ye be a pirate!");
12-
}
10+
internal static string Steamapi => "steam_api64.dll";
11+
internal static int Steamapilengh => 220000;
12+
13+
14+
internal static string folder = Environment.CurrentDirectory;
15+
internal static bool PirateDetected;
1316

1417
internal static readonly HashSet<string> CrackedFiles = new HashSet<string>()
1518
{
@@ -27,28 +30,32 @@ internal static void PirateDetected()
2730
"chuj.cdx",
2831
};
2932

30-
internal static void IsPirate(string folder)
33+
internal static void IsPirate()
3134
{
32-
string steamDll = Path.Combine(folder, "steam_api64.dll");
33-
if (File.Exists(steamDll))
35+
string steamDll = Path.Combine(folder, Steamapi);
36+
bool steamStore = File.Exists(steamDll);
37+
if (steamStore)
3438
{
3539
FileInfo fileInfo = new FileInfo(steamDll);
36-
37-
if (fileInfo.Length > 220000)
40+
if (fileInfo.Length > Steamapilengh)
3841
{
39-
PirateDetected();
40-
return;
42+
PirateDetected = true;
4143
}
4244
}
4345

44-
foreach (string file in CrackedFiles)
46+
if (!PirateDetected)
4547
{
46-
if (File.Exists(Path.Combine(folder, file)))
48+
foreach (string file in CrackedFiles)
4749
{
48-
PirateDetected();
49-
return;
50+
if (File.Exists(Path.Combine(folder, file)))
51+
{
52+
PirateDetected = true;
53+
break;
54+
}
5055
}
5156
}
57+
58+
Logger.Info(PirateDetected? "Ahoy, matey! Ye be a pirate!":"Seems Legit.");
5259
}
5360
}
5461
}

QModManager/HarmonyPatches/EnableConsoleSetting.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ internal static class DevConsole_Awake_Patch
1212
[HarmonyPostfix]
1313
internal static void Postfix()
1414
{
15-
#if BELOWZERO || SUBNAUTICA_EXP
15+
#if !SUBNAUTICA_STABLE
1616
if (PlatformUtils.GetDevToolsEnabled() != Config.EnableConsole)
1717
#else
1818
if (DevConsole.disableConsole != !Config.EnableConsole)
1919
#endif
2020
{
21-
#if BELOWZERO || SUBNAUTICA_EXP
21+
#if !SUBNAUTICA_STABLE
2222
PlatformUtils.SetDevToolsEnabled(Config.EnableConsole);
2323
#else
2424
DevConsole.disableConsole = !Config.EnableConsole;

0 commit comments

Comments
 (0)