X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fbook.cpp;h=8c7cd52c5ca39c482101d87f245bafcca9ef944e;hp=a918d043b619e6915a483400398445c1eeb96d88;hb=c9d7e99de682516c560009b550c41da9ae2008b8;hpb=611a29f7675d3e5dc7e5e2b63cca9274eae05578 diff --git a/src/book.cpp b/src/book.cpp index a918d043..8c7cd52c 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -367,8 +367,8 @@ Book::~Book() { void Book::close() { - if (is_open()) - ifstream::close(); + if (bookFile.is_open()) + bookFile.close(); bookName = ""; } @@ -381,17 +381,17 @@ void Book::open(const string& fileName) { // Close old file before opening the new close(); - ifstream::open(fileName.c_str(), ifstream::in | ifstream::binary); + bookFile.open(fileName.c_str(), ifstream::in | ifstream::binary); // Silently return when asked to open a non-exsistent file - if (!is_open()) + if (!bookFile.is_open()) return; // Get the book size in number of entries - seekg(0, ios::end); - bookSize = long(tellg()) / sizeof(BookEntry); + bookFile.seekg(0, ios::end); + bookSize = long(bookFile.tellg()) / sizeof(BookEntry); - if (!good()) + if (!bookFile.good()) { cerr << "Failed to open book file " << fileName << endl; exit(EXIT_FAILURE); @@ -408,7 +408,7 @@ void Book::open(const string& fileName) { Move Book::get_move(const Position& pos, bool findBestMove) { - if (!is_open() || bookSize == 0) + if (!bookFile.is_open() || bookSize == 0) return MOVE_NONE; BookEntry entry; @@ -459,7 +459,7 @@ Move Book::get_move(const Position& pos, bool findBestMove) { move_to(Move(bookMove)), PieceType(p + 1))); // Verify the book move (if any) is legal - MoveStack mlist[MOVES_MAX]; + MoveStack mlist[MAX_MOVES]; MoveStack* last = generate(pos, mlist); for (MoveStack* cur = mlist; cur != last; cur++) if ((int(cur->move) & ~(3 << 14)) == bookMove) // Mask out special flags @@ -508,15 +508,15 @@ int Book::find_entry(uint64_t key) { BookEntry Book::read_entry(int idx) { assert(idx >= 0 && idx < bookSize); - assert(is_open()); + assert(bookFile.is_open()); BookEntry e; - seekg(idx * sizeof(BookEntry), ios_base::beg); + bookFile.seekg(idx * sizeof(BookEntry), ios_base::beg); *this >> e.key >> e.move >> e.count >> e.learn; - if (!good()) + if (!bookFile.good()) { cerr << "Failed to read book entry at index " << idx << endl; exit(EXIT_FAILURE);