1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Allow to call Position::print() from MovePicker

Fix a recursion issue that gives a stack overflow.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba 2008-12-05 09:50:18 +01:00
parent 9f943a132a
commit 268c12bf31

View file

@ -52,6 +52,7 @@ Key Position::zobSideToMove;
Value Position::MgPieceSquareTable[16][64];
Value Position::EgPieceSquareTable[16][64];
static bool RequestPending = false;
////
//// Functions
@ -272,6 +273,13 @@ void Position::print(Move m) const {
static const std::string pieceLetters = " PNBRQK PNBRQK .";
// Check for reentrancy, as example when called from inside
// MovePicker that is used also here in move_to_san()
if (RequestPending)
return;
RequestPending = true;
std::cout << std::endl;
if (m != MOVE_NONE)
{
@ -296,6 +304,8 @@ void Position::print(Move m) const {
std::cout << "+---+---+---+---+---+---+---+---+" << std::endl
<< "Fen is: " << to_fen() << std::endl
<< "Key is: " << key << std::endl;
RequestPending = false;
}