James, I think you just introduced two major new bugs, in 5df4211d50f69eb62073722f2f206c774d316ffe . 
You caused the multiplication by 4 to happen twice:
fabrik_t * fab = welt->get_fab_list()[i];
if(fab->get_besch()->is_electricity_producer())
{
- electric_productivity += fab->get_base_production();
+ electric_productivity += fab->get_base_production() * PRODUCTION_DELTA_T * 4;
}
else
{
@@ -976,7 +976,7 @@ next_ware_check:
}
// now decide producer of electricity or normal ...
- sint32 promille = (electric_productivity*4000l)/total_electric_demand;
+ const sint32 promille = (electric_productivity*4000l)/total_electric_demand;
Note the "*4000". I think you want to change that to "*1000" if you're using the "*4" earlier?
BTW, call me Nathanael.
--- a/besch/reader/factory_reader.cc
+++ b/besch/reader/factory_reader.cc
@@ -292,7 +292,8 @@ factory_reader_t::read_node(FILE *fp, obj_node_info_t &node)
{
if(experimental_version >= 0)
{
- besch->electricity_proportion = ((float)decode_uint16(p) / 100.0F);
+ besch->electricity_proportion = ((float)decode_uint16(p) / 750.0F);
+ // Reduce factory electricity consumption by factor of 7.5, as it was formerly far too high.
besch->inverse_electricity_proportion = 1 / besch->electricity_proportion;
}
if(experimental_version >= 1)
This is getting into extraordinary hacky territory, and is almost certainly very buggy.
Electricity_proportion should be set in the .dat files in the pak (correctly); if not there, it should be set from the default number (.17).
I don't think it should be saved with saved games at all, actually (factories should 'magically upgrade'). If it *is* saved with saved games, then you want to change the factor when loading *old saved games only*. Otherwise the electricity_proportion will be reduced by a factor of 7.5 each time you save and load).
You need to rewrite this completely.
EDIT:
The other commit is even more problematic.
I suspect your city power supply code will be buggy as well due to failing to follow the principles of the power network stabilization: namely, that when we check to see if a power net is overloaded and not supplying enough, we must use *last month's demand*
if(supply < (shared_power_demand / (city_substations_number - checked_substations.get_count())))
This needs to use "last_shared_power_demand" (which doesn't exist of course). "last_power_demand" is close enough though.
You also managed to totally break the case where the substation is both a city substation and connected directly to a factory.
That's OK though. I'm thinking at this point that the supply code is too complicated. We need two types of substations: one which connects to factories (and not cities), and one which connects to cities (and not factories). This will simplify the code *immensely*. They can be built with the same tool and autodetect based on whether they're next to a factory when built or not, just like sources and sinks are built.
And there's definitely more bugs in the multiple-substation-city-supply code related to the inconsistent use or non-use of load_proportion.
I actually suggest reverting the 'two-substation' commit (92c4475f2e6cdc20bc7027cf0ce0f349773a6611) entirely and trying again after splitting substations into "city substations" and "factroy substations".
Add back the part which worked right:
CHANGE: A downstream substation will now display the city in which it is located.
On an almost unrelated note, I realize that we need to allow multiple substations per factory -- for different players.
That change should go into standard. Separating city substations and factory substations will make it easier to implement and debug these separately.