X-Git-Url: https://git.sesse.net/?p=stockfish;a=blobdiff_plain;f=src%2Fposition.cpp;h=c5c63c2b3862701ffdf65ba258d0a407b82c2a5c;hp=a472c84594a219dd22ecf6d09a91bb04c820b74a;hb=2f6927ac08887ff3b709cfe9228b27a85bdd1d88;hpb=f148a8f6ccbb57c440910ecfd4845c7f497b5404 diff --git a/src/position.cpp b/src/position.cpp index a472c845..c5c63c2b 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -74,23 +74,23 @@ CheckInfo::CheckInfo(const Position& pos) { } -/// Position c'tors. Here we always create a slower but safer copy of -/// the original position or the FEN string, we want the new born Position -/// object do not depend on any external data. Instead if we know what we -/// are doing and we need speed we can create a position with default -/// c'tor Position() and then use just fast_copy(). +/// Position c'tors. Here we always create a copy of the original position +/// or the FEN string, we want the new born Position object do not depend +/// on any external data so we detach state pointer from the source one. -Position::Position() {} +Position::Position(int th) : threadID(th) {} -Position::Position(const Position& pos) { +Position::Position(const Position& pos, int th) { memcpy(this, &pos, sizeof(Position)); detach(); // Always detach() in copy c'tor to avoid surprises + threadID = th; } -Position::Position(const string& fen) { +Position::Position(const string& fen, int th) { from_fen(fen); + threadID = th; } @@ -340,7 +340,7 @@ void Position::print(Move m) const { std::cout << std::endl; if (m != MOVE_NONE) { - Position p(*this); + Position p(*this, thread()); string col = (color_of_piece_on(move_from(m)) == BLACK ? ".." : ""); std::cout << "Move is: " << col << move_to_san(p, m) << std::endl; } @@ -1785,6 +1785,7 @@ void Position::flipped_copy(const Position& pos) { assert(pos.is_ok()); clear(); + threadID = pos.thread(); // Board for (Square s = SQ_A1; s <= SQ_H8; s++)