From e5fd3059972ca0019c6cf2c1a21002d39024e39e Mon Sep 17 00:00:00 2001 From: Jonathan Bayer Date: Wed, 21 Nov 2018 07:38:35 -0500 Subject: [PATCH] Fixed nullref when using the equals sign and at the end of the list of cameras. Added code to allow a docking node to be a target and have the docking info displayed on the docking camera --- Changelog.txt | 6 +++++- GameData/HullCameraVDS/HullcamVDSContinued.version | 2 +- HullCamera/AssemblyVersion.cs | 2 +- HullCamera/MovieTime.cs | 11 ++++++++--- HullCamera/MuMechModuleHullCamera.cs | 2 +- HullcamVDSContinued.version | 2 +- 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index e93cb98..4ea690d 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -65,4 +65,8 @@ Fixed the KSC Launchpad Camera so it now is there Removed the obsolete impactTolerance variable Thanks to @Gordon Dry for this: patch to avoid the EVA cam to be added when the mod ThroughTheEyes is already installed. - Simplified the kerbalEVA patch \ No newline at end of file + Simplified the kerbalEVA patch + +0.1.9.10 + Fixed nullref when using the equals sign and at the end of the list of cameras. + Added code to allow a docking node to be a target and have the docking info displayed on the docking camera \ No newline at end of file diff --git a/GameData/HullCameraVDS/HullcamVDSContinued.version b/GameData/HullCameraVDS/HullcamVDSContinued.version index c511b1e..821cc17 100644 --- a/GameData/HullCameraVDS/HullcamVDSContinued.version +++ b/GameData/HullCameraVDS/HullcamVDSContinued.version @@ -11,7 +11,7 @@ "MAJOR": 0, "MINOR": 1, "PATCH": 9, - "BUILD": 9 + "BUILD": 10 }, "KSP_VERSION": { "MAJOR": 1, diff --git a/HullCamera/AssemblyVersion.cs b/HullCamera/AssemblyVersion.cs index 5620685..5f6e2ef 100644 --- a/HullCamera/AssemblyVersion.cs +++ b/HullCamera/AssemblyVersion.cs @@ -10,4 +10,4 @@ using System.Reflection; - [assembly: AssemblyVersion("0.1.9.9")] \ No newline at end of file + [assembly: AssemblyVersion("0.1.9.10")] \ No newline at end of file diff --git a/HullCamera/MovieTime.cs b/HullCamera/MovieTime.cs index 7604579..7872442 100644 --- a/HullCamera/MovieTime.cs +++ b/HullCamera/MovieTime.cs @@ -140,8 +140,9 @@ public void Update() { print(currentMode); } - - HasTargetData = (FlightGlobals.ActiveVessel.targetObject is Vessel); + if (FlightGlobals.ActiveVessel.targetObject == null) + return; + HasTargetData = (FlightGlobals.ActiveVessel.targetObject is Vessel || FlightGlobals.ActiveVessel.targetObject is ModuleDockingNode); currentMode = GetCameraMode().ToString(); if (HasTargetData) @@ -152,7 +153,11 @@ public void Update() targetVelY = Math.Round(Vector3d.Dot(FlightGlobals.ship_tgtVelocity, FlightGlobals.ActiveVessel.ReferenceTransform.forward), 3); targetVelZ = Math.Round(Vector3d.Dot(FlightGlobals.ship_tgtVelocity, FlightGlobals.ActiveVessel.ReferenceTransform.up), 3); - Vessel targetVessel = (Vessel)FlightGlobals.ActiveVessel.targetObject; + Vessel targetVessel; + if (FlightGlobals.ActiveVessel.targetObject is Vessel) + targetVessel = (Vessel)FlightGlobals.ActiveVessel.targetObject; + else + targetVessel = ((ModuleDockingNode)FlightGlobals.ActiveVessel.targetObject).vessel; Orbit activeOrbit = FlightGlobals.ActiveVessel.orbit; Orbit targetOrbit = targetVessel.orbit; diff --git a/HullCamera/MuMechModuleHullCamera.cs b/HullCamera/MuMechModuleHullCamera.cs index 51c7ade..c6add6e 100644 --- a/HullCamera/MuMechModuleHullCamera.cs +++ b/HullCamera/MuMechModuleHullCamera.cs @@ -314,7 +314,7 @@ protected static void CycleCamera(int direction) // Iterates the number of cameras and returns as soon as a camera is chosen. // Then if no camera is chosen, restore main camera as a last-ditch effort. - for (int i = 0; i < sCameras.Count + 1; i += 1) + for (int i = 0; i < sCameras.Count - 1; i++) { // Check if cycle direction is referse and if the current cam is the first hullcam diff --git a/HullcamVDSContinued.version b/HullcamVDSContinued.version index c511b1e..821cc17 100644 --- a/HullcamVDSContinued.version +++ b/HullcamVDSContinued.version @@ -11,7 +11,7 @@ "MAJOR": 0, "MINOR": 1, "PATCH": 9, - "BUILD": 9 + "BUILD": 10 }, "KSP_VERSION": { "MAJOR": 1,