mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2024-11-23 11:31:33 +01:00
Prevent crash if engine produces an invalid PV
If an engine produces an invalid PV during analysis and the "add analysis" function is used to add the PV to the game tree, the app could crash. Fixed this by ignoring the invalid PV move and any following moves in the PV.
This commit is contained in:
parent
6c6db65f18
commit
6a9af8206b
|
@ -998,12 +998,16 @@ public class DroidComputerPlayer {
|
|||
if (havePvData) {
|
||||
while (statPvInfo.size() < pvNum)
|
||||
statPvInfo.add(new PvInfo(0, 0, 0, 0, 0, 0, 0, 0, false, false, false, new ArrayList<Move>()));
|
||||
while (statPvInfo.size() <= pvNum)
|
||||
if (statPvInfo.size() == pvNum)
|
||||
statPvInfo.add(null);
|
||||
ArrayList<Move> moves = new ArrayList<>();
|
||||
int nMoves = statPV.size();
|
||||
for (i = 0; i < nMoves; i++)
|
||||
moves.add(TextIO.UCIstringToMove(statPV.get(i)));
|
||||
for (i = 0; i < nMoves; i++) {
|
||||
Move m = TextIO.UCIstringToMove(statPV.get(i));
|
||||
if (m == null)
|
||||
break;
|
||||
moves.add(m);
|
||||
}
|
||||
statPvInfo.set(pvNum, new PvInfo(statPVDepth, statScore, statTime, statNodes, statNps,
|
||||
statTBHits, statHash, statSelDepth,
|
||||
statIsMate, statUpperBound, statLowerBound, moves));
|
||||
|
|
|
@ -831,11 +831,13 @@ public class DroidChessController {
|
|||
buf.append(String.format(Locale.US, " [%s]", moveStr));
|
||||
tmpPos.makeMove(ponderMove, ui);
|
||||
}
|
||||
for (Move m : pv.pv) {
|
||||
if (m == null)
|
||||
break;
|
||||
if (!TextIO.isValid(tmpPos, m))
|
||||
for (int i = 0; i < pv.pv.size(); i++) {
|
||||
Move m = pv.pv.get(i);
|
||||
if (!TextIO.isValid(tmpPos, m)) {
|
||||
while (pv.pv.size() > i)
|
||||
pv.pv.remove(pv.pv.size() - 1);
|
||||
break;
|
||||
}
|
||||
String moveStr = TextIO.moveToString(tmpPos, m, false, localPt());
|
||||
buf.append(String.format(Locale.US, " %s", moveStr));
|
||||
tmpPos.makeMove(m, ui);
|
||||
|
|
Loading…
Reference in New Issue
Block a user