mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-04-10 22:22:47 +02:00
Don't try to fixup invalid e.p. square if the position is invalid
En passant fixup requires generating a list of legal moves, which can fail with an array index out of bounds exception if there is a pawn on the first/last rank.
This commit is contained in:
parent
61317fa78d
commit
1afda36d85
@ -442,6 +442,7 @@ public class EditBoard extends Activity {
|
|||||||
|
|
||||||
private void setPosFields() {
|
private void setPosFields() {
|
||||||
setEPFile(getEPFile()); // To handle sideToMove change
|
setEPFile(getEPFile()); // To handle sideToMove change
|
||||||
|
if (isValid())
|
||||||
TextIO.fixupEPSquare(cb.pos);
|
TextIO.fixupEPSquare(cb.pos);
|
||||||
TextIO.removeBogusCastleFlags(cb.pos);
|
TextIO.removeBogusCastleFlags(cb.pos);
|
||||||
}
|
}
|
||||||
@ -478,6 +479,16 @@ public class EditBoard extends Activity {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return true if the position is valid. */
|
||||||
|
private boolean isValid() {
|
||||||
|
try {
|
||||||
|
TextIO.readFEN(TextIO.toFEN(cb.pos));
|
||||||
|
return true;
|
||||||
|
} catch (ChessParseError e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getParseErrString(ChessParseError e) {
|
private String getParseErrString(ChessParseError e) {
|
||||||
if (e.resourceId == -1)
|
if (e.resourceId == -1)
|
||||||
return e.getMessage();
|
return e.getMessage();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user