Skip to content

Commit 7c4036d

Browse files
committed
Don't leak coordinates in exceptions
1 parent 921822a commit 7c4036d

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/main/java/baritone/pathing/calc/AStarPathFinder.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import baritone.api.pathing.goals.Goal;
2323
import baritone.api.pathing.movement.ActionCosts;
2424
import baritone.api.utils.BetterBlockPos;
25+
import baritone.api.utils.SettingsUtil;
2526
import baritone.pathing.calc.openset.BinaryHeapOpenSet;
2627
import baritone.pathing.movement.CalculationContext;
2728
import baritone.pathing.movement.Moves;
@@ -124,7 +125,11 @@ protected Optional<IPath> calculate0(long primaryTimeout, long failureTimeout) {
124125
if (actionCost <= 0 || Double.isNaN(actionCost)) {
125126
throw new IllegalStateException(String.format(
126127
"%s from %s %s %s calculated implausible cost %s",
127-
moves, currentNode.x, currentNode.y, currentNode.z, actionCost));
128+
moves,
129+
SettingsUtil.maybeCensor(currentNode.x),
130+
SettingsUtil.maybeCensor(currentNode.y),
131+
SettingsUtil.maybeCensor(currentNode.z),
132+
actionCost));
128133
}
129134
// check destination after verifying it's not COST_INF -- some movements return a static IMPOSSIBLE object with COST_INF and destination being 0,0,0 to avoid allocating a new result for every failed calculation
130135
if (moves.dynamicXZ && !worldBorder.entirelyContains(res.x, res.z)) { // see issue #218
@@ -133,14 +138,24 @@ protected Optional<IPath> calculate0(long primaryTimeout, long failureTimeout) {
133138
if (!moves.dynamicXZ && (res.x != newX || res.z != newZ)) {
134139
throw new IllegalStateException(String.format(
135140
"%s from %s %s %s ended at x z %s %s instead of %s %s",
136-
moves, currentNode.x, currentNode.y, currentNode.z,
137-
res.x, res.z, newX, newZ));
141+
moves,
142+
SettingsUtil.maybeCensor(currentNode.x),
143+
SettingsUtil.maybeCensor(currentNode.y),
144+
SettingsUtil.maybeCensor(currentNode.z),
145+
SettingsUtil.maybeCensor(res.x),
146+
SettingsUtil.maybeCensor(res.z),
147+
SettingsUtil.maybeCensor(newX),
148+
SettingsUtil.maybeCensor(newZ)));
138149
}
139150
if (!moves.dynamicY && res.y != currentNode.y + moves.yOffset) {
140151
throw new IllegalStateException(String.format(
141152
"%s from %s %s %s ended at y %s instead of %s",
142-
moves, currentNode.x, currentNode.y, currentNode.z,
143-
res.y, (currentNode.y + moves.yOffset)));
153+
moves,
154+
SettingsUtil.maybeCensor(currentNode.x),
155+
SettingsUtil.maybeCensor(currentNode.y),
156+
SettingsUtil.maybeCensor(currentNode.z),
157+
SettingsUtil.maybeCensor(res.y),
158+
SettingsUtil.maybeCensor(currentNode.y + moves.yOffset)));
144159
}
145160
long hashCode = BetterBlockPos.longHash(res.x, res.y, res.z);
146161
if (isFavoring) {

src/main/java/baritone/pathing/calc/PathNode.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import baritone.api.pathing.goals.Goal;
2121
import baritone.api.pathing.movement.ActionCosts;
2222
import baritone.api.utils.BetterBlockPos;
23+
import baritone.api.utils.SettingsUtil;
2324

2425
/**
2526
* A node in the path, containing the cost and steps to get to it.
@@ -68,7 +69,12 @@ public PathNode(int x, int y, int z, Goal goal) {
6869
this.cost = ActionCosts.COST_INF;
6970
this.estimatedCostToGoal = goal.heuristic(x, y, z);
7071
if (Double.isNaN(estimatedCostToGoal)) {
71-
throw new IllegalStateException(goal + " calculated implausible heuristic NaN at " + x + " " + y + " " + z);
72+
throw new IllegalStateException(String.format(
73+
"%s calculated implausible heuristic NaN at %s %s %s",
74+
goal,
75+
SettingsUtil.maybeCensor(x),
76+
SettingsUtil.maybeCensor(y),
77+
SettingsUtil.maybeCensor(z)));
7278
}
7379
this.heapPosition = -1;
7480
this.x = x;

0 commit comments

Comments
 (0)