Skip to content

Commit c568673

Browse files
authored
Merge pull request #128 from SubnauticaModding/QMM301BugFix
QModManager 3.0.1 bug fix
2 parents 35a90d7 + 89aa4fd commit c568673

18 files changed

+154
-20
lines changed

Build/InstallerExtensions.dll

0 Bytes
Binary file not shown.

Build/QModInstaller.dll

512 Bytes
Binary file not shown.

Build/QModInstaller.xml

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

Build/QModManager.exe

0 Bytes
Binary file not shown.

Build/QModManager_Setup.exe

361 Bytes
Binary file not shown.

Data/latest-version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
3.0.1

Executable/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212

1313
[assembly: ComVisible(false)]
1414

15-
[assembly: AssemblyVersion("3.0")]
16-
[assembly: AssemblyFileVersion("3.0")]
15+
[assembly: AssemblyVersion("3.0.1")]
16+
[assembly: AssemblyFileVersion("3.0.1")]

Installer/Properties/AssemblyInfo.cs

+2-2
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("3.0")]
18-
[assembly: AssemblyFileVersion("3.0")]
17+
[assembly: AssemblyVersion("3.0.1")]
18+
[assembly: AssemblyFileVersion("3.0.1")]

Installer/QModsInstallerScript.iss

+1-1
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 "3.0"
8+
#define Version "3.0.1"
99
#define Author "QModManager"
1010
#define URL "https://github.com/QModManager/QModManager"
1111
#define SupportURL "https://discord.gg/UpWuWwq"

QModManager.sln

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29102.190
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.28307.960
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Executable", "Executable\Executable.csproj", "{E00B7FE8-0F1D-4AE6-9E47-4BFD81537F14}"
77
EndProject
@@ -11,6 +11,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unit Tests", "Unit Tests\Un
1111
EndProject
1212
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstallerExtensions", "Installer\InstallerExtensions.csproj", "{92726127-A08F-4843-BF96-4989CE1BF422}"
1313
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5A8D179E-C749-4346-AD81-05F11C082A1C}"
15+
ProjectSection(SolutionItems) = preProject
16+
Data\latest-version.txt = Data\latest-version.txt
17+
Installer\QModsInstallerScript.iss = Installer\QModsInstallerScript.iss
18+
EndProjectSection
19+
EndProject
1420
Global
1521
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1622
Debug|Any CPU = Debug|Any CPU

QModManager/Patching/IQModFactory.cs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System.Collections.Generic;
2+
3+
namespace QModManager.Patching
4+
{
5+
internal interface IQModFactory
6+
{
7+
/// <summary>
8+
/// Searches through all folders in the provided directory and returns an ordered list of mods to load.<para/>
9+
/// Mods that cannot be loaded will have an unsuccessful <see cref="QMod.Status"/> value.
10+
/// </summary>
11+
/// <param name="qmodsDirectory">The QMods directory</param>
12+
/// <returns>A new, sorted <see cref="List{QMod}"/> ready to be initialized or skipped.</returns>
13+
List<QMod> BuildModLoadingList(string qmodsDirectory);
14+
}
15+
}

QModManager/Patching/ManifestValidator.cs

+2
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public ModStatus ValidateManifest(QMod mod, string subDirectory)
113113
versionedDependencies.Add(new RequiredQMod(item.Key));
114114
}
115115
}
116+
117+
mod.RequiredMods = versionedDependencies;
116118
}
117119

118120
if (!mod.Enable)

QModManager/Patching/Patcher.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ internal static void Patch()
4747
Patched = true;
4848

4949
Logger.Info($"Loading QModManager v{Assembly.GetExecutingAssembly().GetName().Version.ToStringParsed()}...");
50+
Logger.Info($"Today is {DateTime.Today:dd-MMMM-yyyy}");
5051

