UmbraSpaceIndustries / USI-LS

USI Life Support
Other
65 stars 47 forks source link

Crew members after the first are instantly homesick on vessel status refresh #316

Open arbsoup opened 4 days ago

arbsoup commented 4 days ago

Setup:

  1. Enable some sort of homesickness penalty.
  2. Build a craft with a two-man command pod and a Hitchhiker (plus a lot of supplies and EC, or disable those). Put two (non-scout, if it matters) Kerbals in the pod and none in the Hitchhiker.
  3. Put the craft in orbit and turn on the Hitchhiker's habitat module. Wait a decently long time (longer than the craft would be habitable without the module on, any more than 22 days should work).
  4. Turn off the Hitchhiker's habitat module.

Expected result: Each crew member's hab timer drops to ~22 days, the hab limit for the updated craft without the module active.

Actual result: Only the first crew member's hab timer drops to that value, and everyone else instantly takes a homesickness effect when the craft's status refreshes.

Cause:

https://github.com/UmbraSpaceIndustries/USI-LS/blob/c842b8587e150875cc563c3aca541d618d5aadbb/Source/USILifeSupport/ModuleLifeSupportSystem.cs#L248-L253

This only updates TimeEnteredVessel for the first crew member in the for loop; after that, _isStatusRefreshRequired is false and nobody else's TimeEnteredVessel changes — meaning that each other crew member then looks at their timer and finds the second condition true:

https://github.com/UmbraSpaceIndustries/USI-LS/blob/c842b8587e150875cc563c3aca541d618d5aadbb/Source/USILifeSupport/ModuleLifeSupportSystem.cs#L717

Presumably _isStatusRefreshRequired should only be set to false after the for loop through the crew.