Skip to content

Commit

Permalink
Exclude parts with realchute modules from setting craft bounds on rec…
Browse files Browse the repository at this point in the history
…overy. This is a hack, but should fix complaints that recovered planes don't fit hangar dimensions. By definition the plane met the requirements to be integrated and launched, so it's safe to do this on recovery (and any editing will go back through the normal path). Close #2024
  • Loading branch information
NathanKell committed Jul 2, 2023
1 parent e1296c3 commit 3c01249
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Source/KerbalConstructionTime/BuildItems/BuildListVessel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public BuildListVessel(ShipConstruct s, string ls, string flagURL, bool storeCon

StorePartNames(s.parts);
// Override KSP sizing of the ship construct
ShipSize = Utilities.GetShipSize(s, true);
ShipSize = Utilities.GetShipSize(s, true, false);

if (storeConstruct)
StoreShipConstruct(s);
Expand Down Expand Up @@ -361,7 +361,7 @@ private ConfigNode FromInFlightVessel(Vessel VesselToSave, ListType listType)
ConfigNode cn = ConstructToSave.SaveShip();
SanitizeShipNode(cn);
// override KSP sizing of the ship construct
cn.SetValue("size", KSPUtil.WriteVector(Utilities.GetShipSize(ConstructToSave, true)));
cn.SetValue("size", KSPUtil.WriteVector(Utilities.GetShipSize(ConstructToSave, true, true)));
// These are actually needed, do not comment them out
VesselToSave.SetRotation(OriginalRotation);
VesselToSave.SetPosition(OriginalPosition);
Expand Down
7 changes: 6 additions & 1 deletion Source/KerbalConstructionTime/Utilities/Utilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public static float GetShipMass(this ShipConstruct sc, bool excludeClamps, out f
}

// Reimplemented from stock so we ignore tags.
public static Vector3 GetShipSize(ShipConstruct ship, bool excludeClamps)
public static Vector3 GetShipSize(ShipConstruct ship, bool excludeClamps, bool excludeChutes)
{
if (ship.parts.Count == 0)
return Vector3.zero;
Expand All @@ -248,6 +248,11 @@ public static Vector3 GetShipSize(ShipConstruct ship, bool excludeClamps)
if (p.IsClampOrChild())
continue;
}
if (excludeChutes)
{
if (p.Modules["RealChuteModule"] != null)
continue;
}

Bounds[] bounds = GetPartRendererBounds(p);
Bounds b;
Expand Down

0 comments on commit 3c01249

Please sign in to comment.