5152
if (QModBaseDir == null)
5253
{
@@ -97,7 +98,7 @@ internal static void Patch()
9798

9899
AddAssemblyResolveEvent();
99100

100-
var modFactory = new QModFactory();
101+
IQModFactory modFactory = new QModFactory();
101102
List<QMod> modsToLoad = modFactory.BuildModLoadingList(QModBaseDir);
102103

103104
QModServices.LoadKnownMods(modsToLoad);
@@ -111,7 +112,7 @@ internal static void Patch()
111112
{
112113
if (mod.IsLoaded)
113114
loadedMods++;
114-
else
115+
else if (mod.Enable)
115116
erroredMods++;
116117
}
117118

@@ -120,7 +121,11 @@ internal static void Patch()
120121
Logger.Info($"Finished loading QModManager. Loaded {loadedMods} mods");
121122

122123
if (ErrorModCount > 0)
123-
Logger.Warn($"A total of {ErrorModCount} mods failed to load");
124+
{
125+
string msg = $"A total of {ErrorModCount} mods failed to load";
126+
Logger.Warn(msg);
127+
Dialog.Show(msg + "\nSee log file for details.", Dialog.Button.close, Dialog.Button.Disabled, false);
128+
}
124129

125130
SummaryLogger.LogSummaries(modsToLoad);
126131
}

QModManager/Patching/QModFactory.cs

+11-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99
using QModManager.DataStructures;
1010
using QModManager.Utility;
1111

