From 78012d87e07d4eca3a757540be40f9429c63b516 Mon Sep 17 00:00:00 2001 From: enkido Date: Tue, 14 Jan 2014 13:26:18 +0100 Subject: [PATCH 1/2] Update ModuleElementRadioactiveDecay.cs null reference check, in case part ressource is not present or wrong configured --- FNPlugin/ModuleElementRadioactiveDecay.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/FNPlugin/ModuleElementRadioactiveDecay.cs b/FNPlugin/ModuleElementRadioactiveDecay.cs index 4340382c..e2409be0 100644 --- a/FNPlugin/ModuleElementRadioactiveDecay.cs +++ b/FNPlugin/ModuleElementRadioactiveDecay.cs @@ -23,16 +23,22 @@ public override void OnStart(PartModule.StartState state) { return; } decay_resource = part.Resources[resourceName]; - part.force_activate(); + if (decay_resource!=null) + { + part.force_activate(); + } } public override void OnFixedUpdate() { - double decay_amount = decayConstant * decay_resource.amount * TimeWarp.fixedDeltaTime; - decay_resource.amount -= decay_amount; - if (PartResourceLibrary.Instance.resourceDefinitions.Contains(decayProduct)) { - part.RequestResource(decayProduct, -decay_amount); + if (decay_resource != null) + { + double decay_amount = decayConstant * decay_resource.amount * TimeWarp.fixedDeltaTime; + decay_resource.amount -= decay_amount; + if (PartResourceLibrary.Instance.resourceDefinitions.Contains(decayProduct)) + { + part.RequestResource(decayProduct, -decay_amount); + } } } - } } From e1b7f2ae07d7fc2bdaf09fce1863bdca88367821 Mon Sep 17 00:00:00 2001 From: enkido Date: Tue, 14 Jan 2014 16:42:41 +0100 Subject: [PATCH 2/2] Update FNNuclearReactor.cs ** swap fuel fails because of very small fuel amounts (E^-5, normally not visible in the resource manager ui ** testing a double against zero is no good practise --- FNPlugin/FNNuclearReactor.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FNPlugin/FNNuclearReactor.cs b/FNPlugin/FNNuclearReactor.cs index 59792017..08cfee2b 100644 --- a/FNPlugin/FNNuclearReactor.cs +++ b/FNPlugin/FNNuclearReactor.cs @@ -68,12 +68,12 @@ public void SwapFuel() { if (actinides.amount <= 0.0001) { if (uranium_fuel) { defuelUranium(); - if (uf4.amount > 0) { return; } + if (uf4.amount > 0.001) { return; } setThoriumFuel(); RefuelThorium(); } else { defuelThorium(); - if (thf4.amount > 0) { return; } + if (thf4.amount > 0.001) { return; } setUraniumFuel(); RefuelUranium(); }