X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=bdac10dab4951a4cd8abc451d54389df29060486;hb=af73501b054db378b0a3e687a28e98c9234e973c;hp=29f55db2f2893f66a91d48cf7a1246e80ffbddc6;hpb=2fc6fd0719e5aa3e94bdb80b581d849a2ebb4d0f;p=xboard.git diff --git a/backend.c b/backend.c index 29f55db..bdac10d 100644 --- a/backend.c +++ b/backend.c @@ -77,6 +77,7 @@ #if STDC_HEADERS # include # include +# include #else /* not STDC_HEADERS */ # if HAVE_STRING_H # include @@ -1423,12 +1424,14 @@ KeepAlive() /* added routine for printf style output to ics */ void ics_printf(char *format, ...) { - char buffer[MSG_SIZ], *args; - - args = (char *)&format + sizeof(format); - vsnprintf(buffer, sizeof(buffer), format, args); - buffer[sizeof(buffer)-1] = '\0'; - SendToICS(buffer); + char buffer[MSG_SIZ]; + va_list args; + + va_start(args, format); + vsnprintf(buffer, sizeof(buffer), format, args); + buffer[sizeof(buffer)-1] = '\0'; + SendToICS(buffer); + va_end(args); } void @@ -1937,8 +1940,6 @@ void VariantSwitch(Board board, VariantClass newVariant) { int newHoldingsWidth, newWidth = 8, newHeight = 8, i, j; - int oldCurrentMove = currentMove, oldForwardMostMove = forwardMostMove, oldBackwardMostMove = backwardMostMove; -// Board tempBoard; int saveCastling[BOARD_SIZE], saveEP; startedFromPositionFile = FALSE; if(gameInfo.variant == newVariant) return; @@ -1955,59 +1956,65 @@ VariantSwitch(Board board, VariantClass newVariant) * case we want to add those holdings to the already received position. */ - - if (appData.debugMode) { - fprintf(debugFP, "Switch board from %s to %s\n", - VariantName(gameInfo.variant), VariantName(newVariant)); - setbuf(debugFP, NULL); - } - shuffleOpenings = 0; /* [HGM] shuffle */ - gameInfo.holdingsSize = 5; /* [HGM] prepare holdings */ - switch(newVariant) { - case VariantShogi: - newWidth = 9; newHeight = 9; - gameInfo.holdingsSize = 7; - case VariantBughouse: - case VariantCrazyhouse: - newHoldingsWidth = 2; break; - default: - newHoldingsWidth = gameInfo.holdingsSize = 0; - } - - if(newWidth != gameInfo.boardWidth || - newHeight != gameInfo.boardHeight || - newHoldingsWidth != gameInfo.holdingsWidth ) { - - /* shift position to new playing area, if needed */ - if(newHoldingsWidth > gameInfo.holdingsWidth) { - for(i=0; i=BOARD_LEFT; j--) - board[i][j+newHoldingsWidth-gameInfo.holdingsWidth] = - board[i][j]; - for(i=0; i gameInfo.holdingsWidth) { + for(i=0; i=BOARD_LEFT; j--) + board[i][j+newHoldingsWidth-gameInfo.holdingsWidth] = + board[i][j]; + for(i=0; i