JonnyOThan / TweakScale

Forked from Gaius Goodspeed's Goodspeed Aerospace Part & TweakScale plugin
Other
3 stars 2 forks source link

Re-rooting to a scaled down pod can sometimes reset crew-capacity #32

Closed numberlesstim closed 5 months ago

numberlesstim commented 5 months ago

Steps to reproduce:

  1. Attach 2 pods ontop of each other using the match node feature
  2. Copy the smaller pod (hold alt + click) and re-attach to the top, again using the match node feature 3 or 4 times
  3. Re-root to the smallest pod
  4. (Optional) Remove all but the root pod
  5. You should now have a tiny pod with the default crew capacity

(lower pod in image is the default size for scale) capacity

numberlesstim commented 5 months ago

I can still reproduce this bug in the latest version (v3.1.3).

JonnyOThan commented 5 months ago

Same repro steps?

numberlesstim commented 5 months ago

Yes.

https://github.com/JonnyOThan/TweakScale/assets/117858473/e7b0c1a3-8fe8-45e0-b5d9-0672a90cc0e6

JonnyOThan commented 5 months ago

Ah, so my previous fix only worked when the partManifest for the scaled down part still existed in the vesselCrewManifest. But something about this flow is resulting in the partManifest for the root part not being there. You can hit the same UpdateCrewForVessel call if you scale down a command pod so that it has no crew, then attach a fuel tank, then delete the tank. But the partManifest exists in that case and everything works. Why doesn't it exist after re-rooting?

Answer?: in on_partAttached it calls RefreshCrewAssignment if the selected part has crewcapacity > 0. So when you attach a scaled-down part, it doesn't add that part's partManifest to the vesselCrewManifest like it would have if you attached it and then scaled it down.

Seemingly confirmed:

  1. start a new craft with a fuel tank as root
  2. attach another fuel tank
  3. grab a command pod from the parts bin, but don't attach it
  4. scale it down so there's no crew
  5. attach it to the fuel tank (without match node size, so it stays scaled down)
  6. delete the non-root fuel tank

This would all be a bit easier if parts persisted the crew capacity field. Currently there's not a great way to get the right crew capacity when creating the part manifest from the persisted config node.

numberlesstim commented 5 months ago

This can also be done with a subassembly in place of a single pod with the same steps you provided.