From 1575ceaae198ced900e8293ac6394881e9f82f6d Mon Sep 17 00:00:00 2001 From: Jaxe Date: Tue, 21 Aug 2018 20:42:06 +0800 Subject: [PATCH] v1.0.1 Fixed the NullReferenceException when attempting to bond with an animal before any rules have been set --- About/ModSync.xml | 2 +- README.md | 4 +++- Source/Mod.cs | 2 +- .../RimWorld_RelationsUtility_TryDevelopBondRelation.cs | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/About/ModSync.xml b/About/ModSync.xml index 80351af..0355562 100644 --- a/About/ModSync.xml +++ b/About/ModSync.xml @@ -3,7 +3,7 @@ 59f538ed-f86d-4506-a4a5-7e9faaa37509 Pawn Rules - v1.0-rw0.19 + v1.0.1 False Jaxe-Dev diff --git a/README.md b/README.md index 30332ec..ed40ce4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # Pawn Rules -#### Version 1.0 +![](https://img.shields.io/badge/Version-1.0.1-brightgreen.svg) + Built for **RimWorld 1.0.x / 0.19.x**\ +Powered by **Harmony**\ Supports **ModSync RW** [Link to Ludeon Forum Post](https://ludeon.com/forums/index.php?topic=43086.0) diff --git a/Source/Mod.cs b/Source/Mod.cs index efce907..2c1d8a2 100644 --- a/Source/Mod.cs +++ b/Source/Mod.cs @@ -7,7 +7,7 @@ internal class Mod : Verse.Mod public const string Id = "PawnRules"; public const string Name = "Pawn Rules"; public const string Author = "Jaxe"; - public const string Version = "1.0"; + public const string Version = "1.0.1"; public static ModContentPack ContentPack { get; private set; } diff --git a/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs b/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs index 5fbc14b..bc8f236 100644 --- a/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs +++ b/Source/Patch/RimWorld_RelationsUtility_TryDevelopBondRelation.cs @@ -10,11 +10,12 @@ internal static class RimWorld_RelationsUtility_TryDevelopBondRelation { private static bool Prefix(Pawn humanlike, Pawn animal) { - if (!Registry.IsActive || !humanlike.CanHaveRules()) { return true; } + if (!Registry.IsActive || (humanlike == null) || (animal == null) || !humanlike.CanHaveRules()) { return true; } var rules = Registry.GetRules(humanlike); + if (rules == null) { return true; } var restrictions = rules.GetRestriction(RestrictionType.Bonding); - return (rules == null) || (restrictions.IsVoid) || restrictions.Allows(animal.def); + return (restrictions == null) || restrictions.IsVoid || restrictions.Allows(animal.def); } } }