Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for null in OnPartJointBreak #707

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

MacGyverNL
Copy link
Contributor

In the VAB, for some reason probably related to automatic autostrutting,
ContractConfigurator starts throwing NullReferenceExceptions of the type

[EXC 23:10:42.742] NullReferenceException: Object reference not set to an instance of an object
        ContractConfigurator.Parameters.VesselNotDestroyed.OnPartJointBreak (PartJoint p, System.Single breakForce) (at <ef0243a06f2841fe9bf57034a334902e>:0)
        EventData`2[T,U].Fire (T data0, U data1) (at <dc0e5f458c0f4571ad839b9c4153f347>:0)
        UnityEngine.DebugLogHandler:LogException(Exception, Object)
        ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
        UnityEngine.Debug:LogException(Exception)
        EventData`2:Fire(PartJoint, Single)
        PartJoint:DestroyJoint()
        Part:ReleaseAutoStruts()
        Part:onDetach(Boolean)
        Part:onDetach(Boolean)
        EditorLogic:detachPart(Part)
        EditorLogic:<SetupFSM>b__190_21()
        KerbalFSM:RunEvent(KFSMEvent)
        KerbalFSM:updateFSM(KFSMUpdateMode)
        KerbalFSM:UpdateFSM()
        EditorLogic:Update()

Because for some reason OnPartJointBreak gets called on a PartJoint p
for which p.Parent.vessel returns null.

This is reproducible on my config with normal decouplers, but the most
reliable way of reproducing it I've found is:

  1. Start a new vehicle in the VAB.
  2. Select a Mk1-3 command pod as the root.
  3. Put an engine plate (SquadExpansion) on the bottom.
  4. Put an engine on the engine plate.
  5. "Pick up" the engine plate.
  6. Observe the VAB stutter while the log gets filled with these
    exceptions.

This happens on an old save file which I've been coaxing into working
with the current install, but I have done a complete reinstall of all
my mods and it happens on a new craft, not just existing ones. I have
not tested it in a clean save file because I figure the fix is worth
doing anyway.

In the VAB, for some reason probably related to automatic autostrutting,
ContractConfigurator starts throwing NullReferenceExceptions of the type

```
[EXC 23:10:42.742] NullReferenceException: Object reference not set to an instance of an object
        ContractConfigurator.Parameters.VesselNotDestroyed.OnPartJointBreak (PartJoint p, System.Single breakForce) (at <ef0243a06f2841fe9bf57034a334902e>:0)
        EventData`2[T,U].Fire (T data0, U data1) (at <dc0e5f458c0f4571ad839b9c4153f347>:0)
        UnityEngine.DebugLogHandler:LogException(Exception, Object)
        ModuleManager.UnityLogHandle.InterceptLogHandler:LogException(Exception, Object)
        UnityEngine.Debug:LogException(Exception)
        EventData`2:Fire(PartJoint, Single)
        PartJoint:DestroyJoint()
        Part:ReleaseAutoStruts()
        Part:onDetach(Boolean)
        Part:onDetach(Boolean)
        EditorLogic:detachPart(Part)
        EditorLogic:<SetupFSM>b__190_21()
        KerbalFSM:RunEvent(KFSMEvent)
        KerbalFSM:updateFSM(KFSMUpdateMode)
        KerbalFSM:UpdateFSM()
        EditorLogic:Update()
```

Because for some reason OnPartJointBreak gets called on a `PartJoint p`
for which `p.Parent.vessel` returns null.

This is reproducible on my config with normal decouplers, but the most
reliable way of reproducing it I've found is:
0. Start a new vehicle in the VAB.
1. Select a Mk1-3 command pod as the root.
2. Put an engine plate (SquadExpansion) on the bottom.
3. Put an engine on the engine plate.
4. "Pick up" the engine plate.
5. Observe the VAB stutter while the log gets filled with these
   exceptions.

This happens on an old save file which I've been coaxing into working
with the current install, but I *have* done a complete reinstall of all
my mods and it happens on a *new* craft, not just existing ones. I have
not tested it in a clean save file because I figure the fix is worth
doing anyway.
@NathanKell
Copy link

I mean, of course the vessel of a part in the editor is gonna be null? Presumably it's a base KSP bug that the joint is even created in the editor at all, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants