Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for sickbays erroneously consuming resources after rendezvous #884

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DougWagner
Copy link

This is a fix for a bug I found with sickbays where rendezvousing with a vessel that contains a part with a configurable sickbay would cause it to start consuming electricity and other resources as if all possible sickbay modules were running at the same time. To reproduce the bug, launch a vessel with a PPD-10 Hitchhiker crew container with nothing configured in the sickbay, and then launch a 2nd vessel and rendezvous with the first. When the vessel with the Hitchhiker container comes within physics range and loads into the scene, it will immediately start consuming electricity and oxygen for both the sickbay TV and RDU processes, despite originally being configured with neither sickbay modules. This bug is present in both Kerbalism versions 3.18 and 3.19.

Here are screenshots showing electricity consumption before and after rendezvousing for the target vessel that has a PPD-10 Hitchhiker part on it:

Before rendezvous:
before-rendezvous
After rendezvous:
after-rendezvous

As shown in the screenshots, the vessel has started consuming electricity and oxygen for the RDU and TV, despite being configured with neither when launched.

When debugging this, I discovered that loading a vessel normally by launching or focusing it from the tracking station would call Sickbay.Start() immediately followed by Sickbay.Update(), however when rendezvousing with the vessel, only Sickbay.Start() would be called. If both Start and Update are called, the resulting amount values for _SickbayTV and _SickbayRDU are set to 0, but if only Start is called, the amount values would end up being set to 1. This is because Sickbay.Start() calls Sickbay.Configure() with the first parameter hardcoded to true, resulting in Lib.SetResource() to be called for the TV and RDU with an amount value of 1. I am unsure if rendezvouses only calling Sickbay.Start() without calling Sickbay.Update() is a separate bug or not.

This change now ensures that the amount value for _SickbayTV and _SickbayRDU will only be set to 1 if the sickbay module configured in the part, which will set isEnabled to true. Otherwise, if the sickbay is not configured, isEnabled for _SickbayTV and _SickbayRDU will be false, and the amount value will always be 0.

I have tested this change with various different sickbay configurations and have not found any erroneous behavior.

@willfulZephyr
Copy link

This happens for me when EVAing as well. Any ETA on this PR getting merged and released?

@willfulZephyr
Copy link

This happens for me when EVAing as well. Any ETA on this PR getting merged and released?

Nevermind - I can't reproduce the EVA thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants