heat solver: Fixed index going out of bounds
When attempting solving impossible heat goals and ranges, algo runs out of prebaked DX1 values.
1. Fixed incorrect loop condition that caused the out of bounds.
2. Clamped the heat goal so they also never attempt to solve impossible heat goals.
Stacktrace
----------
java.lang.ArrayIndexOutOfBoundsException: Index 27 out of bounds for length 27
at com.toofifty.easygiantsfoundry.HeatActionSolver.relativeSolve(HeatActionSolver.java:188)
at com.toofifty.easygiantsfoundry.HeatActionSolver.heatingSolve(HeatActionSolver.java:136)
at com.toofifty.easygiantsfoundry.HeatActionSolver.solve(HeatActionSolver.java:288)
at com.toofifty.easygiantsfoundry.FoundryOverlay3D.drawHeatChangerPreviewOverlay(FoundryOverlay3D.java:244)
This commit is contained in:
@@ -151,7 +151,7 @@ public class HeatActionSolver
|
|||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
if (index >= MAX_INDEX)
|
if (index > MAX_INDEX)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -175,6 +175,7 @@ public class HeatActionSolver
|
|||||||
dx0 -= decayValue;
|
dx0 -= decayValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
dx0 += DX_1[index];
|
dx0 += DX_1[index];
|
||||||
++index;
|
++index;
|
||||||
decay = !decay;
|
decay = !decay;
|
||||||
@@ -210,11 +211,11 @@ public class HeatActionSolver
|
|||||||
|
|
||||||
final boolean isStageHeating = stage.isHeating();
|
final boolean isStageHeating = stage.isHeating();
|
||||||
|
|
||||||
// adding 1.8s/6ticks worth of padding so preform doesn't decay out of range
|
// adding 2.4s/8ticks worth of padding so preform doesn't decay out of range
|
||||||
// average distance from lava+waterfall around 6 ticks
|
// average distance from lava+waterfall around 8 ticks
|
||||||
// preform decays 1 heat every 2 ticks
|
// preform decays 1 heat every 2 ticks
|
||||||
final int min = range[0] + padding;
|
final int min = Math.min(1000, range[0] + padding);
|
||||||
final int max = range[1] + padding;
|
final int max = Math.min(1000, range[1] + padding);
|
||||||
|
|
||||||
final int actionsLeft_DeltaHeat = actionLeftInStage * stage.getHeatChange();
|
final int actionsLeft_DeltaHeat = actionLeftInStage * stage.getHeatChange();
|
||||||
|
|
||||||
|
|||||||
@@ -135,8 +135,6 @@ public class HeatActionStateMachine
|
|||||||
/**
|
/**
|
||||||
* Helper to remind the neccessary parameters to start the state-machine.
|
* Helper to remind the neccessary parameters to start the state-machine.
|
||||||
*
|
*
|
||||||
* @param velocity the velocity of the heating/cooling action, 7 for slow, 27 for fast.
|
|
||||||
* @param accelerationBonus the acceleration bonus of the heating/cooling action. Usually 0 for slow, 2 for fast.
|
|
||||||
* @param actionName the name of the action to display in the ui overlay
|
* @param actionName the name of the action to display in the ui overlay
|
||||||
*/
|
*/
|
||||||
public void setup(boolean isFast, boolean isHeating, String actionName)
|
public void setup(boolean isFast, boolean isHeating, String actionName)
|
||||||
|
|||||||
Reference in New Issue
Block a user