From 750b200d90f8c192e213526dd9def37e01de8357 Mon Sep 17 00:00:00 2001 From: Ryley Kimmel Date: Wed, 25 Feb 2015 23:50:42 -0500 Subject: [PATCH] Use the Positions hashcode implementation and utilize toStringHelper within Node. --- src/org/apollo/game/model/entity/path/Node.java | 7 ++++--- .../game/model/entity/path/SimplePathfindingAlgorithm.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/org/apollo/game/model/entity/path/Node.java b/src/org/apollo/game/model/entity/path/Node.java index 096cc843..1028abb8 100644 --- a/src/org/apollo/game/model/entity/path/Node.java +++ b/src/org/apollo/game/model/entity/path/Node.java @@ -5,6 +5,8 @@ import java.util.Optional; import org.apollo.game.model.Position; +import com.google.common.base.MoreObjects; + /** * A node representing a weighted {@link Position}. * @@ -100,7 +102,7 @@ final class Node { @Override public int hashCode() { - return position.getX() * 31 + position.getY(); + return position.hashCode(); } /** @@ -141,8 +143,7 @@ final class Node { @Override public String toString() { - return Node.class.getSimpleName() + " [x=" + position.getX() + ", y=" + position.getY() + ", open=" + open + ", cost=" - + cost + "]"; + return MoreObjects.toStringHelper(this).add("position", position).add("open", open).add("cost", cost).toString(); } } \ No newline at end of file diff --git a/src/org/apollo/game/model/entity/path/SimplePathfindingAlgorithm.java b/src/org/apollo/game/model/entity/path/SimplePathfindingAlgorithm.java index 21d62763..0ef4b77d 100644 --- a/src/org/apollo/game/model/entity/path/SimplePathfindingAlgorithm.java +++ b/src/org/apollo/game/model/entity/path/SimplePathfindingAlgorithm.java @@ -8,7 +8,7 @@ import org.apollo.game.model.Position; /** * A very simple pathfinding algorithm that simply walks in the direction of the target until it either reaches it or is - * blocked. TODO diagonal movement support. + * blocked. * * @author Major */