mirror of
				https://github.com/tiyn/yeschess.git
				synced 2025-11-04 04:11:15 +01:00 
			
		
		
		
	bugfix: threefold repitition throws nullpointer
If the threefold repitition check is called before enough moves are saved in the previous board state it throws a nullpointer. A simple null check solves the problem
This commit is contained in:
		@@ -810,6 +810,8 @@ proc isCheckmate*(game: Game, color: Color): bool =
 | 
			
		||||
proc threeMoveRep(game: Game): bool =
 | 
			
		||||
  ## Returns true if a 3-fold repitition happened on the last move of the
 | 
			
		||||
  ## `game`.
 | 
			
		||||
  if game.previousBoard == []:
 | 
			
		||||
    return false
 | 
			
		||||
  var lastState = game.previousBoard[game.previousBoard.high]
 | 
			
		||||
  var lastCastleRights = game.previousCastleRights[game.previousBoard.high]
 | 
			
		||||
  var reps = 0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user