Skip to content

Commit

Permalink
Merge pull request #290 from SubnauticaModding/dev
Browse files Browse the repository at this point in the history
2.15.0.1 Hotfix for KnownTech.Analyze null ref exception with custom scannables
  • Loading branch information
MrPurple6411 authored Dec 27, 2022
2 parents 0933048 + 487eb4c commit f3d5de3
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Example mod/Mod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ private const string
MODNAME = "SMLHelper",
AUTHOR = "The SMLHelper Dev Team",
GUID = "SMLHelperExampleMod",
VERSION = "2.15.0.0";
VERSION = "2.15.0.1";

internal static ManualLogSource LogSource { get; private set; }

Expand Down
5 changes: 4 additions & 1 deletion SMLHelper/Handlers/KnownTechHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ internal void AddAnalysisTech(TechType techTypeToBeAnalysed, IEnumerable<TechTyp
unlockMessage = UnlockMessage,
unlockSound = UnlockSound,
unlockPopup = UnlockSprite,
unlockTechTypes = new List<TechType>(techTypesToUnlock)
unlockTechTypes = new List<TechType>(techTypesToUnlock),
//Secondary fix for null ref exception caused by Subnautica 2.0 moving story goal initialization
//Maybe one day we expand this to actually be able to add list of StoryGoals from mods or base game???
storyGoals = new()
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class Initializer: BaseUnityPlugin
private const string
MODNAME = "SMLHelper",
GUID = "com.ahk1221.smlhelper",
VERSION = "2.15.0.0";
VERSION = "2.15.0.1";

internal static readonly Harmony harmony = new Harmony(GUID);

Expand Down
11 changes: 6 additions & 5 deletions SMLHelper/Patchers/KnownTechPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ internal static void InitializePostfix()
}
}

foreach (KnownTech.AnalysisTech tech in techToAdd)
List<KnownTech.AnalysisTech> validatedTechsToAdd = KnownTech.ValidateAnalysisTech(new(techToAdd));
foreach (KnownTech.AnalysisTech tech in validatedTechsToAdd)
{
if (tech == null)
continue;
Expand All @@ -86,18 +87,18 @@ internal static void InitializePostfix()
analysisTech.Add(tech);
}

List<KnownTech.CompoundTech> compoundTech = KnownTech.compoundTech;
foreach (KnownTech.CompoundTech customTech in CompoundTech.Values)
List <KnownTech.CompoundTech> validatedCompoundTeches = KnownTech.ValidateCompoundTech(new(CompoundTech.Values));
foreach (KnownTech.CompoundTech customTech in validatedCompoundTeches)
{
if (customTech == null) // Safety check
continue;

// Only add the new compound tech if it isn't unlocked yet
if (!KnownTech.Contains(customTech.techType))
compoundTech.Add(customTech);
KnownTech.compoundTech.Add(customTech);

// If a compound tech already exists, set the dependencies correctly.
var foundTech = compoundTech.Find(tech => tech.techType == customTech.techType);
var foundTech = KnownTech.compoundTech.Find(tech => tech.techType == customTech.techType);
if (foundTech != null)
foundTech.dependencies = customTech.dependencies;
}
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/BZ.EXP/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SMLHelper_BZ_Experimental",
"version_number": "2.15.0000",
"version_number": "2.15.0001",
"website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki",
"description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.",
"dependencies": [ "Subnautica_Modding-BepInExPack-5.4.2101" ]
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/BZ.STABLE/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SMLHelper_BZ",
"version_number": "2.15.0000",
"version_number": "2.15.0001",
"website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki",
"description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.",
"dependencies": [ "Subnautica_Modding-BepInExPack-5.4.2101" ]
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/SN.EXP/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SMLHelper_Experimental",
"version_number": "2.15.0000",
"version_number": "2.15.0001",
"website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki",
"description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.",
"dependencies": [ "Subnautica_Modding-BepInExPack-5.4.2101" ]
Expand Down
2 changes: 1 addition & 1 deletion SMLHelper/ThunderstoreMetadata/SN.STABLE/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "SMLHelper",
"version_number": "2.15.0000",
"version_number": "2.15.0001",
"website_url": "https://github.com/SubnauticaModding/SMLHelper/wiki",
"description": "SMLHelper is a modding library that helps making mods easier by helping with adding new items, changing items, adding models, sprites, etc.",
"dependencies": [ "Subnautica_Modding-BepInExPack-5.4.2101" ]
Expand Down
2 changes: 1 addition & 1 deletion Version.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<!-- The assembly uses this version number. !-->
<Version>2.15.0</Version>
<Version>2.15.0.1</Version>
</PropertyGroup>
</Project>

0 comments on commit f3d5de3

Please sign in to comment.