From 55729048876a63cbb6d264e074cbd754e4125080 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Mon, 15 Jul 2019 10:49:55 -0400 Subject: chessbox: Fixes and enhancements - Unfinished game is now saved along with current position. - All savings are automatically done on shutdown. - Implemented facility to view played games. - Fixed bug that prevented program from the very first move. Patch by Igor Poretsky Change-Id: I997b97752e4362ed953309bea985d071f9db229b --- apps/plugins/chessbox/gnuchess.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apps/plugins/chessbox/gnuchess.c') diff --git a/apps/plugins/chessbox/gnuchess.c b/apps/plugins/chessbox/gnuchess.c index ff9bb99b91..f0600e3d67 100644 --- a/apps/plugins/chessbox/gnuchess.c +++ b/apps/plugins/chessbox/gnuchess.c @@ -1167,12 +1167,12 @@ void OpeningBook() m = 0; while ( o_c < MAX_OPENING ) { m_c = 0 ; - for (j = 0; j <= GameCnt; j++) { + for (j = 0; j < ((GameCnt + 1) & 0xFF); j++) { if ( GameList[j].gmove != OBook[o_c][m_c] ) break; m_c++; } /* I added ( m != OBook[o_c][m_c] ) trying to get more random games */ - if ( ( j > GameCnt ) && ( m != OBook[o_c][m_c] ) ) { + if ( ( j >= ((GameCnt + 1) & 0xFF) ) && ( m != OBook[o_c][m_c] ) ) { r=rb->rand(); if ( r > r0 ) { r0 = r; m = OBook[o_c][m_c]; @@ -2066,7 +2066,7 @@ register short i,c,f,t; short b[64]; unsigned short m; *cnt = c = 0; - if (GameCnt > Game50+3) + if (((GameCnt + 1) & 0xFF) > Game50+4) { for (i = 0; i < 64; b[i++] = 0); for (i = GameCnt; i > Game50; i--) -- cgit v1.2.3