tgstation/-tg-station — pull request #3794 by Menshin (2014-05-24 23:23:35+00:00)
Title: Power distribution tweaking

Tweaked the power generation/usage procedure :
* power generation (solars, generators, collectors, etc) and usage (SMES, APC, drains, etc) are handled during machine processing,
* the powernet available power is reset each tick (with whatever power was generated during machines processing). If there was unused power in the net, store it back in the SMES.

Game differences with the previous way of doing :
* the available power is correctly handled each tick.
Previously, some variables were not correctly reinitialized, causing, for example, the SMES to only load 1 tick on 2, despite the powernet having enough power to do it every tick, (fixes the main issue of #3761).
* consequence : the SMES and APC are (re)charging faster,
* APC now draw power the same way as other machines.
Previously, perapc available power was split between every APC __before__ applying any load on it. So, you could have an heavy loaded powernet that would potentially send power to all APC,
* consequence : we can now have some APC charging but others that don't (if the powernet don't have enough power for all of them).
Also, a little less processing from powernets.