diff --git a/src/pawns.cpp b/src/pawns.cpp index b5c377ef..5a789ef2 100644 --- a/src/pawns.cpp +++ b/src/pawns.cpp @@ -214,7 +214,7 @@ Score PawnInfoTable::evaluate_pawns(const Position& pos, Bitboard ourPawns, pi->qsStormValue[Us] += QStormTable[relative_square(Us, s)] + bonus; // Our rank plus previous one. Used for chain detection. - b = rank_bb(r) | rank_bb(Us == WHITE ? r - 1 : r + 1); + b = rank_bb(r) | rank_bb(Us == WHITE ? r - Rank(1) : r + Rank(1)); // Passed, isolated, doubled or member of a pawn // chain (but not the backward one) ? diff --git a/src/position.cpp b/src/position.cpp index c8132d5e..021113ed 100644 --- a/src/position.cpp +++ b/src/position.cpp @@ -182,7 +182,7 @@ void Position::from_fen(const string& fen) { { if (isdigit(token)) { - file += token - '0'; // Skip the given number of files + file += File(token - '0'); // Skip the given number of files continue; } else if (token == '/') diff --git a/src/square.h b/src/square.h index e4eab2ac..8de3f55c 100644 --- a/src/square.h +++ b/src/square.h @@ -77,22 +77,6 @@ const int FlopMask = 07; //// Inline functions //// -inline File operator+ (File x, int i) { return File(int(x) + i); } -inline File operator+ (File x, File y) { return x + int(y); } -inline void operator++ (File &x, int) { x = File(int(x) + 1); } -inline void operator+= (File &x, int i) { x = File(int(x) + i); } -inline File operator- (File x, int i) { return File(int(x) - i); } -inline void operator-- (File &x, int) { x = File(int(x) - 1); } -inline void operator-= (File &x, int i) { x = File(int(x) - i); } - -inline Rank operator+ (Rank x, int i) { return Rank(int(x) + i); } -inline Rank operator+ (Rank x, Rank y) { return x + int(y); } -inline void operator++ (Rank &x, int) { x = Rank(int(x) + 1); } -inline void operator+= (Rank &x, int i) { x = Rank(int(x) + i); } -inline Rank operator- (Rank x, int i) { return Rank(int(x) - i); } -inline void operator-- (Rank &x, int) { x = Rank(int(x) - 1); } -inline void operator-= (Rank &x, int i) { x = Rank(int(x) - i); } - inline Square operator+ (Square x, int i) { return Square(int(x) + i); } inline void operator++ (Square &x, int) { x = Square(int(x) + 1); } inline void operator+= (Square &x, int i) { x = Square(int(x) + i); } @@ -103,6 +87,7 @@ inline Square operator+ (Square x, SquareDelta i) { return Square(int(x) + i); } inline void operator+= (Square &x, SquareDelta i) { x = Square(int(x) + i); } inline Square operator- (Square x, SquareDelta i) { return Square(int(x) - i); } inline void operator-= (Square &x, SquareDelta i) { x = Square(int(x) - i); } + inline SquareDelta operator- (Square x, Square y) { return SquareDelta(int(x) - int(y)); } diff --git a/src/types.h b/src/types.h index 4931531b..f018311d 100644 --- a/src/types.h +++ b/src/types.h @@ -125,6 +125,12 @@ inline T operator* (int i, const T d) { return T(int(d) * i); } template inline T operator/ (const T d, int i) { return T(int(d) / i); } +template +inline void operator++ (T& d, int) { d = T(int(d) + 1); } + +template +inline void operator-- (T& d, int) { d = T(int(d) - 1); } + template inline void operator+= (T& d1, const T d2) { d1 = d1 + d2; }