Explorar o código

Berechnungsbug Oversupply obwohl noch andere Gebäubde die Energy
gebraucht haben - Fix

tolatesry %!s(int64=7) %!d(string=hai) anos
pai
achega
ee58f2092f
Modificáronse 1 ficheiros con 6 adicións e 4 borrados
  1. 6 4
      src/ui/controller/SimulationManager.java

+ 6 - 4
src/ui/controller/SimulationManager.java

@@ -278,15 +278,17 @@ public class SimulationManager {
 						//supplyFullytillEnd ... because its cant be fully supplied 
 						for(HolonObject hO : singleSubNet.getObjects())
 						{
-							float neededEnergy = -hO.getCurrentEnergyAtTimeStep(x);
-							if(neededEnergy < 0)continue; //Producer
+							
+							float actualSupplyEnergy = hO.getCurrentSupply();
+							float neededEnergy = -hO.getCurrentEnergyAtTimeStep(x) - actualSupplyEnergy;
+							if(neededEnergy <= 0)continue; //Producer or No EnergyNeeded
 							if(neededEnergy <= currentProduction)
 							{
-								hO.setCurrentSupply(neededEnergy+hO.getCurrentSupply());
+								hO.setCurrentSupply(neededEnergy+actualSupplyEnergy);
 								currentProduction -= neededEnergy;
 							}else
 							{
-								hO.setCurrentSupply(currentProduction+hO.getCurrentSupply());
+								hO.setCurrentSupply(currentProduction+actualSupplyEnergy);
 								currentProduction = 0;
 								break;
 							}