12-
internal class QModFactory
12+
internal class QModFactory : IQModFactory
1313
{
1414
internal static readonly ManifestValidator Validator = new ManifestValidator();
1515

16-
internal List<QMod> BuildModLoadingList(string qmodsDirectory)
16+
/// <summary>
17+
/// Searches through all folders in the provided directory and returns an ordered list of mods to load.<para/>
18+
/// Mods that cannot be loaded will have an unsuccessful <see cref="QMod.Status"/> value.
19+
/// </summary>
20+
/// <param name="qmodsDirectory">The QMods directory</param>
21+
/// <returns>A new, sorted <see cref="List{QMod}"/> ready to be initialized or skipped.</returns>
22+
public List<QMod> BuildModLoadingList(string qmodsDirectory)
1723
{
1824
if (!Directory.Exists(qmodsDirectory))
1925
{
@@ -68,12 +74,10 @@ internal List<QMod> BuildModLoadingList(string qmodsDirectory)
6874

6975
List<QMod> modsToLoad = modSorter.GetSortedList();
7076

71-
List<QMod> modList = CreateModStatusList(earlyErrors, modsToLoad);
72-
73-
return modList;
77+
return CreateModStatusList(earlyErrors, modsToLoad);
7478
}
7579

76-
private static List<QMod> CreateModStatusList(List<QMod> earlyErrors, List<QMod> modsToLoad)
80+
internal static List<QMod> CreateModStatusList(List<QMod> earlyErrors, List<QMod> modsToLoad)
7781
{
7882
var modList = new List<QMod>(modsToLoad.Count + earlyErrors.Count);
7983

@@ -99,7 +103,7 @@ private static List<QMod> CreateModStatusList(List<QMod> earlyErrors, List<QMod>
99103

100104
foreach (RequiredQMod requiredMod in mod.RequiredMods)
101105
{
102-
QMod dependency = modList.Find(d => d.Id == requiredMod.Id);
106+
QMod dependency = modsToLoad.Find(d => d.Id == requiredMod.Id);
103107

104108
if (dependency == null || dependency.Status != ModStatus.Success)
105109
{

QModManager/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
[assembly: ComVisible(false)]
1515

16-
[assembly: AssemblyVersion("3.0.0")]
17-
[assembly: AssemblyFileVersion("3.0.0")]
16+
[assembly: AssemblyVersion("3.0.1")]
17+
[assembly: AssemblyFileVersion("3.0.1")]
1818

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

QModManager/QModManager.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@
139139
<Compile Include="Patching\FatalPatchingException.cs" />
140140
<Compile Include="Patching\GameDetector.cs" />
141141
<Compile Include="Patching\Initializer.cs" />
142+
<Compile Include="Patching\IQModFactory.cs" />
142143
<Compile Include="Patching\ManifestValidator.cs" />
143144
<Compile Include="Patching\Patcher.cs" />
144145
<Compile Include="Patching\IQModSerialiable.cs" />

Unit Tests/QModFactoryTests.cs

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
namespace QMMTests
2+
{
3+
using System;
4+
using System.Collections.Generic;
5+
using NUnit.Framework;
6+
using QModManager.API;
7+
using QModManager.API.ModLoading;
8+
using QModManager.Patching;
9+
10+
[TestFixture]
11+
internal class QModFactoryTests
12+
{
13+
[Test]
14+
public void CreateModStatusList_EarlyErrorsCombineWithSuccessfullMods()
15+
{
16+
// Arange
17+
var earlyErrors = new List<QMod>
18+
{
19+
new QMod {Id = "1", Status = ModStatus.CanceledByUser },
20+
new QMod {Id = "2", Status = ModStatus.InvalidCoreInfo },
21+
new QMod {Id = "3", Status = ModStatus.MissingAssemblyFile },
22+
new QMod {Id = "4", Status = ModStatus.MissingDependency },
23+
new QMod {Id = "5", Status = ModStatus.MissingPatchMethod },
24+
};
25+
26+
var modsToLoad = new List<QMod>
27+
{
28+
new QMod { Id = "6", Status = ModStatus.Success },
29+
new QMod { Id = "7", Status = ModStatus.Success },
30+
new QMod { Id = "8", Status = ModStatus.Success },
31+
};
32+
33+
// Act
34+
List<QMod> combinedList = QModFactory.CreateModStatusList(earlyErrors, modsToLoad);
35+
36+
Assert.AreEqual(earlyErrors.Count + modsToLoad.Count, combinedList.Count);
37+
38+
foreach (QMod erroredMod in earlyErrors)
39+
Assert.IsTrue(combinedList.Contains(erroredMod));
40+
41+
foreach (QMod readyMod in modsToLoad)
42+
Assert.IsTrue(combinedList.Contains(readyMod));
43+
}
44+
45+
[TestCase("0", ModStatus.MissingDependency)]
46+
[TestCase("5", ModStatus.MissingDependency)]
47+
[TestCase("7", ModStatus.OutOfDateDependency)]
48+
public void CreateModStatusList_WhenMissingVersionDependencies_StatusUpdates(string missingOrOutdatedMod, ModStatus expectedStatus)
49+
{
50+
// Arange
51+
var earlyErrors = new List<QMod>
52+
{
53+
new QMod {Id = "5", Status = ModStatus.MissingPatchMethod },
54+
};
55+
56+
var modToInspect = new QMod
57+
{
58+
Id = "8",
59+
Status = ModStatus.Success,
60+
RequiredMods = new List<RequiredQMod>
61+
{
62+
new RequiredQMod(missingOrOutdatedMod, new Version(1, 0, 2))
63+
}
64+
};
65+
66+
var modsToLoad = new List<QMod>
67+
{
68+
new QMod { Id = "6", Status = ModStatus.Success },
69+
new QMod
70+
{
71+
Id = "7", Status = ModStatus.Success,
72+
ParsedVersion = new Version(1, 0, 1)
73+
},
74+
modToInspect
75+
};
76+
77+
// Act
78+
List<QMod> combinedList = QModFactory.CreateModStatusList(earlyErrors, modsToLoad);
79+
80+
// Assert
81+
Assert.AreEqual(expectedStatus, modToInspect.Status);
82+
}
83+
}
84+
}

Unit Tests/Unit Tests.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
</ItemGroup>
5959
<ItemGroup>
6060
<Compile Include="ModLoadingSimulationTests.cs" />
61+
<Compile Include="QModFactoryTests.cs" />
6162
<Compile Include="SortedTreeTests.cs" />
6263
<Compile Include="Properties\AssemblyInfo.cs" />
6364
<Compile Include="TestPatchClass.cs" />

0 commit comments

Comments
 (0)