mirror of
https://github.com/peterosterlund2/droidfish.git
synced 2025-12-12 17:12:40 +01:00
DroidFish: Fixed crash when reading PGN file.
This commit is contained in:
@@ -239,27 +239,39 @@ public class PGNFile {
|
|||||||
hi = new HeaderInfo();
|
hi = new HeaderInfo();
|
||||||
}
|
}
|
||||||
if (line.startsWith("[Event ")) {
|
if (line.startsWith("[Event ")) {
|
||||||
hi.event = line.substring(8, len - 2);
|
if (len >= 10) {
|
||||||
if (hi.event.equals("?")) hi.event = "";
|
hi.event = line.substring(8, len - 2);
|
||||||
|
if (hi.event.equals("?")) hi.event = "";
|
||||||
|
}
|
||||||
} else if (line.startsWith("[Site ")) {
|
} else if (line.startsWith("[Site ")) {
|
||||||
hi.site = line.substring(7, len - 2);
|
if (len >= 9) {
|
||||||
if (hi.site.equals("?")) hi.site = "";
|
hi.site = line.substring(7, len - 2);
|
||||||
|
if (hi.site.equals("?")) hi.site = "";
|
||||||
|
}
|
||||||
} else if (line.startsWith("[Date ")) {
|
} else if (line.startsWith("[Date ")) {
|
||||||
hi.date = line.substring(7, len - 2);
|
if (len >= 9) {
|
||||||
if (hi.date.equals("?")) hi.date = "";
|
hi.date = line.substring(7, len - 2);
|
||||||
|
if (hi.date.equals("?")) hi.date = "";
|
||||||
|
}
|
||||||
} else if (line.startsWith("[Round ")) {
|
} else if (line.startsWith("[Round ")) {
|
||||||
hi.round = line.substring(8, len - 2);
|
if (len >= 10) {
|
||||||
if (hi.round.equals("?")) hi.round = "";
|
hi.round = line.substring(8, len - 2);
|
||||||
|
if (hi.round.equals("?")) hi.round = "";
|
||||||
|
}
|
||||||
} else if (line.startsWith("[White ")) {
|
} else if (line.startsWith("[White ")) {
|
||||||
hi.white = line.substring(8, len - 2);
|
if (len >= 10)
|
||||||
|
hi.white = line.substring(8, len - 2);
|
||||||
} else if (line.startsWith("[Black ")) {
|
} else if (line.startsWith("[Black ")) {
|
||||||
hi.black = line.substring(8, len - 2);
|
if (len >= 10)
|
||||||
|
hi.black = line.substring(8, len - 2);
|
||||||
} else if (line.startsWith("[Result ")) {
|
} else if (line.startsWith("[Result ")) {
|
||||||
hi.result = line.substring(9, len - 2);
|
if (len >= 11) {
|
||||||
if (hi.result.equals("1-0")) hi.result = "1-0";
|
hi.result = line.substring(9, len - 2);
|
||||||
else if (hi.result.equals("0-1")) hi.result = "0-1";
|
if (hi.result.equals("1-0")) hi.result = "1-0";
|
||||||
else if ((hi.result.equals("1/2-1/2")) || (hi.result.equals("1/2"))) hi.result = "1/2-1/2";
|
else if (hi.result.equals("0-1")) hi.result = "0-1";
|
||||||
else hi.result = "*";
|
else if ((hi.result.equals("1/2-1/2")) || (hi.result.equals("1/2"))) hi.result = "1/2-1/2";
|
||||||
|
else hi.result = "*";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
inHeader = false;
|
inHeader = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user