dkavolis / Ferram-Aerospace-Research

Aerodynamics model for Kerbal Space Program
Other
81 stars 32 forks source link

Craft file incompatibility between 1.4.5 and 1.3.1 KSP #25

Closed raidernick closed 5 years ago

raidernick commented 5 years ago

This has never been an issue before but no craft file made in KSP 1.4.5 works in 1.3.1.

The log is spammed with these errors when you try and open it in 1.3.1, please fix this.

(Filename: Line: -1)

NullReferenceException: Object reference not set to an instance of an object at FerramAerospaceResearch.FARPartGeometry.GeometryPartModule.SetupICrossSectionAdjusters () [0x00000] in :0 at FerramAerospaceResearch.FARPartGeometry.GeometryPartModule.Start () [0x00000] in :0

(Filename: Line: -1)

NullReferenceException: Object reference not set to an instance of an object at FerramAerospaceResearch.FARPartGeometry.GeometryPartModule.RebuildAllMeshData () [0x00000] in :0 at FerramAerospaceResearch.FARPartGeometry.GeometryPartModule.FixedUpdate () [0x00000] in :0

(Filename: Line: -1)

It repeats those lines over and over infinitely until you restart the game. Note that you can open a 1.3.1 craft in 1.4.5 but if you save it in 1.4.5 it won't open in 1.3.1 after that even if you make no changes to it.

raidernick commented 5 years ago

I would also like to point out the same thing happens with 1.6. If you save in 1.6 and try to open in a previous ksp, I tested 1.4.5 and 1.3.1, you get the same error spam. It happens if you just have FAR installed and nothing else except bare stock also.

dkavolis commented 5 years ago

Can you share a craft file? It would make debugging slightly faster for me.

raidernick commented 5 years ago

Sorry I deleted them because they didn't work, but it's not one specific file you can easily replicate it by spawning something as simple as a mk1 pod, saving, then trying to load it in an older ksp. So open 1.4.5, create a mk1 pod, save and then try and open it in 1.3.1. You will need to change the game version in the file though otherwise it won't let you even try to open it.

dkavolis commented 5 years ago

Actually, this is not FAR problem. The problem lies with the changes in the craft file format which fails to load higher version crafts in KSP 1.3.1. It would have been clear if you had included the first exception that sets all the rest:

[EXC 19:08:22.705] FormatException: Input string was not in the correct format
    System.UInt32.Parse (System.String s)
    ShipConstruct.LoadShip (.ConfigNode root)
    ShipConstruction.LoadShip (System.String filePath)
    EditorLogic.StartEditor (Boolean isRestart)
    EditorLogic.ShipToLoadSelected (System.String path, LoadType loadType)
    KSP.UI.Screens.CraftBrowserDialog.onPipelineFinished (.ConfigNode n, KSP.UI.Screens.CraftEntry sItem, LoadType loadType)
    KSP.UI.Screens.CraftBrowserDialog+<pipeSelectedItem>c__AnonStorey1B7.<>m__89C (.ConfigNode n)
    KSPUpgradePipeline.Process (.ConfigNode n, System.String saveName, LoadContext loadContext, .Callback`1 onSucceed, .Callback`2 onFail)
    KSP.UI.Screens.CraftBrowserDialog.pipeSelectedItem (KSP.UI.Screens.CraftEntry sItem, LoadType loadType)
    KSP.UI.Screens.CraftBrowserDialog.onButtonLoad ()
    UnityEngine.Events.InvokableCall.Invoke (System.Object[] args)
    UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters)
    UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters)
    UnityEngine.Events.UnityEvent.Invoke ()
    UnityEngine.UI.Button.Press ()
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData)
    UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData)
    UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor)
    UnityEngine.EventSystems.EventSystem:Update()

The difference in craft files lies in a few extra fields that don't affect the loading and

    attN = top,mk1pod_4294650680_0|1.875|0

in KSP 1.4+ compared to

    attN = top,mk1pod_4294650680

in KSP 1.3.1. The craft loader expects the part name to end in a unique int but in 1.4+ additional values are added. Even if I checked and caught all the NREs it wouldn't change the fact that KSP fails to load every part that is attached to something else so only the root part is loaded (tested it with one of the stock crafts from KSP 1.5.1).

Unless someone wants to and can intercept the craft loader to convert the field format into what KSP expects, I can do nothing in FAR.

raidernick commented 5 years ago

Ok then it's just a stock change, I didn't get that first error you posted there I only saw some unrelated nre's above the FAR ones from mechjeb and realfuels.