diff --git a/DeepFreeze.zip b/DeepFreeze.zip index ae55a32..96a3f54 100644 Binary files a/DeepFreeze.zip and b/DeepFreeze.zip differ diff --git a/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version b/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version index cf04e88..1b35a44 100644 --- a/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version +++ b/GameData/REPOSoftTech/DeepFreeze/DeepFreezeContinued.version @@ -2,7 +2,7 @@ "NAME":"DeepFreeze Continued...", "URL":"http://ksp-avc.cybutek.net/version.php?id=183", "DOWNLOAD":"https://kerbalstuff.com/mod/895/DeepFreeze%20Continued...", -"VERSION":{"MAJOR":0,"MINOR":20,"PATCH":1,"BUILD":0}, +"VERSION":{"MAJOR":0,"MINOR":20,"PATCH":2,"BUILD":0}, "KSP_VERSION":{"MAJOR":1,"MINOR":0,"PATCH":5}, "KSP_VERSION_MIN":{"MAJOR":1,"MINOR":0,"PATCH":3}, "KSP_VERSION_MAX":{"MAJOR":1,"MINOR":0,"PATCH":5} diff --git a/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll b/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll index a46c2d5..de7ced9 100644 Binary files a/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll and b/GameData/REPOSoftTech/DeepFreeze/Plugins/DeepFreeze.dll differ diff --git a/Source/Changelog.txt b/Source/Changelog.txt index d4645a3..d919767 100644 --- a/Source/Changelog.txt +++ b/Source/Changelog.txt @@ -1,4 +1,8 @@ -V0.20.1.0 "Bug fixes & Enhancements" +V0.20.2.0 "Bug fixes" +Fixed null ref bug when vessels are destroyed. +Fixed null ref bug when KSP vessel list cannot be accessed. +Fixed null ref/NAN bug when revert to editor (from vessel with DeepFreeze part) and launch another vessel. +V0.20.1.0 "Bug fixes & Enhancements" Fixed sound glitch/issue with CRY-0300R when attaching more than one in symmetry mode in the editor. For Other Modder/Mods API interface re-written providing API via reflection class (no hard dependancy) - of no relevance to users. [B]V0.20.0.0 "External Radial Pods"[/B] diff --git a/Source/DFGameSettings.cs b/Source/DFGameSettings.cs index cd0808e..d4fac79 100644 --- a/Source/DFGameSettings.cs +++ b/Source/DFGameSettings.cs @@ -173,5 +173,21 @@ internal void DmpKnownFznKerbals() } } } + + internal void DmpKnownVessels() + { + this.Log("Dump of KnownVessels"); + if (knownVessels.Count() == 0) + { + this.Log("KnownVessels is EMPTY."); + } + else + { + foreach (KeyValuePair vessel in knownVessels) + { + this.Log("Vessel = " + vessel.Key + " Name = " + vessel.Value.vesselName + " crew = " + vessel.Value.numCrew + " frozencrew = " + vessel.Value.numFrznCrew); + } + } + } } } \ No newline at end of file diff --git a/Source/DFIntMemory.cs b/Source/DFIntMemory.cs index ea17152..0a6eba1 100644 --- a/Source/DFIntMemory.cs +++ b/Source/DFIntMemory.cs @@ -686,7 +686,34 @@ private void CheckVslUpdate() this.Log_Debug("knownvessels id = " + entry.Key + " Name = " + entry.Value.vesselName); Guid vesselId = entry.Key; VesselInfo vesselInfo = entry.Value; - Vessel vessel = allVessels.Find(v => v.id == vesselId); + Vessel vessel = null; + try + { + vessel = allVessels.Find(v => v.id == vesselId); + } + catch (Exception ex) + { + DeepFreeze.Instance.DFgameSettings.DmpKnownVessels(); + if (allVessels.Count == 0 || allVessels == null) + { + this.Log("FlightGlobals.Vessels = 0 or null"); + } + else + { + foreach(Vessel vsl in allVessels) + { + this.Log("Vessel " + vsl.id + " name = " + vsl.name); + } + } + this.Log("Exception: " + ex); + if (entry.Value.numFrznCrew == 0) + { + this.Log("Removing entry as vessel has no frozen crew"); + vesselsToDelete.Add(vesselId); + partsToDelete.AddRange(DeepFreeze.Instance.DFgameSettings.knownFreezerParts.Where(e => e.Value.vesselID == vesselId).Select(e => e.Key).ToList()); + continue; + } + } if (vessel == null) { this.Log_Debug("Deleting vessel " + vesselInfo.vesselName + " - vessel does not exist anymore"); diff --git a/Source/DeepFreezerPart.cs b/Source/DeepFreezerPart.cs index e681b56..8d6dd67 100644 --- a/Source/DeepFreezerPart.cs +++ b/Source/DeepFreezerPart.cs @@ -1288,7 +1288,7 @@ public override void OnStart(PartModule.StartState state) externalDoorAnim = this.part.FindModelAnimators(animationName).FirstOrDefault(); if (externalDoorAnim == null) { - this.Log_Debug("Part has external animation defined but cannot find the animation on the part"); + Utilities.Log_Debug("Part has external animation defined but cannot find the animation on the part"); hasExternalDoor = false; Events["eventOpenDoors"].active = false; Events["eventCloseDoors"].active = false; @@ -1297,10 +1297,10 @@ public override void OnStart(PartModule.StartState state) } else { - this.Log_Debug("Part has external animation, check if RPM is installed and process"); + Utilities.Log_Debug("Part has external animation, check if RPM is installed and process"); if (DFInstalledMods.IsRPMInstalled) { - this.Log_Debug("RPM installed, set doorstate"); + Utilities.Log_Debug("RPM installed, set doorstate"); hasExternalDoor = true; if (_externaldoorstate == DoorState.OPEN) { @@ -1313,11 +1313,11 @@ public override void OnStart(PartModule.StartState state) } else //RPM is not installed, disable the doors. { - this.Log_Debug("RPM NOT installed, set transparent transforms"); + Utilities.Log_Debug("RPM NOT installed, set transparent transforms"); hasExternalDoor = false; Events["eventOpenDoors"].active = false; Events["eventCloseDoors"].active = false; - this.Log_Debug("door actions/events off"); + Utilities.Log_Debug("door actions/events off"); if (transparentTransforms != string.Empty) Utilities.setTransparentTransforms(this.part, transparentTransforms); } @@ -3239,18 +3239,18 @@ private void OnVesselChange(Vessel vessel) // ie scene changes, exiting loading distance private void onVesselDestroy(Vessel vessel) { - this.Log_Debug("OnVesselDestroy"); + Utilities.Log_Debug("OnVesselDestroy"); //Check a Freeze or Thaw is not in progress, if it is, we must abort. if (IsThawActive) { ScreenMessages.PostScreenMessage("Vessel about to change, Aborting Thaw process", 5.0f, ScreenMessageStyle.UPPER_CENTER); - this.Log_Debug("Thawisactive - abort"); + Utilities.Log_Debug("Thawisactive - abort"); ThawKerbalAbort(ToThawKerbal); } if (IsFreezeActive) { ScreenMessages.PostScreenMessage("Vessel about to change, Aborting Freeze process", 5.0f, ScreenMessageStyle.UPPER_CENTER); - this.Log_Debug("Freezeisactive - abort"); + Utilities.Log_Debug("Freezeisactive - abort"); FreezeKerbalAbort(ActiveFrzKerbal); } } diff --git a/Source/Properties/AssemblyInfo.cs b/Source/Properties/AssemblyInfo.cs index e8f8451..1559f77 100644 --- a/Source/Properties/AssemblyInfo.cs +++ b/Source/Properties/AssemblyInfo.cs @@ -31,7 +31,7 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.20.1.0")] -[assembly: AssemblyFileVersion("0.20.1.0")] +[assembly: AssemblyVersion("0.20.2.0")] +[assembly: AssemblyFileVersion("0.20.2.0")] [assembly: KSPAssembly("DeepFreeze", 0, 20)] [assembly: KSPAssemblyDependency("DFInterface", 0, 4)] \ No newline at end of file diff --git a/Source/utilities.cs b/Source/utilities.cs index 6a37c60..2d4a99a 100644 --- a/Source/utilities.cs +++ b/Source/utilities.cs @@ -822,30 +822,62 @@ internal static void Log(string context, string message) internal static void Log_Debug(this UnityEngine.Object obj, string message) { - DFSettings DFsettings = DeepFreeze.Instance.DFsettings; - if (DFsettings.debugging) + try + { + DFSettings DFsettings = DeepFreeze.Instance.DFsettings; + if (DFsettings.debugging) + Debug.Log(obj.GetType().FullName + "[" + obj.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " + message); + } + catch + { Debug.Log(obj.GetType().FullName + "[" + obj.GetInstanceID().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " + message); + } + } internal static void Log_Debug(this System.Object obj, string message) { - DFSettings DFsettings = DeepFreeze.Instance.DFsettings; - if (DFsettings.debugging) + try + { + DFSettings DFsettings = DeepFreeze.Instance.DFsettings; + if (DFsettings.debugging) + Debug.Log(obj.GetType().FullName + "[" + obj.GetHashCode().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " + message); + } + catch + { Debug.Log(obj.GetType().FullName + "[" + obj.GetHashCode().ToString("X") + "][" + Time.time.ToString("0.00") + "]: " + message); + } + } internal static void Log_Debug(string context, string message) { - DFSettings DFsettings = DeepFreeze.Instance.DFsettings; - if (DFsettings.debugging) + + try + { + DFSettings DFsettings = DeepFreeze.Instance.DFsettings; + if (DFsettings.debugging) + Debug.Log(context + "[][" + Time.time.ToString("0.00") + "]: " + message); + } + catch + { Debug.Log(context + "[][" + Time.time.ToString("0.00") + "]: " + message); + } } internal static void Log_Debug(string message) { - DFSettings DFsettings = DeepFreeze.Instance.DFsettings; - if (DFsettings.debugging) + + try + { + DFSettings DFsettings = DeepFreeze.Instance.DFsettings; + if (DFsettings.debugging) + Debug.Log("[DeepFreeze][" + Time.time.ToString("0.00") + "]: " + message); + } + catch + { Debug.Log("[DeepFreeze][" + Time.time.ToString("0.00") + "]: " + message); + } } } } \ No newline at end of file