X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fbook.cpp;h=9528e47c8c9e99c383e22838371723f9e1a09e6f;hb=94a67c49b0238200bbd4b167d067f067ff4aad30;hp=0212317f88ce281608af946e1bad631a58c0122b;hpb=9dcc2aad98b970380a66b61f2238875e9051de97;p=stockfish diff --git a/src/book.cpp b/src/book.cpp index 0212317f..9528e47c 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -365,18 +365,20 @@ void Book::open(const string& fName) { fileName = fName; ifstream::open(fileName.c_str(), ifstream::in | ifstream::binary); - if (is_open()) - { - // Get the book size in number of entries - seekg(0, ios::end); - bookSize = long(tellg()) / EntrySize; - seekg(0, ios::beg); + // Silently return when asked to open a non-exsistent file + if (!is_open()) + return; + + // Get the book size in number of entries + seekg(0, ios::end); + bookSize = long(tellg()) / EntrySize; + seekg(0, ios::beg); - if (good()) - return; + if (!good()) + { + cerr << "Failed to open book file " << fileName << endl; + exit(EXIT_FAILURE); } - cerr << "Failed to open book file " << fileName << endl; - Application::exit_with_failure(); } @@ -496,7 +498,7 @@ void Book::read_entry(BookEntry& entry, int idx) { if (!good()) { cerr << "Failed to read book entry at index " << idx << endl; - Application::exit_with_failure(); + exit(EXIT_FAILURE); } } @@ -528,7 +530,7 @@ namespace { uint64_t book_key(const Position& pos) { uint64_t result = 0; - Bitboard b = pos.pieces_of_color(WHITE) | pos.pieces_of_color(BLACK); + Bitboard b = pos.occupied_squares(); while (b) {