From e8698b39e48139357e045776c965975501f6fb7c Mon Sep 17 00:00:00 2001 From: Roland Chastain Date: Tue, 11 Feb 2020 12:06:47 +0100 Subject: [PATCH] Fix castling rule --- source/eschecs.pas | 2 +- source/position.pas | 14 +++++++------- source/version.inc | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/source/eschecs.pas b/source/eschecs.pas index 5aa43f9..e57b3b0 100644 --- a/source/eschecs.pas +++ b/source/eschecs.pas @@ -906,7 +906,7 @@ procedure TMainForm.OnMoveDone(const AHistory: string; const ASound: boolean); if (AHistory <> '') and not FChess960 then begin FOpeningName := GetOpening(AHistory); - WindowTitle := FOpeningName; + //WindowTitle := FOpeningName; end; FWaitingForUserMove := not (FGame.state in [csCheckmate, csStalemate, csDraw]); end; diff --git a/source/position.pas b/source/position.pas index ee43151..3c61bd4 100644 --- a/source/position.pas +++ b/source/position.pas @@ -276,16 +276,16 @@ function TChessPosition.IsCheck(const AColor: TPieceColorStrict): boolean; function TChessPosition.IsCastlingCheck(const ACastling: TCastling): boolean; var - x, y, dx: integer; + x, y, dx, xdest: integer; c: TPieceColorStrict; x1, x2, y1, y2: integer; i: integer; begin case ACastling of - caWH: begin y := 1; dx := -1; c := pcWhite; end; - caWA: begin y := 1; dx := 1; c := pcWhite; end; - caBH: begin y := 8; dx := -1; c := pcBlack; end; - caBA: begin y := 8; dx := 1; c := pcBlack; end; + caWH: begin y := 1; dx := -1; xdest := 7; c := pcWhite; end; + caWA: begin y := 1; dx := 1; xdest := 3; c := pcWhite; end; + caBH: begin y := 8; dx := -1; xdest := 7; c := pcBlack; end; + caBA: begin y := 8; dx := 1; xdest := 3; c := pcBlack; end; end; x := FData.FCastling[ACastling]; repeat @@ -298,8 +298,8 @@ function TChessPosition.IsCastlingCheck(const ACastling: TCastling): boolean; begin StrToMove(FList[i], x1, y1, x2, y2); if (y2 = y) - and (x2 > Min(x, FData.FCastling[ACastling])) - and (x2 < Max(x, FData.FCastling[ACastling])) then + and (x2 >= Min(x, {FData.FCastling[ACastling]}xdest)) + and (x2 <= Max(x, {FData.FCastling[ACastling]}xdest)) then result := TRUE else Inc(i); diff --git a/source/version.inc b/source/version.inc index c465465..5503f8b 100644 --- a/source/version.inc +++ b/source/version.inc @@ -1,6 +1,6 @@ const - CVersion = '5.0.5'; + CVersion = '5.0.6'; CDefaultTitle = 'Eschecs'; {$IF DEFINED(CPU64) AND DEFINED(WINDOWS)} COsType = 'win64';