Stock construction part too heavy handling
Opened this issue · 8 comments
Currently KSP allows an engineer to click and remove a part that is too heavy and only warns of the problem when trying to reattach. This is an issue because no matter how the operation is "canceled" that I can deduce ends up leaving the craft with spurious accelerations requiring a quickload.
If there is a better way to "cancel" than boarding the craft, please let me know.
Ideally, clicking on a too heavy part would not detach it from the craft in the first place and "canceling" should not induce spurious accelerations
I can't reproduce the behavior you describe in KSP 1.12
At least in the cases I tried, attempting to detach a part that exceed the current mass limit has no effect outside of the part X exceeds the weight that a kerbal can construct with in this gravity.
message being triggered, the action is immediately canceled and the part/vessel not affected at all.
If you can reproduce this, please provide exact reproduction setup and steps (and ideally upload a non-modded save that I can load to reproduce it).
Thank you for investigating. I suspect the issue, perhaps mod caused, is the lack of cancellation. I get the message, but Esc doesn't cancel and it does not auto cancel on exceeding weight while placing. I'm determining the "spurious accelerations" by watching KER apoapsis, periapsis, eccentricity etc, fwiw. No RCS or throttle involved. I will get a testbed save going as soon as I get my game machine working again (pwr supp issue)
I think I've found this one. Picking up a part sets its mass equal to the prefab mass AFTER you've picked it up. This ignores any mass modifiers like the stock ModulePartVariants, b9ps, tweakscale, etc.
I made a small transpiler patch here, but maybe this should also be in KSPCF: JonnyOThan/TweakScale@b5f8bde
Ugh, noticed another possible culprit: when you store a part in an inventory, it uses the prefab's mass and resource mass to update the amount occupied in the inventory.
ugggh and there's also ModuleCargoPart.MakePartSettle which messes with the part's prefabMass. What a mess.
I suspect MakePartSettle changes the mass so that it can move other things out of the way, or would be less likely to get punted by something else moving.
Ohhhh! What if PickupPart was supposed to set selectedPart.prefabMass instead of selectedPart.mass? That would make WAY more sense.
There are indeed a whole bunch of issues with the inventory system using the part prefab mass values, instead of the protopart values. I know at some point I tackled a bunch of them in a KSPCF branch, which I then decided to put in a separate mod, which I then forgot about.
This being said, the way EVA construction works, attaching a part involves instantiating a brand new part out of the held part protopart (which is then destroyed), so those modifications to the held part mass / prefabMass shouldn't matter once the part is attached.
However, the ModuleCargoPart.preSettlingPrefabMass
field is indeed used to check construction weight limits (see Part.IsUnderConstructionWeightLimit()
using the ModuleCargoPart.MassForWeightTesting
property pointing to preSettlingPrefabMass
), so this definitely seems quite sketchy, as weight limits should be checking not only the part mass, but also its resources mass.
I guess the reason ModuleCargoPart.MakePartSettle()
is messing around with prefabMass
is because it needs a mechanism to change the part mass without it being reverted by the part update.
IDK, as you pointed out, EVA construction is one of the worst spaghetti mess in the KSP codebase, and it introduce tons of weird hacks that completely break some otherwise invariant behaviors and lifecyles on which mods and even stock code are relying.
Just recording this here for posterity: I’m pretty sure that MassForWeightTesting does not work properly. While I was investigating all this stuff I often hit cases where I could drop a part and then couldn’t immediately pick it up again, getting the “part too heavy” message. Once it settled I could pick it up again.
Someone may have a repro here: https://discord.com/channels/132478131490521089/454043306800840714/1218002887490142229