]> git.sesse.net Git - stockfish/blobdiff - src/book.cpp
Force inlining of move generation functions
[stockfish] / src / book.cpp
index 95ccd690506251c284dc557905a53d5c1cc6711f..7b5be1864c667b4269a388b0e4bdf4b267c9a2d0 100644 (file)
@@ -30,6 +30,7 @@
 ////
 
 #include <cassert>
+#include <iostream>
 
 #include "book.h"
 #include "movegen.h"
@@ -365,18 +366,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;
-  exit(EXIT_FAILURE);
 }
 
 
@@ -434,7 +437,7 @@ Move Book::get_move(const Position& pos, bool findBestMove) {
 
   // Verify the book move is legal
   MoveStack mlist[MOVES_MAX];
-  MoveStack* last = generate_moves(pos, mlist);
+  MoveStack* last = generate<MV_LEGAL>(pos, mlist);
   for (MoveStack* cur = mlist; cur != last; cur++)
       if ((int(cur->move) & 07777) == bookMove)
           return cur->move;