In the original code the supply was constant (as in reality for most power sources). Now it scales with demand. I lost a little overview, but does this mean now at low demand there will be low consumption? Because this would force everyone supplying a power station to build powerlines and would invalidate countless tutorial on how to start a game.
The foundations for such a feature are there, however it still mechanically works like it currently does. Power stations will produce power independently from the power demand they are linked with. The power produced scales with the power station boost, so passengers and mail might cause it to make more or less power. Power stations produce at full rate even if no transformer is connected.
Consumers scale power based on work done. This is a feature of JIT2 that is in the current release and reasonably well accepted, although debate remains to what the maximum power consumption should be. The only difference is the way the work is represented. Currently it is prone to jitter and oscillations. This patch should hopefully fix both those issues.
May I suggest a little more descriptive name than srdwr for senke_t, like global_rdwr() or static_rdwr(). That could become then the new standard for all the few others doing that too.
was also thinking "static_rdwr" however I thought people wanted to keep those names abbreviated and short for some reason.
Power demand is changing with the production rate of the industries in JIT2, but the consumption rate of a electricity generating industry does not change with the power supplied. IMHO that should be done at some point, but the patch I'd previously done wasn't liked...
I fully agree, but how it would effect the power stations needs to be decided and discussed.
max capacity had comments stating what the limits were rather than just a magic number appearing in code. Are these limits still valid? Then the comments should remain. If not, new comments with the new limits.
Mechanically there are still limits due to the fixed point mathematics used. These limits should be slightly larger than before. The 4 TW limit remains because it is a sensible limit (more than the Wikipedia quoted world energy generation amount). I did make it less "magic" though by using the compiler to derive it from human readable values.
add_supply/demand respected max capacity. New modify_* does not. Comments say they do.
Ops... was a last minute change. I removed the checks since they really are not necessary as overflow should not be possible (you would need billions of industries with insane power demand each). Only reason there is still ultimately a bounds check is so it ends at some nice readable number and does not explode the UI.
How does a sint32 give a value between 0 and 1? - get_demand_factor() comment.
Fixed point fractional number. If there was a fixed point type it would use that.
User friendly net id would be nice - get rid of using a pointer for that display.
Yes they would be nice. Something to do some day, as that change is not really related to the changes in this patch.
Why would the pay period need a setting?
Why not? Maybe in some paksets they want it longer than others. In any case it is there as a human readable constant for people to modify if they ever decide 10 seconds is not right.
Yes. Please do so.
This patch is already running into a lot of changes everywhere. Probably a good idea for that to be a separate patch.
Saveformat already changing, why not this too...
It already is saved. Originally I was not intending for the patch to add the save functionality, with that coming as a separate patch. However after some discussion on one of the server games I decided to move ahead and throw saving in as well so the feature feels more complete. I must have forgoten to remove the comment.
And then you change it to powernet, pumpe, senke. ? ? ?
Changing this is why you needed to change around/add all those next_, this_, and last_ that weren't there before. Again, if the new order is correct (and for JIT1 as well), then the comments need updating.
The ordering was changed to make powernet reconstruction easier. The substations and distribution transformers store their current tick power when saved. This is then pushed to their powernet on load, and conserved through mergers. Since it advances the powernet first it solves for these loaded values on its first tick. The transformers can then correctly return the solved power on their first tick. Industries save their last computed power amounts so the system is kept constantly fed. The only real difference it makes is that the logical pause occurs before the powernet tick rather than after.
The whole "next_", "this_" and "last_" thing was added in a previous patch. They are needed to preserve the computed amounts between ticks for UI purposes, since you can only show what has been solved. This logic was needed due to the dynamic power consumption of JIT2 which causes it to appear unstable.
Powernets will load and be created empty since previous tick results are not saved or relevant to the power system. Their tick results should still be correct.
The UI shows you what the last tick's results were and not what the results will be for the next tick.
What was the animation fix?
Distribution transformers flicker when not supplying 100% of power requirements. This logic was prone to overflows when a consumer used more than ~2 Gigawatts of power. One can argue if a consumer should be using so much power but if they did (pak128 steel mill with JIT2 on) then it broke. Same problem occurred with payment logic, which the new metering logic should have fixed.