Skip to content

lhervier/KSP-Bug26942Fix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This plugin tries to fix KSP Bug 26942 (and probably others).

KSP parts have multiple ids:

  • craftID : Generated by the editor. Launching multiple times the same craft will generate vessels with parts that have the same craftID (and it's not the only case as KSP is not even trying to generate unique craftID for different crafts). It is present in the "cid" attribute of the PART nodes in the .sfs file.
  • missionID : Identifier computed when launching a craft. All parts of the same launched craft have the same missionID. It is present in the "mid" attribute of PART nodes in the .sfs file.
  • flightID : Unique among all the parts of all the existing vessels. Present in the "persistentId" attribute of PART nodes in the .sfs file. It is a "real" part identifier.

Struts are parts that reference a target part. But the link to the target part is stored in a PARTDATA node in the .sfs file as a "tgt" attribute that represents a craftID.

So, when loading a vessel with struts, KSP will search for the target part using the strut target craftID (in the "tgt" attribute), AND the strut missionID (in the "mid" attribute). Before EVA Construction Mode, it works fine ! Even with vessels composed of multiple docked vessels (because each vessel has a different missionID).

But now, with EVA Construction mode, when you add an piece from an inventory :

  • The new piece's missionID will be "0", except for struts where it will be equal to the missionID of the strut present in the inventory case.
  • The new piece's craftID will be the same as the piece's craftID present in the inventory case. But note that for stacked pieces, there is only ONE part in the inventory case (associated with a counter). Adding two stacked pieces from the same inventory case location will generate two parts with the same craftID (and missionID !! See the problem with struts ?)
  • If the piece is a strut, the target (ie "tgt" attribute of the PARTDATA node) will be the craftID of the target part (which is incoherent with the missionID !!).

And so, once the game is saved and reloaded, the strut will be seen as connected to an unknown part, and will be disconnected.

The solution is to change two things when a part is attached :

  • Change the strut missionID to the missionID of its target part.
  • Ensure that the craftID/missionID couple of any newly added part is unique, updating the craftID if needed.

That's what this mod does...

Beware that it will not make a "corrupted" savegame work again. You will have to edit it by hand (or via a tool like KML) to re-generate unique craftID/missionID couples. Beware of tgt and other attribute that may reference the craftID (maybe some mods does ?) : You will have to update them too ! That's why this mod is not trying to do the update for you

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages