Crash fix.

This commit is contained in:
2013-06-24 01:52:23 +04:00
parent 6c99d0a6eb
commit 0b18acab40

View File

@@ -7,6 +7,7 @@ package org.dyndns.vahagn.sokoban.play;
import static java.lang.Math.*;
import java.util.Arrays;
import org.dyndns.vahagn.sokoban.Puzzle;
import static org.dyndns.vahagn.sokoban.App.TAG;
/**
*
@@ -29,7 +30,7 @@ public class PuzzleLogic
setOfCells = new int[2*puzzle.getColumnCount()*puzzle.getRowCount()];
}
public boolean createSteps(Animator animator, int x, int y )
public boolean createSteps(Animator animator, final int x, final int y )
{
//
// Check that the x,y are valid.
@@ -300,7 +301,8 @@ public class PuzzleLogic
// Move the worker to the direction. If we cannot move worker
// next to the box then we cannot select it.
//
if ( !tryMoveWorker(animator, pref_x, pref_y) )
if ( !puzzle.isValid(pref_x, pref_y)
|| !tryMoveWorker(animator, pref_x, pref_y) )
return false;
//
// Select the box.
@@ -440,7 +442,7 @@ public class PuzzleLogic
public final boolean isAccessible( int x, int y )
{
return stepsAway(x, y) != Integer.MAX_VALUE;
return puzzle.isValid(x, y) && stepsAway(x, y) != Integer.MAX_VALUE;
}
public int [] getDirections( int x, int y )