From f3b8811b44c258e1a196247dc8eaa67866e3f305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B5=D0=B9=20=D0=91=D0=B5?= =?UTF-8?q?=D0=B7=D1=8A=D1=8F=D0=B7=D1=8B=D1=87=D0=BD=D1=8B=D0=B9?= Date: Sat, 20 Jun 2020 11:08:50 +0300 Subject: [PATCH] fixed for NullReferenceExceptions --- 1.1/Source/WhatTheHack/Harmony/Dialog_FormCaravan.cs | 6 +++++- 1.1/Source/WhatTheHack/Harmony/Pawn_HealthTracker.cs | 2 +- 1.1/Source/WhatTheHack/Recipes/Recipe_HackMechanoid.cs | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/1.1/Source/WhatTheHack/Harmony/Dialog_FormCaravan.cs b/1.1/Source/WhatTheHack/Harmony/Dialog_FormCaravan.cs index 0ea70e11..ed5255d2 100644 --- a/1.1/Source/WhatTheHack/Harmony/Dialog_FormCaravan.cs +++ b/1.1/Source/WhatTheHack/Harmony/Dialog_FormCaravan.cs @@ -83,7 +83,11 @@ public static void AddWarnings(Dialog_FormCaravan instance, ref List war { return; } - if(numPlatforms < numMechanoids) + if (warnings == null) + { + warnings = new List(); + } + if (numPlatforms < numMechanoids) { warnings.Add("WTH_Warning_NotEnoughPlatforms".Translate()); } diff --git a/1.1/Source/WhatTheHack/Harmony/Pawn_HealthTracker.cs b/1.1/Source/WhatTheHack/Harmony/Pawn_HealthTracker.cs index abf67912..1b8b4e50 100644 --- a/1.1/Source/WhatTheHack/Harmony/Pawn_HealthTracker.cs +++ b/1.1/Source/WhatTheHack/Harmony/Pawn_HealthTracker.cs @@ -259,7 +259,7 @@ private static void TryHealRandomInjury(Pawn_HealthTracker __instance, Pawn pawn } Hediff_Injury hediff_Injury = hediffs.RandomElement(); hediff_Injury.Heal(healAmount); - if (pawn.IsHashIntervalTick(50) && !pawn.IsHashIntervalTick(100) && !pawn.Position.Fogged(pawn.Map)) + if (pawn.IsHashIntervalTick(50) && !pawn.IsHashIntervalTick(100) && pawn.Map != null && !pawn.Position.Fogged(pawn.Map)) { MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_HealingCross); } diff --git a/1.1/Source/WhatTheHack/Recipes/Recipe_HackMechanoid.cs b/1.1/Source/WhatTheHack/Recipes/Recipe_HackMechanoid.cs index 758d3a85..d9fb8d23 100644 --- a/1.1/Source/WhatTheHack/Recipes/Recipe_HackMechanoid.cs +++ b/1.1/Source/WhatTheHack/Recipes/Recipe_HackMechanoid.cs @@ -38,6 +38,10 @@ protected override void PostSuccessfulApply(Pawn pawn, BodyPartRecord part, Pawn { pawn.ownership = new Pawn_Ownership(pawn); } + if (pawn.psychicEntropy == null) + { + pawn.psychicEntropy = new Pawn_PsychicEntropyTracker(pawn); + } pawn.Name = PawnBioAndNameGenerator.GeneratePawnName(pawn, NameStyle.Full); Find.LetterStack.ReceiveLetter("WTH_Letter_Success_Label".Translate(), "WTH_Letter_Success_Label_Description".Translate(new object[]{billDoer.Name.ToStringShort, pawn.Name}), LetterDefOf.PositiveEvent, pawn);