mta: Null checks

This commit is contained in:
sdburns1998
2019-07-07 15:46:49 +02:00
parent 5a11f1eddf
commit 6b644f92cd
2 changed files with 22 additions and 4 deletions

View File

@@ -249,7 +249,10 @@ public class AlchemyRoom extends MTARoom
Cupboard clicked = getClicked();
if (clicked.alchemyItem != alchemyItem)
{
fill(clicked, alchemyItem);
if (alchemyItem != null)
{
fill(clicked, alchemyItem);
}
}
}
else if (message.equals(EMPTY))

View File

@@ -286,7 +286,11 @@ public class TelekineticRoom extends MTARoom
Direction next = moves.pop();
WorldArea areaNext = getIndicatorLine(next);
WorldPoint nearestNext = nearest(areaNext, current);
WorldPoint nearestNext = null;
if (areaNext != null)
{
nearestNext = nearest(areaNext, current);
}
if (moves.isEmpty())
{
@@ -298,9 +302,20 @@ public class TelekineticRoom extends MTARoom
Direction after = moves.peek();
moves.push(next);
WorldArea areaAfter = getIndicatorLine(after);
WorldPoint nearestAfter = nearest(areaAfter, nearestNext);
WorldPoint nearestAfter = null;
if (areaAfter != null)
{
nearestAfter = nearest(areaAfter, nearestNext);
}
return nearest(areaNext, nearestAfter);
if (areaNext != null)
{
return nearest(areaNext, nearestAfter);
}
else
{
return nearestAfter;
}
}
private static int manhattan(WorldPoint point1, WorldPoint point2)