From: H.G. Muller Date: Fri, 5 Feb 2010 21:27:51 +0000 (+0100) Subject: One-click moves X-Git-Tag: master-20100206~2 X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=32bbe66c5718d2187e62550c058ffd1632b2f3e6;p=xboard.git One-click moves Playing on ICS or against engine, clicking a square from or to which only a single move can be made causes the move to be done, when the new option -oneClickMove is set to true. --- diff --git a/args.h b/args.h index 1c6053e..e85deb4 100644 --- a/args.h +++ b/args.h @@ -542,6 +542,7 @@ ArgDescriptor argDescriptors[] = { { "defaultPathEGTB", ArgFilename, (void *) &appData.defaultPathEGTB, TRUE, (ArgIniType) "c:\\egtb" }, /* [HGM] board-size, adjudication and misc. options */ + { "oneClickMove", ArgBoolean, (void *) &appData.oneClick, TRUE, (ArgIniType) FALSE }, { "boardWidth", ArgInt, (void *) &appData.NrFiles, TRUE, (ArgIniType) -1 }, { "boardHeight", ArgInt, (void *) &appData.NrRanks, TRUE, (ArgIniType) -1 }, { "holdingsSize", ArgInt, (void *) &appData.holdingsSize, TRUE, (ArgIniType) -1 }, diff --git a/backend.c b/backend.c index 6499a0d..afb509c 100644 --- a/backend.c +++ b/backend.c @@ -5549,6 +5549,55 @@ OKToStartUserMove(x, y) return TRUE; } +Boolean +OnlyMove(int *x, int *y) { + DisambiguateClosure cl; + if (appData.zippyPlay) return FALSE; + switch(gameMode) { + case MachinePlaysBlack: + case IcsPlayingWhite: + case BeginningOfGame: + if(!WhiteOnMove(currentMove)) return FALSE; + break; + case MachinePlaysWhite: + case IcsPlayingBlack: + if(WhiteOnMove(currentMove)) return FALSE; + break; + default: + return FALSE; + } + cl.pieceIn = EmptySquare; + cl.rfIn = *y; + cl.ffIn = *x; + cl.rtIn = -1; + cl.ftIn = -1; + cl.promoCharIn = NULLCHAR; + Disambiguate(boards[currentMove], PosFlags(currentMove), &cl); + if(cl.kind == NormalMove) { + fromX = cl.ff; + fromY = cl.rf; + *x = cl.ft; + *y = cl.rt; + return TRUE; + } + if(cl.kind != ImpossibleMove) return FALSE; + cl.pieceIn = EmptySquare; + cl.rfIn = -1; + cl.ffIn = -1; + cl.rtIn = *y; + cl.ftIn = *x; + cl.promoCharIn = NULLCHAR; + Disambiguate(boards[currentMove], PosFlags(currentMove), &cl); + if(cl.kind == NormalMove) { + fromX = cl.ff; + fromY = cl.rf; + *x = cl.ft; + *y = cl.rt; + return TRUE; + } + return FALSE; +} + FILE *lastLoadGameFP = NULL, *lastLoadPositionFP = NULL; int lastLoadGameNumber = 0, lastLoadPositionNumber = 0; int lastLoadGameUseList = FALSE; @@ -6039,6 +6088,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) return; if (fromX == -1) { + if(!appData.oneClick || !OnlyMove(&x, &y)) { if (clickType == Press) { /* First square */ if (OKToStartUserMove(x, y)) { @@ -6053,6 +6103,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } } return; + } } /* fromX != -1 */ diff --git a/common.h b/common.h index f97f16c..a5577e2 100644 --- a/common.h +++ b/common.h @@ -448,6 +448,7 @@ typedef struct { char *cmailGameName; /* xboard only */ Boolean alwaysPromoteToQueen; Boolean oldSaveStyle; + Boolean oneClick; Boolean quietPlay; Boolean showThinking; Boolean ponderNextMove;