X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=4537da1fa716241e197da0509789e247fd041b5a;hb=985cec56a6e655776b35dfeaf338f748808651da;hp=933b07a169a8286737bd5dae8b09e6f6dafc7641;hpb=ab773ff40f992d0462d500b429d4df863be9d288;p=xboard.git diff --git a/backend.c b/backend.c index 933b07a..4537da1 100644 --- a/backend.c +++ b/backend.c @@ -261,7 +261,7 @@ void ics_update_width P((int new_width)); extern char installDir[MSG_SIZ]; VariantClass startVariant; /* [HGM] nicks: initial variant */ Boolean abortMatch; -int deadRanks, handSize; +int deadRanks, handSize, handOffsets; extern int tinyLayout, smallLayout; ChessProgramStats programStats; @@ -4741,7 +4741,13 @@ ParseBoard12 (char *string) boards[moveNum][EP_STATUS] = EP_NONE; if(str[0] == 'P') boards[moveNum][EP_STATUS] = EP_PAWN_MOVE; if(strchr(move_str, 'x')) boards[moveNum][EP_STATUS] = EP_CAPTURE; - if(double_push != -1) boards[moveNum][EP_STATUS] = double_push + BOARD_LEFT; + if(double_push != -1) { + int dir = WhiteOnMove(moveNum) ? 1 : -1, last = BOARD_HEIGHT-1; + boards[moveNum][EP_FILE] = // also set new e.p. variables + boards[moveNum][EP_STATUS] = double_push + BOARD_LEFT; + boards[moveNum][EP_RANK] = (last + 3*dir)/2; + boards[moveNum][LAST_TO] = 128*(last + dir) + boards[moveNum][EP_FILE]; + } else boards[moveNum][EP_FILE] = boards[moveNum][EP_RANK] = 100; if (ics_getting_history == H_GOT_REQ_HEADER || @@ -4907,7 +4913,7 @@ ParseBoard12 (char *string) && gameInfo.variant != VariantGrand&& gameInfo.variant != VariantSChess) // inherit info that ICS does not give from previous board for(k=0; k= BlackPawn && old < BlackCannon) boards[moveNum][k][j] = PROMOTED(old); // choose correct type of Gold in promotion else boards[moveNum][k][j] = old; // preserve type of Gold - } else if((old == WhitePawn || old == BlackPawn) && new != EmptySquare) // Pawn promotions (but not e.p.capture!) + } else if(old == WhitePawn || old == BlackPawn) // Pawn promotions (but not e.p.capture!) boards[moveNum][k][j] = PROMOTED(new); // use non-primordial representation of chosen piece } } else { @@ -6359,14 +6365,14 @@ InitPosition (int redraw) } if(appData.holdingsSize >= 0) { i = appData.holdingsSize; - if(i > gameInfo.boardHeight) i = gameInfo.boardHeight; +// if(i > gameInfo.boardHeight) i = gameInfo.boardHeight; gameInfo.holdingsSize = i; } if(gameInfo.holdingsSize) gameInfo.holdingsWidth = 2; if(BOARD_HEIGHT > BOARD_RANKS || BOARD_WIDTH > BOARD_FILES) DisplayFatalError(_("Recompile to support this BOARD_RANKS or BOARD_FILES!"), 0, 2); - handSize = BOARD_HEIGHT; + if(!handSize) handSize = BOARD_HEIGHT; pawnRow = gameInfo.boardHeight - 7; /* seems to work in all common variants */ if(pawnRow < 1) pawnRow = 1; if(gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN || @@ -6823,12 +6829,45 @@ InPalace (int row, int column) int PieceForSquare (int x, int y) { - if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) - return -1; - else + if (x < 0 || x >= BOARD_WIDTH || y < 0 || y >= BOARD_HEIGHT) return -1; + if(x == BOARD_RGHT+1 && handOffsets & 1) y += handSize - BOARD_HEIGHT; + if(x == BOARD_LEFT-2 && !(handOffsets & 2)) y += handSize - BOARD_HEIGHT; return boards[currentMove][y][x]; } +ChessSquare +More (Board board, int col, int start, int end) +{ + int k; + for(k=start; k BOARD_HEIGHT && board) { + int k; + CopyBoard(compactedBoard, board); + if(handOffsets & 1) { + for(k=0; k h) handSize = hand; else handSize = h; appData.NrFiles = w; appData.NrRanks = h; appData.holdingsSize = hand; if(dummy == 4) gameInfo.variant = StringToVariant(varName); // parent variant InitPosition(1); // calls InitDrawingSizes to let new parameters take effect @@ -11401,6 +11465,7 @@ RecentEngineEvent (int nr) if(mnemonic[n]) { // if somehow the engine with the selected nickname is no longer found in the list, we skip ReplaceEngine(&first, 0); FloatToFront(&appData.recentEngineList, command[n]); + ASSIGN(currentEngine[0], command[n]); } } @@ -12102,6 +12167,7 @@ Reset (int redraw, int init) } pieceDefs = FALSE; // [HGM] gen: reset engine-defined piece moves deadRanks = 0; // assume entire board is used + handSize = 0; for(i=0; i= BOARD_RGHT) { if(x == BOARD_LEFT-2) { - if(y < BOARD_HEIGHT-1-gameInfo.holdingsSize) break; + if(y < handSize-1-gameInfo.holdingsSize) break; boards[0][y][1] = 0; } else if(x == BOARD_RGHT+1) { @@ -17313,6 +17386,8 @@ ParseOption (Option *opt, ChessProgramState *cps) opt->type = SaveButton; } else return FALSE; *p = 0; // terminate option name + *(int*) (opt->name + MSG_SIZ - 104) = opt->value; // hide default values somewhere + if(opt->target == &opt->textValue) strncpy(opt->name + MSG_SIZ - 100, opt->textValue, 99); // now look if the command-line options define a setting for this engine option. if(cps->optionSettings && cps->optionSettings[0]) p = strstr(cps->optionSettings, opt->name); else p = NULL; @@ -17325,6 +17400,8 @@ ParseOption (Option *opt, ChessProgramState *cps) if(!strcmp(((char**)opt->textValue)[n], q+1)) opt->value = n; break; case TextBox: + case FileName: + case PathName: safeStrCpy(opt->textValue, q+1, MSG_SIZ - (opt->textValue - opt->name)); break; case Spin: @@ -17336,8 +17413,6 @@ ParseOption (Option *opt, ChessProgramState *cps) strcat(buf, "\n"); SendToProgram(buf, cps); } - *(int*) (opt->name + MSG_SIZ - 104) = opt->value; // hide default values somewhere - if(opt->target == &opt->textValue) strncpy(opt->name + MSG_SIZ - 100, opt->textValue, 99); return TRUE; } @@ -17347,7 +17422,7 @@ FeatureDone (ChessProgramState *cps, int val) DelayedEventCallback cb = GetDelayedEvent(); if ((cb == InitBackEnd3 && cps == &first) || (cb == SettingsMenuIfReady && cps == &second) || - (cb == LoadEngine) || + (cb == LoadEngine) || (cb == StartSecond) || (cb == TwoMachinesEventIfReady)) { CancelDelayedEvent(); ScheduleDelayedEvent(cb, val ? 1 : 3600000); @@ -18337,9 +18412,9 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) *p++ = PieceToChar(piece); } for(i=0; i= bcnt) n = rand() % bcnt; // use same randomization for black and white if possible - for(k=0, m=n; k