Skip to content

Commit 56f4b84

Browse files
authored
Merge pull request #165 from SubnauticaModding/devQ3
QModManager 4.0.1 - Hotfix for version dependency issues
2 parents 42c2ade + 0700d4a commit 56f4b84

30 files changed

+259
-62
lines changed

Build/InstallerExtensions.dll

0 Bytes
Binary file not shown.

Build/QModInstaller.dll

1 KB
Binary file not shown.

Build/QModInstaller.xml

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 Bytes
Binary file not shown.

Build/QModManager.QMMLoader.dll

0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

Build/QModManager.UnityAudioFixer.dll

0 Bytes
Binary file not shown.

Build/QModManager.exe

0 Bytes
Binary file not shown.

Build/QModManager_Setup.exe

62 KB
Binary file not shown.

Build/VortexPackage.zip

703 KB
Binary file not shown.

Data/latest-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.0.0.0
1+
4.0.1.0

Executable/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
[assembly: ComVisible(false)]
1414

15-
[assembly: AssemblyVersion("4.0.0.0")]
16-
[assembly: AssemblyFileVersion("4.0.0.0")]
15+
[assembly: AssemblyVersion("4.0.1.0")]
16+
[assembly: AssemblyFileVersion("4.0.1.0")]

Installer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@
1414

1515
[assembly: Guid("8c6c9a0b-80c4-43d2-89f2-749e6f09fdda")]
1616

17-
[assembly: AssemblyVersion("4.0.0.0")]
18-
[assembly: AssemblyFileVersion("4.0.0.0")]
17+
[assembly: AssemblyVersion("4.0.1.0")]
18+
[assembly: AssemblyFileVersion("4.0.1.0")]

Installer/QModsInstallerScript.iss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#endif
66

77
#define Name "QModManager" ; The name of the game will be added after it
8-
#define Version "4.0.0"
8+
#define Version "4.0.1"
99
#define Author "QModManager"
1010
#define URL "https://github.com/QModManager/QModManager"
1111
#define SupportURL "https://discord.gg/UpWuWwq"
@@ -70,6 +70,9 @@ Source: "..\Dependencies\cldb.dat"; DestDir: "{app}\BepInEx\patchers\QModManager
7070
Source: "..\Build\QModManager.exe"; DestDir: "{app}\BepInEx\patchers\QModManager"; Flags: ignoreversion;
7171
; BepInEx
7272
Source: "..\Dependencies\BepInEx\*"; DestDir: "{app}"; Flags: recursesubdirs createallsubdirs replacesameversion sharedfile uninsnosharedfileprompt;
73+
74+
[Dirs]
75+
Name: "{app}\QMods"
7376

7477
[UninstallRun]
7578
Filename: "{app}\BepInEx\patchers\QModManager\QModManager.exe"; Parameters: "-u";

QMMHarmonyShimmer/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.0.0.0")]
37-
[assembly: AssemblyFileVersion("4.0.0.0")]
36+
[assembly: AssemblyVersion("4.0.1.0")]
37+
[assembly: AssemblyFileVersion("4.0.1.0")]
3838
[assembly: NeutralResourcesLanguage("en")]

QMMLoader/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.0.0.0")]
37-
[assembly: AssemblyFileVersion("4.0.0.0")]
36+
[assembly: AssemblyVersion("4.0.1.0")]
37+
[assembly: AssemblyFileVersion("4.0.1.0")]
3838
[assembly: NeutralResourcesLanguage("en")]

