Jump to content

2 Questions: Editor.SortedSHipList is null? and KSPAddon Flight Start running late?


Recommended Posts

Alright, 2 questions on weird behavior I'm seeing that is confusing me and I'm hoping that someone has some ideas on what is happening.

1) EditorLogic.SortedShipList is null during vessel load in the editor.

During a vessel load, so going into the editor and hitting the Open icon to load an existing vessel, I am tying into the VesselChanged event to refresh some of my data.

On my copy of KSP (windows), the VesselChanged event fires once after the vessel is finished loading. On this players version of KSP (linux), the VesselChanged event is firing multiple times during the vessel loading process, but not in any pattern I can figure out. It seems to load half the vessel, fire VesselChanged, load a couple parts and fire VesselChanged again, then load a bunch of parts and fire VesselChanged, etc.

When it does so, the following line of code:

foreach (Part p in EditorLogic.SortedShipList)

throws a NullRef error. I can not replicate the error on my installation but the log is clear it is this exact line of code.

How can EditorLogic.SortedShipList be null while a vessel is loading if .SortedShipList is a list of parts in the editor when I know for sure several parts have been processed already?

2) KSPAddon Flight Start running late?

This one really puzzles me.

I have a class AGXFlight which runs in the Flight Scene via the KSPAddon.Flight method. I have a static List in that class so that code on a vessel partModule can easily find it. On my dev installation (and presumably other players installations as no one else has reported wierdness), the KSPAddon.Flight Start() method runs and finished before KSP loads the vessel that will be flown and everything is fine.

From the log file this one player has sent me, the KSPAddon.Flight Start() method is running after the vessel has loaded. This is causing me problems that I don't understand as I reference AGXFlight.StaticList from the OnSave method of the partModule. (When you load the flight scene, KSP loads and them immediately saves.)

Now, if my StaticList wasn't static, this would be straight forward, with the Flight Start() method running late, the StaticList does not exist for the code in the partModule OnSave to reference. However, AGXFlight.StaticList is static, shouldn't the list still exist in memory for me to reference? Or does the fact that the AGXFlight class is not static, so without an initialized AGXFlight class in existence, the static StaticList does not exist even though it is static?

I'm really out of my depth on this one and hope someone has some ideas.

D.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...