FractalUK / KSPInterstellar

KSP Instellar Mod for Kerbal Space Program
115 stars 67 forks source link

Fix tritium not breeding in background #65

Closed ericperko closed 9 years ago

ericperko commented 9 years ago

In Interstellar 0.13, tritium is not breeding for me on unfocused vessels even when the same setup would successfully breed tritium when it was the active vessel.

To reproduce the issue, create a tritium breeder (I used a fission reactor, generator, lithium, tritium cryostat and microwave transmitter to keep the reactor at 100%), enable tritium breeding and timewarp for a while while watching the amount of LqdTritium on the vessel. It should increase. Now, note the amount of tritium on the vessel, switch to the SpaceCenter (or otherwise make the tritium breeder not the active vessel) and timewarp a similar period of time. Switch back to the tritium breeder and compare the LqdTritium levels to the value previously noted. Without this patch, no additional tritium will have been produced in the background.

There were two variables that weren't getting set anymore that caused this problem. I referenced the reactor code from 0.10.3 ( https://github.com/FractalUK/KSPInterstellar/blob/def545fc24007fdbd0390ab667ba78a8f2f19d77/FNPlugin/FNReactor.cs ) for how things should work:

  1. last_active_time was not getting set, so the doPersistentResourceUpdate() function never got called and any time deltas wouldn't make sense even if it were.
  2. ongoing_consumption_rate was not getting set, so the persistent resource update acted like the reactor was always at 0% power.