QModManager/API/RequiredQMod.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
11
namespace QModManager.API
22
{
33
using System;
4+
using QModManager.Utility;
45

56
/// <summary>
67
/// Identifies a required mod and an optional minimum version.
78
/// </summary>
89
public class RequiredQMod
910
{
10-
internal RequiredQMod(string id)
11+
internal static IVersionParser VersionParserService { get; set; } = new VersionParser();
12+
13+
private RequiredQMod(string id, bool requiresMinVersion, Version version)
1114
{
1215
this.Id = id;
13-
this.RequiresMinimumVersion = false;
14-
this.MinimumVersion = new Version();
16+
this.RequiresMinimumVersion = requiresMinVersion;
17+
this.MinimumVersion = version;
18+
}
19+
20+
internal RequiredQMod(string id)
21+
: this(id, false, VersionParserService.NoVersionParsed)
22+
{
1523
}
1624

1725
internal RequiredQMod(string id, Version minimumVersion)
26+
: this(id, !VersionParserService.IsAllZeroVersion(minimumVersion), minimumVersion)
27+
{
28+
}
29+
30+
internal RequiredQMod(string id, string minimumVersion)
31+
: this(id, !string.IsNullOrEmpty(minimumVersion), VersionParserService.GetVersion(minimumVersion))
1832
{
19-
this.Id = id;
20-
this.RequiresMinimumVersion = true;
21-
this.MinimumVersion = minimumVersion;
2233
}
2334

2435
/// <summary>

QModManager/Patching/ManifestValidator.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
internal class ManifestValidator : IManifestValidator
1414
{
15-
internal static readonly Regex VersionRegex = new Regex(@"(((\d+)\.?)+)");
15+
internal static IVersionParser VersionParserService { get; set; } = new VersionParser();
1616

1717
internal static readonly Dictionary<string, ModStatus> ProhibitedModIDs = new Dictionary<string, ModStatus>()
1818
{
@@ -29,7 +29,7 @@ public void ValidateManifest(QMod mod)
2929
if (mod.PatchMethods.Count > 0)
3030
return;
3131

32-
Logger.Debug($"Validating mod in '{mod.SubDirectory}'");
32+
Logger.Debug($"Validating mod '{mod.Id}'");
3333
if (string.IsNullOrEmpty(mod.Id) ||
3434
string.IsNullOrEmpty(mod.DisplayName) ||
3535
string.IsNullOrEmpty(mod.Author))
@@ -70,8 +70,7 @@ public void ValidateManifest(QMod mod)
7070

7171
try
7272
{
73-
if (Version.TryParse(mod.Version, out Version version))
74-
mod.ParsedVersion = version;
73+
mod.ParsedVersion = VersionParserService.GetVersion(mod.Version);
7574
}
7675
catch (Exception vEx)
7776
{
@@ -135,26 +134,27 @@ public void CheckRequiredMods(QMod mod)
135134
foreach (KeyValuePair<string, string> item in mod.VersionDependencies)
136135
{
137136
string id = item.Key;
138-
string cleanVersion = VersionRegex.Matches(item.Value)?[0]?.Value;
137+
string versionString = item.Value;
139138

140-
if (string.IsNullOrEmpty(cleanVersion))
141-
{
142-
requiredMods[id] = new RequiredQMod(id);
143-
}
144-
else if (Version.TryParse(cleanVersion, out Version version))
145-
{
146-
requiredMods[id] = new RequiredQMod(id, version);
147-
}
148-
else if (!requiredMods.ContainsKey(id))
149-
{
150-
requiredMods[id] = new RequiredQMod(id);
151-
}
139+
Version version = VersionParserService.GetVersion(versionString);
140+
141+
requiredMods[id] = new RequiredQMod(id, version);
152142

153143
mod.RequiredDependencies.Add(id);
154144
}
155145
}
156146

157147
mod.RequiredMods = requiredMods.Values;
148+
if (Logger.DebugLogsEnabled && requiredMods.Count > 0)
149+
{
150+
string msg = $"{mod.Id} has required mods: ";
151+
foreach (var required in requiredMods.Values)
152+
{
153+
msg += $"{required.Id} ";
154+
}
155+
156+
Logger.Debug(msg);
157+
}
158158
}
159159

160160
internal ModStatus FindPatchMethods(QMod qMod)

QModManager/Patching/QModFactory.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ private void ValidateDependencies(List<QMod> modsToLoad, QMod mod)
141141
continue;
142142
}
143143

144+
if (dependencyQMod.HasDependencies)
145+
{
146+
ValidateDependencies(modsToLoad, dependencyQMod);
147+
}
148+
144149
if (dependencyQMod.LoadedAssembly == null)
145150
{
146151
// Dependency hasn't been validated yet

QModManager/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
[assembly: ComVisible(false)]
1515

16-
[assembly: AssemblyVersion("4.0.0.0")]
17-
[assembly: AssemblyFileVersion("4.0.0.0")]
16+
[assembly: AssemblyVersion("4.0.1.0")]
17+
[assembly: AssemblyFileVersion("4.0.1.0")]
1818

1919
[assembly: InternalsVisibleTo("QMMTests")]
2020
[assembly: InternalsVisibleTo("QModManager")]

QModManager/QModManager.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@
183183
<Compile Include="Utility\NetworkUtilities.cs" />
184184
<Compile Include="Utility\ReflectionHelper.cs" />
185185
<Compile Include="Checks\VersionCheck.cs" />
186+
<Compile Include="Utility\VersionParser.cs" />
186187
</ItemGroup>
187188
<ItemGroup />
188189
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

QModManager/Utility/Dialog.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ internal class Button
2525
internal static readonly Button Disabled = new Button();
2626
internal static readonly Button SeeLog = new Button("See Log", () =>
2727
{
28-
string logPath = Application.consoleLogPath;
28+
string gameSuffix = "Subnautica";
29+
if (Patcher.CurrentlyRunningGame == QModGame.BelowZero)
30+
gameSuffix += "Zero";
31+
32+
string logPath = Path.Combine(Environment.CurrentDirectory, $"qmodmanager_log-{gameSuffix}.txt");
2933

3034
Logger.Debug($"Opening log file located in: \"{logPath}\"");
3135

QModManager/Utility/VersionParser.cs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
namespace QModManager.Utility
2+
{
3+
using System;
4+
using System.Text.RegularExpressions;
5+
6+
/// <summary>
7+
/// Defines a service for parsing version strings.
8+
/// </summary>
9+
public interface IVersionParser
10+
{
11+
/// <summary>
12+
/// The default version zero used when no version could be parsed.
13+
/// </summary>
14+
Version NoVersionParsed { get; }
15+
16+
/// <summary>
17+
/// Returns a new <see cref="Version"/> based on the provided string value, with all 4 groups populated.
18+
/// </summary>
19+
/// <param name="versionString">The version string to parse.</param>
20+
/// <returns>A new <see cref="Version"/> with all empty groups populated with 0.</returns>
21+
Version GetVersion(string versionString);
22+
23+
/// <summary>
24+
/// Checks if the provided version is all zeros.
25+
/// </summary>
26+
/// <param name="version">The version to check.</param>
27+
/// <returns>True if this matches version 0.0.0.0</returns>
28+
bool IsAllZeroVersion(Version version);
29+
}
30+
31+
/// <summary>
32+
/// A service that handles parsing <see cref="string"/> values into <see cref="Version"/> objects.
33+
/// </summary>
34+
public class VersionParser : IVersionParser
35+
{
36+
private static readonly Version VersionZeroSingleton = new Version(0, 0, 0, 0);
37+
38+
/// <summary>
39+
/// The regex used to sanitize incoming version strings.
40+
/// ^(((\d+)\.?){0,3}\d+)$
41+
/// </summary>
42+
public static readonly Regex VersionRegex = new Regex(@"^(((\d+)\.?){0,3}\d+)$");
43+
44+
/// <summary>
45+
/// The default version zero used when no version could be parsed.
46+
/// </summary>
47+
public Version NoVersionParsed => new Version(0, 0, 0, 0);
48+
49+
/// <summary>
50+
/// Returns a new <see cref="Version"/> based on the provided string value, with all 4 groups populated.
51+
/// </summary>
52+
/// <param name="versionString">The version string to parse. This must match <seealso cref="VersionRegex"/>.</param>
53+
/// <returns>A new <see cref="Version"/> with all empty groups populated with 0.</returns>
54+
/// <example>
55+
/// "2.8" will be parsed as "2.8.0.0"
56+
/// </example>
57+
public Version GetVersion(string versionString)
58+
{
59+
if (!VersionRegex.IsMatch(versionString))
60+
{
61+
return NoVersionParsed;
62+
}
63+
64+
versionString = VersionRegex.Matches(versionString)?[0]?.Value;
65+
66+
int groups = versionString.Split('.').Length;
67+
while (groups++ < 4)
68+
{
69+
versionString += ".0";
70+
}
71+
72+
if (Version.TryParse(versionString, out Version parsedVersion))
73+
{
74+
return parsedVersion;
75+
}
76+
77+
return NoVersionParsed;
78+
}
79+
80+
/// <summary>
81+
/// Checks if the provided version is all zeros.
82+
/// </summary>
83+
/// <param name="version">The version to check.</param>
84+
/// <returns>True if this matches version 0.0.0.0</returns>
85+
public bool IsAllZeroVersion(Version version)
86+
{
87+
return version == VersionZeroSingleton;
88+
}
89+
}
90+
}

QModPluginEmulator/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
// You can specify all the values or you can default the Build and Revision Numbers
3434
// by using the '*' as shown below:
3535
// [assembly: AssemblyVersion("1.0.*")]
36-
[assembly: AssemblyVersion("4.0.0.0")]
37-
[assembly: AssemblyFileVersion("4.0.0.0")]
36+
[assembly: AssemblyVersion("4.0.1.0")]
37+
[assembly: AssemblyFileVersion("4.0.1.0")]
3838
[assembly: NeutralResourcesLanguage("en")]
3939

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

0 commit comments

Comments
 (0)