ferram4 / Ferram-Aerospace-Research

Aerodynamics model for Kerbal Space Program
Other
239 stars 131 forks source link

NRE in UpdateThermodynamicsPre method #98

Closed mjn33 closed 9 years ago

mjn33 commented 9 years ago

While testing the recent heating bugfix, I stumbled across a few NREs causing general weirdness.

Reproduction steps:

  1. Using FAR at e782e735615bb9029a6ddcd5ff1788005dfe3a7d
  2. Load quicksave.sfs provided
  3. Decouple the command pod
  4. Re-enter as shown in screenshot2.png
  5. Observe that the heatshield is destroyed, however the command pod isn't
  6. Also, gravity breaks

Looking at the Player.log, the following exception is spammed:

NullReferenceException
  at (wrapper managed-to-native) UnityEngine.Component:GetComponent (System.Type)
  at UnityEngine.Component.GetComponent[FARAeroPartModule] () [0x00000] in <filename unknown>:0 
  at FerramAerospaceResearch.FARAeroComponents.ModularFlightIntegratorRegisterer.UpdateThermodynamicsPre (ModularFI.ModularFlightIntegrator fi) [0x00000] in <filename unknown>:0 
  at ModularFI.ModularFlightIntegrator.UpdateThermodynamics () [0x00000] in <filename unknown>:0 
  at FlightIntegrator.FixedUpdate () [0x00000] in <filename unknown>:0 
  at ModularFI.ModularFlightIntegrator.FixedUpdate () [0x00000] in <filename unknown>:0

Adding some extra logging in this patch solves this partially, and prints out this in the Player.log:

[ModularFlightIntegratorRegisterer] Caught NullReferenceException
  Part: Heat Shield (2.5m)
  Part Modules: 
    - ModuleJettison
    - ModuleAblator
    - FerramAerospaceResearch.FARPartGeometry.GeometryPartModule
    - FerramAerospaceResearch.FARAeroComponents.FARAeroPartModule
    - ferram4.FARPartModule

Also, another exception I found (which seems unrelated):

NullReferenceException: Object reference not set to an instance of an object
  at FerramAerospaceResearch.FARPartGeometry.GeometryPartModule.GetICrossSectionAdjusters (System.Collections.Generic.List`1 forwardFacing, System.Collections.Generic.List`1 rearwardFacing, Matrix4x4 basis, Vector3 vehicleMainAxis) [0x00000] in <filename unknown>:0 
  at FerramAerospaceResearch.FARAeroComponents.VehicleAerodynamics.AdjustCrossSectionForAirDucting (FerramAerospaceResearch.FARPartGeometry.VoxelCrossSection[] vehicleCrossSection, System.Collections.Generic.List`1 geometryModules) [0x00000] in <filename unknown>:0 
  at FerramAerospaceResearch.FARAeroComponents.VehicleAerodynamics.CalculateVesselAeroProperties () [0x00000] in <filename unknown>:0 
  at FerramAerospaceResearch.FARAeroComponents.VehicleAerodynamics.CreateVoxel () [0x00000] in <filename unknown>:0 
UnityEngine.Debug:Internal_LogException(Exception, Object)
UnityEngine.Debug:LogException(Exception)
FerramAerospaceResearch.FARThreading.ThreadSafeDebugLogger:Update()

From the extra logging, this is printed out:

[GeometryPartModule] crossSectionAdjusters is null

All files: Player.log Player.log (with extra logging patch) quicksave.sfs Extra logging patch screenshot1.png screenshot2.png screenshot3.png screenshot4.png

ferram4 commented 9 years ago

https://github.com/ferram4/Ferram-Aerospace-Research/commit/43ec6a09eb641adfd73f60f1b9de87c85fa1db9f resolves both issues.