From: H.G. Muller Date: Fri, 5 Jun 2009 05:52:31 +0000 (-0700) Subject: source clean up. Fix compiler warning, removed unused variables, etc. X-Git-Tag: v4.4.0.alpha4~3 X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=570f0d333ffba03730d5bc5a69ef5a509247104f source clean up. Fix compiler warning, removed unused variables, etc. --- diff --git a/backend.c b/backend.c index 5ae5525..910d1d8 100644 --- a/backend.c +++ b/backend.c @@ -70,6 +70,7 @@ #include #include #include +#include #if STDC_HEADERS # include @@ -210,6 +211,10 @@ void ParseFeatures P((char* args, ChessProgramState *cps)); void InitBackEnd3 P((void)); void FeatureDone P((ChessProgramState* cps, int val)); void InitChessProgram P((ChessProgramState *cps, int setup)); +void OutputKibitz(int window, char *text); +int PerpetualChase(int first, int last); +int EngineOutputIsUp(); +void InitDrawingSizes(int x, int y); #ifdef WIN32 extern void ConsoleCreate(); @@ -228,8 +233,7 @@ extern char installDir[MSG_SIZ]; extern int tinyLayout, smallLayout; ChessProgramStats programStats; static int exiting = 0; /* [HGM] moved to top */ -static int setboardSpoiledMachineBlack = 0, errorExitFlag = 0; -extern int startedFromPositionFile; +static int setboardSpoiledMachineBlack = 0 /*, errorExitFlag = 0*/; int startedFromPositionFile = FALSE; Board filePosition; /* [HGM] loadPos */ char endingGame = 0; /* [HGM] crash: flag to prevent recursion of GameEnds() */ int whiteNPS, blackNPS; /* [HGM] nps: for easily making clocks aware of NPS */ @@ -290,6 +294,8 @@ static char * safeStrCpy( char * dst, const char * src, size_t count ) return dst; } +#if 0 +//[HGM] for future use? Conditioned out for now to suppress warning. static char * safeStrCat( char * dst, const char * src, size_t count ) { size_t dst_len; @@ -306,6 +312,7 @@ static char * safeStrCat( char * dst, const char * src, size_t count ) return dst; } +#endif /* Some compiler can't cast u64 to double * This function do the job for us: @@ -1943,7 +1950,7 @@ 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; +// Board tempBoard; int saveCastling[BOARD_SIZE], saveEP; startedFromPositionFile = FALSE; if(gameInfo.variant == newVariant) return; @@ -2359,10 +2366,10 @@ read_from_ics(isr, closure, data, count, error) (StrStr(star_match[0], gameInfo.white) == star_match[0] || StrStr(star_match[0], gameInfo.black) == star_match[0] )) { // kibitz of self or opponent suppressKibitz = TRUE; - if((StrStr(star_match[0], gameInfo.white) == star_match[0]) - && (gameMode == IcsPlayingWhite) || - (StrStr(star_match[0], gameInfo.black) == star_match[0]) - && (gameMode == IcsPlayingBlack) ) // opponent kibitz + if((StrStr(star_match[0], gameInfo.white) == star_match[0] + && (gameMode == IcsPlayingWhite)) || + (StrStr(star_match[0], gameInfo.black) == star_match[0] + && (gameMode == IcsPlayingBlack)) ) // opponent kibitz started = STARTED_CHATTER; // own kibitz we simply discard else { started = STARTED_COMMENT; // make sure it will be collected in parse[] @@ -2852,7 +2859,7 @@ read_from_ics(isr, closure, data, count, error) if(bookHit) { // [HGM] book: simulate book reply static char bookMove[MSG_SIZ]; // a bit generous? - programStats.depth = programStats.nodes = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; sprintf(programStats.movelist, "%s (xbook)", bookHit); @@ -3882,7 +3889,7 @@ ParseBoard12(string) if(bookHit) { // [HGM] book: simulate book reply static char bookMove[MSG_SIZ]; // a bit generous? - programStats.depth = programStats.nodes = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; sprintf(programStats.movelist, "%s (xbook)", bookHit); @@ -4102,7 +4109,7 @@ ProcessICSInitScript(f) void AlphaRank(char *move, int n) { - char *p = move, c; int x, y; +// char *p = move, c; int x, y; if (appData.debugMode) { fprintf(debugFP, "alphaRank(%s,%d)\n", move, n); @@ -4246,6 +4253,7 @@ ParseOneMove(move, moveNum, moveType, fromX, fromY, toX, toY, promoChar) } } +#if 0 /* [AS] FRC game initialization */ static int FindEmptySquare( Board board, int n ) { @@ -4262,7 +4270,6 @@ static int FindEmptySquare( Board board, int n ) return i; } -#if 0 static void ShuffleFRC( Board board ) { int i; @@ -4354,7 +4361,7 @@ static void SetupFRC( Board board, int pos_index ) int squaresLeft[4]; int piecesLeft[(int)BlackPawn]; -long long int seed, nrOfShuffles; +u64 seed, nrOfShuffles; void GetPositionNumber() { // sets global variable seed @@ -4375,9 +4382,9 @@ int put(Board board, int pieceType, int rank, int n, int shade) int i; for(i=BOARD_LEFT; i (int) WhitePawn; p--) { if(p != (int) WhiteBishop && p != (int) WhiteFerz && p != (int) WhiteAlfil) continue; @@ -4645,10 +4652,10 @@ InitPosition(redraw) nrCastlingRights = 6; castlingRights[0][0] = initialRights[0] = BOARD_RGHT-1; castlingRights[0][1] = initialRights[1] = BOARD_LEFT; - castlingRights[0][2] = initialRights[2] = BOARD_WIDTH-1>>1; + castlingRights[0][2] = initialRights[2] =(BOARD_WIDTH-1)>>1; castlingRights[0][3] = initialRights[3] = BOARD_RGHT-1; castlingRights[0][4] = initialRights[4] = BOARD_LEFT; - castlingRights[0][5] = initialRights[5] = BOARD_WIDTH-1>>1; + castlingRights[0][5] = initialRights[5] =(BOARD_WIDTH-1)>>1; break; case VariantFalcon: pieces = FalconArray; @@ -5442,7 +5449,7 @@ if(appData.debugMode) fprintf(debugFP, "moveType 2 = %d, promochar = %x\n", move if(bookHit) { // [HGM] book: simulate book reply static char bookMove[MSG_SIZ]; // a bit generous? - programStats.depth = programStats.nodes = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; sprintf(programStats.movelist, "%s (xbook)", bookHit); @@ -5475,7 +5482,7 @@ if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", move void SendProgramStatsToFrontend( ChessProgramState * cps, ChessProgramStats * cpstats ) { - char * hint = lastHint; +// char * hint = lastHint; FrontEndProgramStats stats; stats.which = cps == &first ? 0 : 1; @@ -5669,8 +5676,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h sprintf(buf1, _("Illegal move \"%s\" from %s machine"), machineMove, cps->which); DisplayError(buf1, 0); - sprintf(buf1, "Xboard: Forfeit due to invalid move: %s (%c%c%c%c) res=%d%c", - machineMove, fromX+AAA, fromY+ONE, toX+AAA, toY+ONE, 0); + sprintf(buf1, "Xboard: Forfeit due to invalid move: %s (%c%c%c%c) res=%d", + machineMove, fromX+AAA, fromY+ONE, toX+AAA, toY+ONE, moveType); if (gameMode == TwoMachinesPlay) { GameEnds(machineWhite ? BlackWins : WhiteWins, buf1, GE_XBOARD); @@ -5715,6 +5722,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h toX--; currentMoveString[2]--; break; + default: ; // nothing to do, but suppresses warning of pedantic compilers } } hintRequested = FALSE; @@ -5737,8 +5745,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h programStats.depth, programStats.score / 100., programStats.time / 100., - (double) programStats.nodes, - programStats.nodes / (10*abs(programStats.time) + 1.), + u64ToDouble(programStats.nodes), + u64ToDouble(programStats.nodes) / (10*abs(programStats.time) + 1.), programStats.movelist); SendToICS(buf); } @@ -5827,7 +5835,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h { /* [HGM] Some more adjudications for obstinate engines */ int NrWN=0, NrBN=0, NrWB=0, NrBB=0, NrWR=0, NrBR=0, NrWQ=0, NrBQ=0, NrW=0, bishopsColor = 0, - NrPieces=0, NrPawns=0, PawnAdvance=0, i, j, k; + NrPieces=0, NrPawns=0, PawnAdvance=0, i, j; static int moveCount = 6; /* First absolutely insufficient mating material. Count what is on board. */ @@ -6126,7 +6134,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h strcat(bookMove, bookHit); message = bookMove; cps = cps->other; - programStats.depth = programStats.nodes = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; sprintf(programStats.movelist, "%s (xbook)", bookHit); @@ -6660,8 +6668,8 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if(cps->nps >= 0) { /* [HGM] nps: use engine nodes or time to decrement clock */ int ticklen; - if(cps->nps == 0) ticklen = 10*time; // use engine reported time - else ticklen = (1000. * nodes) / cps->nps; // convert node count to time + if(cps->nps == 0) ticklen = 10*time; // use engine reported time + else ticklen = (1000. * u64ToDouble(nodes)) / cps->nps; // convert node count to time if(WhiteOnMove(forwardMostMove)) whiteTimeRemaining = timeRemaining[0][forwardMostMove] - ticklen; else blackTimeRemaining = timeRemaining[1][forwardMostMove] - ticklen; @@ -6820,7 +6828,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h else { buf1[0] = NULLCHAR; - if (sscanf(message, "%d%c %d %d %lu %[^\n]\n", + if (sscanf(message, "%d%c %d %d " u64Display " %[^\n]\n", &plylev, &plyext, &curscore, &time, &nodes, buf1) >= 5) { ChessProgramStats cpstats; @@ -7065,7 +7073,7 @@ ApplyMove(fromX, fromY, toX, toY, promoChar, board) /* [HGM] compute & store e.p. status and castling rights for new position */ /* if we are updating a board for which those exist (i.e. in boards[]) */ if((p = ((int)board - (int)boards[0])/((int)boards[1]-(int)boards[0])) < MAX_MOVES && p > 0) - { int i, j; + { int i; if(gameInfo.variant == VariantBerolina) berolina = EP_BEROLIN_A; oldEP = epStatus[p-1]; @@ -9516,7 +9524,7 @@ SaveGamePGN(f) { int i, offset, linelen, newblock; time_t tm; - char *movetext; +// char *movetext; char numtext[32]; int movelen, numlen, blank; char move_buffer[100]; /* [AS] Buffer for move+PV info */ @@ -9625,12 +9633,6 @@ SaveGamePGN(f) #else seconds = (pvInfoList[i].time + 5)/10; // [HGM] PVtime: use engine time #endif - if (appData.debugMode,0) { - fprintf(debugFP, "times = %d %d %d %d, seconds=%d\n", - timeRemaining[0][i+1], timeRemaining[0][i], - timeRemaining[1][i+1], timeRemaining[1][i], seconds - ); - } if( seconds <= 0) buf[0] = 0; else if( seconds < 30 ) sprintf(buf, " %3.1f%c", seconds/10., 0); else { @@ -10443,7 +10445,7 @@ MachineWhiteEvent() if(bookHit) { // [HGM] book: simulate book reply static char bookMove[MSG_SIZ]; // a bit generous? - programStats.depth = programStats.nodes = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; sprintf(programStats.movelist, "%s (xbook)", bookHit); @@ -10518,7 +10520,7 @@ MachineBlackEvent() if(bookHit) { // [HGM] book: simulate book reply static char bookMove[MSG_SIZ]; // a bit generous? - programStats.depth = programStats.nodes = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; sprintf(programStats.movelist, "%s (xbook)", bookHit); @@ -10664,7 +10666,7 @@ TwoMachinesEvent P((void)) if(bookHit) { // [HGM] book: simulate book reply static char bookMove[MSG_SIZ]; // a bit generous? - programStats.depth = programStats.nodes = programStats.time = + programStats.nodes = programStats.depth = programStats.time = programStats.score = programStats.got_only_move = 0; sprintf(programStats.movelist, "%s (xbook)", bookHit); @@ -12921,7 +12923,7 @@ GetTimeMark(tm) #else /*!HAVE_GETTIMEOFDAY*/ #if HAVE_FTIME -#include +// include / moved to just above start of function struct timeb timeB; ftime(&timeB); diff --git a/backend.h b/backend.h index 7fb98da..c819520 100644 --- a/backend.h +++ b/backend.h @@ -361,7 +361,7 @@ typedef struct { } ChessProgramStats; extern ChessProgramStats_Move pvInfoList[MAX_MOVES]; -extern shuffleOpenings; +extern int shuffleOpenings; extern ChessProgramStats programStats; #endif /* _BACKEND */ diff --git a/book.c b/book.c index 82d4a45..124344f 100644 --- a/book.c +++ b/book.c @@ -30,6 +30,8 @@ #include #include +#include +#include #include "common.h" #include "backend.h" @@ -273,8 +275,7 @@ uint64 *RandomTurn =Random64+780; uint64 hash(int moveNr) { - char c; - int p, r, f, i, p_enc, squareNr, pieceGroup; + int r, f, p_enc, squareNr, pieceGroup; uint64 key=0, Zobrist; for(f=BOARD_LEFT; frt && ft == cl->ft) cl->recaptures++; // count legal recaptures to this square - if(appData.debugMode && board[rt][ft] != EmptySquare) - fprintf(debugFP, "try %c%c%c%c=%d\n", ff+AAA, rf+ONE,ft+AAA, rt+ONE, cl->recaptures); + register ChaseClosure *cl = (ChaseClosure *) closure; // closure tells us where to recapture + + if(rt == cl->rt && ft == cl->ft) cl->recaptures++; // count legal recaptures to this square + if(appData.debugMode && board[rt][ft] != EmptySquare) + fprintf(debugFP, "try %c%c%c%c=%d\n", ff+AAA, rf+ONE,ft+AAA, rt+ONE, cl->recaptures); } extern char moveList[MAX_MOVES][MOVE_LEN]; @@ -1749,7 +1750,7 @@ int PerpetualChase(int first, int last) cl.recaptures = 0; // prepare closure to pass recapture square and count moves to it cl.rt = chaseStack[j].rt; cl.ft = chaseStack[j].ft; - if(appData.debugMode) { int n; + if(appData.debugMode) { fprintf(debugFP, "test if we can recapture %c%c\n", cl.ft+AAA, cl.rt+ONE); } GenLegal(boards[i+1], PosFlags(i+1), EP_NONE, initialRights, ProtectedCallback, &cl); // try all moves diff --git a/winboard/parser.c b/winboard/parser.c index ff36db3..ad2369e 100644 --- a/winboard/parser.c +++ b/winboard/parser.c @@ -9,7 +9,6 @@ #define YY_FLEX_MINOR_VERSION 5 #include -#include /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ #ifdef c_plusplus @@ -22,9 +21,7 @@ #ifdef __cplusplus #include -#ifndef _WIN32 #include -#endif /* Use prototypes in function declarations. */ #define YY_USE_PROTOS @@ -64,7 +61,6 @@ #define YY_PROTO(proto) () #endif - /* Returned upon end-of-file. */ #define YY_NULL 0 @@ -1974,20 +1970,9 @@ YY_MALLOC_DECL YY_FATAL_ERROR( "input in flex scanner failed" ); \ result = n; \ } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(yyin); \ - } \ - } + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); #endif /* No semi-colon after return; correct usage is to write "yyterminate();" - @@ -3549,15 +3534,11 @@ YY_BUFFER_STATE b; } -#ifndef _WIN32 -#include -#else #ifndef YY_ALWAYS_INTERACTIVE #ifndef YY_NEVER_INTERACTIVE extern int isatty YY_PROTO(( int )); #endif #endif -#endif #ifdef YY_USE_PROTOS void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) diff --git a/winboard/wclipbrd.c b/winboard/wclipbrd.c index c0941e0..838d250 100644 --- a/winboard/wclipbrd.c +++ b/winboard/wclipbrd.c @@ -198,7 +198,7 @@ CopyTextToClipboard(char *text) locked = !((err == NO_ERROR) || (err == ERROR_NOT_LOCKED)); if (appData.debugMode) { fprintf(debugFP, - "CopyTextToClipboard(): err %d locked %d\n", err, locked); + "CopyTextToClipboard(): err %d locked %d\n", (int)err, locked); } } if (locked) { @@ -368,7 +368,7 @@ PasteTextFromClipboard(char **text) locked = !((err == NO_ERROR) || (err == ERROR_NOT_LOCKED)); if (appData.debugMode) { fprintf(debugFP, - "PasteTextFromClipboard(): err %d locked %d\n", err, locked); + "PasteTextFromClipboard(): err %d locked %d\n", (int)err, locked); } } if (locked) diff --git a/winboard/wedittags.c b/winboard/wedittags.c index da86de3..19f1bd4 100644 --- a/winboard/wedittags.c +++ b/winboard/wedittags.c @@ -37,6 +37,7 @@ #include "winboard.h" #include "frontend.h" #include "backend.h" +#include "wedittags.h" /* Module globals */ static char *editTagsText; diff --git a/winboard/wengineo.c b/winboard/wengineo.c index a2d77ed..ff7b3b1 100644 --- a/winboard/wengineo.c +++ b/winboard/wengineo.c @@ -119,9 +119,9 @@ typedef struct { int an_move_count; } EngineOutputData; -static VerifyDisplayMode(); +static void VerifyDisplayMode(); static void UpdateControls( EngineOutputData * ed ); -static SetEngineState( int which, int state, char * state_data ); +static void SetEngineState( int which, int state, char * state_data ); // front end static HICON LoadIconEx( int id ) @@ -248,9 +248,9 @@ static void ResizeWindowControls( HWND hDlg, int mode ) { RECT rc; int headerHeight = GetHeaderHeight(); - int labelHeight = GetControlHeight( hDlg, IDC_EngineLabel1 ); - int labelOffset = H_MARGIN + ICON_SIZE + H_MARGIN; - int labelDeltaY = ICON_SIZE - labelHeight; +// int labelHeight = GetControlHeight( hDlg, IDC_EngineLabel1 ); +// int labelOffset = H_MARGIN + ICON_SIZE + H_MARGIN; +// int labelDeltaY = ICON_SIZE - labelHeight; int clientWidth; int clientHeight; int maxControlWidth; @@ -448,7 +448,7 @@ void DoClearMemo(int which) // back end, due to front-end wrapper for SetWindowText, and new SetIcon arguments -static SetEngineState( int which, int state, char * state_data ) +static void SetEngineState( int which, int state, char * state_data ) { int x_which = 1 - which; @@ -581,6 +581,7 @@ char GetEngineColor( int which ) result = cps->twoMachinesColor[0]; result = result == 'w' ? ENGINE_COLOR_WHITE : ENGINE_COLOR_BLACK; break; + default: ; // does not happen, but suppresses pedantic warnings } } @@ -618,6 +619,7 @@ static int IsEnginePondering( int which ) if( GetEngineColor( which ) != GetActiveEngineColor() ) result = TRUE; } break; + default: ; // does not happen, but suppresses pedantic warnings } return result; @@ -634,7 +636,7 @@ static void SetDisplayMode( int mode ) } // pure back end -static VerifyDisplayMode() +static void VerifyDisplayMode() { int mode; @@ -684,7 +686,7 @@ static void SetEngineColorIcon( int which ) // pure back end, now SetWindowText is called via wrapper DoSetWindowText static void UpdateControls( EngineOutputData * ed ) { - int isPondering = FALSE; +// int isPondering = FALSE; char s_label[MAX_NAME_LENGTH + 32]; @@ -727,7 +729,7 @@ static void UpdateControls( EngineOutputData * ed ) SetEngineState( ed->which, STATE_THINKING, "" ); } else if( gameMode == AnalyzeMode || gameMode == AnalyzeFile - || gameMode == IcsObserving && appData.icsEngineAnalyze) { // [HGM] ICS-analyze + || (gameMode == IcsObserving && appData.icsEngineAnalyze)) { // [HGM] ICS-analyze char buf[64]; int time_secs = ed->time / 100; int time_mins = time_secs / 60; diff --git a/winboard/wevalgraph.c b/winboard/wevalgraph.c index 55c3ec2..3e57bb9 100644 --- a/winboard/wevalgraph.c +++ b/winboard/wevalgraph.c @@ -152,9 +152,7 @@ static VOID DrawAxisSegmentHoriz( int value, BOOL drawValue ) sprintf(b, "%d", value); cbBuf = strlen( buf ); - GetTextExtentPoint32( hdcPB, buf, cbBuf, &stSize ); - TextOut( hdcPB, MarginX - stSize.cx - 2, y - stSize.cy / 2, buf, cbBuf ); } } diff --git a/winboard/wgamelist.c b/winboard/wgamelist.c index ee9759b..1c8a15d 100644 --- a/winboard/wgamelist.c +++ b/winboard/wgamelist.c @@ -39,6 +39,7 @@ #include "backend.h" #include "wsnap.h" +#include "wgamelist.h" /* Module globals */ HWND gameListDialog = NULL; diff --git a/winboard/winboard.c b/winboard/winboard.c index a00473e..bdfc1f3 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -70,6 +70,7 @@ #include #include #include +#include #if __GNUC__ #include @@ -99,6 +100,9 @@ extern int whiteFlag, blackFlag; Boolean flipClock = FALSE; void DisplayHoldingsCount(HDC hdc, int x, int y, int align, int copyNumber); +VOID NewVariantPopup(HWND hwnd); +int FinishMove P((ChessMove moveType, int fromX, int fromY, int toX, int toY, + /*char*/int promoChar)); typedef struct { ChessSquare piece; @@ -177,7 +181,7 @@ static HWND hwndPause; /* pause button */ static HBITMAP pieceBitmap[3][(int) BlackPawn]; /* [HGM] nr of bitmaps referred to bP in stead of wK */ static HBRUSH lightSquareBrush, darkSquareBrush, blackSquareBrush, /* [HGM] for band between board and holdings */ - whitePieceBrush, blackPieceBrush, iconBkgndBrush, outlineBrush; + whitePieceBrush, blackPieceBrush, iconBkgndBrush /*, outlineBrush*/; static POINT gridEndpoints[(BOARD_SIZE + 1) * 4]; static DWORD gridVertexCounts[(BOARD_SIZE + 1) * 2]; static HPEN gridPen = NULL; @@ -247,7 +251,7 @@ SizeInfo sizeInfo[] = { NULL, 0, 0, 0, 0, 0, 0 } }; -#define MF(x) {x, {0, }, {0, }, 0} +#define MF(x) {x, {{0,}, 0. }, {0, }, 0} MyFont fontRec[NUM_SIZES][NUM_FONTS] = { { MF(CLOCK_FONT_TINY), MF(MESSAGE_FONT_TINY), MF(COORD_FONT_TINY), MF(CONSOLE_FONT_TINY), MF(COMMENT_FONT_TINY), MF(EDITTAGS_FONT_TINY), MF(MOVEHISTORY_FONT_ALL) }, @@ -478,6 +482,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, { MSG msg; HANDLE hAccelMain, hAccelNoAlt, hAccelNoICS; +// INITCOMMONCONTROLSEX ex; debugFP = stderr; @@ -490,6 +495,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, if (!InitInstance(hInstance, nCmdShow, lpCmdLine)) { return (FALSE); } +// InitCommonControlsEx(&ex); + InitCommonControls(); hAccelMain = LoadAccelerators (hInstance, szAppName); hAccelNoAlt = LoadAccelerators (hInstance, "NO_ALT"); @@ -1407,6 +1414,7 @@ FileGet(void *getClosure) FILE* f = (FILE*) getClosure; c = getc(f); + if (c == '\r') c = getc(f); // work around DOS format files by bypassing the '\r' completely if (c == EOF) return NULLCHAR; else @@ -1862,12 +1870,6 @@ InitAppData(LPSTR lpCmdLine) dcb.fNull = FALSE; dcb.fRtsControl = RTS_CONTROL_ENABLE; dcb.fAbortOnError = FALSE; - /* Microsoft SDK >= Feb. 2003 (MS VS >= 2002) */ - #if (defined(_MSC_VER) && _MSC_VER <= 1200) - //dcb.wReserved = 0; - #else - dcb.wReserved = 0; - #endif dcb.ByteSize = 7; dcb.Parity = SPACEPARITY; dcb.StopBits = ONESTOPBIT; @@ -2286,14 +2288,14 @@ SaveSettings(char* name) case ArgColor: { COLORREF color = *(COLORREF *)ad->argLoc; - fprintf(f, "/%s=#%02x%02x%02x\n", ad->argName, + fprintf(f, "/%s=#%02lx%02lx%02lx\n", ad->argName, color&0xff, (color>>8)&0xff, (color>>16)&0xff); } break; case ArgAttribs: { MyTextAttribs* ta = &textAttribs[(ColorClass)ad->argLoc]; - fprintf(f, "/%s=\"%s%s%s%s%s#%02x%02x%02x\"\n", ad->argName, + fprintf(f, "/%s=\"%s%s%s%s%s#%02lx%02lx%02lx\"\n", ad->argName, (ta->effects & CFE_BOLD) ? "b" : "", (ta->effects & CFE_ITALIC) ? "i" : "", (ta->effects & CFE_UNDERLINE) ? "u" : "", @@ -2331,6 +2333,8 @@ SaveSettings(char* name) break; case ArgCommSettings: PrintCommSettings(f, ad->argName, (DCB *)ad->argLoc); + case ArgNone: + case ArgSettingsFilename: ; } } fclose(f); @@ -3258,7 +3262,6 @@ InitDrawingSizes(BoardSize boardSize, int flags) boardRect.top + lineGap / 2 + (i * (squareSize + lineGap)); gridEndpoints[i*2 + 1].x = boardRect.left + lineGap / 2 + BOARD_WIDTH * (squareSize + lineGap); - lineGap / 2 + (i * (squareSize + lineGap)); gridVertexCounts[i*2] = gridVertexCounts[i*2 + 1] = 2; } for (i = 0; i < BOARD_WIDTH + 1; i++) { @@ -3678,8 +3681,8 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, } else { tmpSize = squareSize; if(minorSize && - (piece >= (int)WhiteNightrider && piece <= WhiteGrasshopper || - piece >= (int)BlackNightrider && piece <= BlackGrasshopper) ) { + ((piece >= (int)WhiteNightrider && piece <= WhiteGrasshopper) || + (piece >= (int)BlackNightrider && piece <= BlackGrasshopper)) ) { /* [HGM] no bitmap available for promoted pieces in Crazyhouse */ /* Bitmaps of smaller size are substituted, but we have to align them */ x += (squareSize - minorSize)>>1; @@ -4215,9 +4218,9 @@ void fputDW(FILE *f, int x) VOID DrawLogoOnDC(HDC hdc, RECT logoRect, ChessProgramState *cps) { - HBITMAP bufferBitmap; +// HBITMAP bufferBitmap; BITMAP bi; - RECT Rect; +// RECT Rect; HDC tmphdc; HBITMAP hbm; int w = 100, h = 50; @@ -4556,7 +4559,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) boardRect.bottom - boardRect.top, tmphdc, boardRect.left, boardRect.top, SRCCOPY); if(saveDiagFlag) { - BITMAP b; int i, j, m, w, wb, fac=0; char pData[1000000]; + BITMAP b; int i, j=0, m, w, wb, fac=0; char pData[1000000]; BITMAPINFOHEADER bih; int color[16], nrColors=0; GetObject(bufferBitmap, sizeof(b), &b); @@ -4600,7 +4603,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) while(p&3) pData[p++] = 0; } fac = 3; - wb = (wb+31>>5)<<2; + wb = ((wb+31)>>5)<<2; } // write BITMAPFILEHEADER fprintf(diagFile, "BM"); @@ -4660,9 +4663,6 @@ int SaveDiagram(f) FILE *f; { - time_t tm; - char *fen; - saveDiagFlag = 1; diagFile = f; HDCDrawPosition(NULL, TRUE, NULL); @@ -4687,7 +4687,7 @@ PaintProc(HWND hwnd) PAINTSTRUCT ps; HFONT oldFont; - if(hdc = BeginPaint(hwnd, &ps)) { + if((hdc = BeginPaint(hwnd, &ps))) { if (IsIconic(hwnd)) { DrawIcon(hdc, 2, 2, iconCurrent); } else { @@ -4780,7 +4780,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) POINT pt; static int recursive = 0; HMENU hmenu; - BOOLEAN needsRedraw = FALSE; +// BOOLEAN needsRedraw = FALSE; BOOLEAN saveAnimate; BOOLEAN forceFullRepaint = IsFullRepaintPreferrable(); /* [AS] */ static BOOLEAN sameAgain = FALSE, promotionChoice = FALSE; @@ -4855,7 +4855,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } if (!appData.highlightLastMove) { ClearHighlights(); - DrawPosition(forceFullRepaint || FALSE, NULL); + DrawPosition((int) (forceFullRepaint || FALSE), NULL); } fromX = fromY = -1; dragInfo.start.x = dragInfo.start.y = -1; @@ -4864,8 +4864,8 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } else if (x < 0 || y < 0 /* [HGM] block clicks between board and holdings */ || x == BOARD_LEFT-1 || x == BOARD_RGHT - || x == BOARD_LEFT-2 && y < BOARD_HEIGHT-gameInfo.holdingsSize - || x == BOARD_RGHT+1 && y >= gameInfo.holdingsSize + || (x == BOARD_LEFT-2 && y < BOARD_HEIGHT-gameInfo.holdingsSize) + || (x == BOARD_RGHT+1 && y >= gameInfo.holdingsSize) /* EditPosition, empty square, or different color piece; click-click move is possible */ ) { @@ -4895,8 +4895,8 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if(moveType != ImpossibleMove) { /* [HGM] We use PromotionToKnight in Shogi to indicate frorced promotion */ if (moveType == WhitePromotionKnight || moveType == BlackPromotionKnight || - (moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && - appData.alwaysPromoteToQueen) { + ((moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && + appData.alwaysPromoteToQueen)) { FinishMove(moveType, fromX, fromY, toX, toY, 'q'); if (!appData.highlightLastMove) { ClearHighlights(); @@ -5001,8 +5001,8 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* [HGM] use move type to determine if move is promotion. Knight is Shogi kludge for mandatory promotion, Queen means choice */ if (moveType == WhitePromotionKnight || moveType == BlackPromotionKnight || - (moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && - appData.alwaysPromoteToQueen) + ((moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && + appData.alwaysPromoteToQueen)) FinishMove(moveType, fromX, fromY, toX, toY, 'q'); else if (moveType == WhitePromotionQueen || moveType == BlackPromotionQueen ) { @@ -5066,12 +5066,12 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) * Play moves forward */ if((short)HIWORD(wParam) > 0 && currentMove < forwardMostMove) - if(lastDir == 1) ForwardEvent(); else lastDir = 1; // [HGM] suppress first event in each direction + { if(lastDir == 1) ForwardEvent(); else lastDir = 1; } // [HGM] suppress first event in direction /* Mouse Wheel is being rolled backward * Play moves backward */ if((short)HIWORD(wParam) < 0 && currentMove > backwardMostMove) - if(lastDir == -1) BackwardEvent(); else lastDir = -1; + { if(lastDir == -1) BackwardEvent(); else lastDir = -1; } } break; @@ -5229,16 +5229,16 @@ Promotion(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SW_SHOW : SW_HIDE); /* [HGM] Only allow C & A promotions if these pieces are defined */ ShowWindow(GetDlgItem(hDlg, PB_Archbishop), - (PieceToChar(WhiteAngel) >= 'A' && - PieceToChar(WhiteAngel) != '~' || - PieceToChar(BlackAngel) >= 'A' && - PieceToChar(BlackAngel) != '~' ) ? + ((PieceToChar(WhiteAngel) >= 'A' && + PieceToChar(WhiteAngel) != '~') || + (PieceToChar(BlackAngel) >= 'A' && + PieceToChar(BlackAngel) != '~') ) ? SW_SHOW : SW_HIDE); ShowWindow(GetDlgItem(hDlg, PB_Chancellor), - (PieceToChar(WhiteMarshall) >= 'A' && - PieceToChar(WhiteMarshall) != '~' || - PieceToChar(BlackMarshall) >= 'A' && - PieceToChar(BlackMarshall) != '~' ) ? + ((PieceToChar(WhiteMarshall) >= 'A' && + PieceToChar(WhiteMarshall) != '~') || + (PieceToChar(BlackMarshall) >= 'A' && + PieceToChar(BlackMarshall) != '~') ) ? SW_SHOW : SW_HIDE); /* [HGM] Hide B & R button in Shogi, use Q as promote, N as defer */ ShowWindow(GetDlgItem(hDlg, PB_Rook), @@ -6788,7 +6788,7 @@ SetStartupDialogEnables(HWND hDlg) { EnableWindow(GetDlgItem(hDlg, OPT_ChessEngineName), IsDlgButtonChecked(hDlg, OPT_ChessEngine) || - appData.zippyPlay && IsDlgButtonChecked(hDlg, OPT_ChessServer)); + (appData.zippyPlay && IsDlgButtonChecked(hDlg, OPT_ChessServer))); EnableWindow(GetDlgItem(hDlg, OPT_SecondChessEngineName), IsDlgButtonChecked(hDlg, OPT_ChessEngine)); EnableWindow(GetDlgItem(hDlg, OPT_ChessServerName), @@ -7414,8 +7414,6 @@ VOID GothicPopUp(char *title, VariantClass variant) { FARPROC lpProc; - char *p, *q; - BOOLEAN modal = hwndMain == NULL; static char *lastTitle; strncpy(errorTitle, title, sizeof(errorTitle)); @@ -7496,7 +7494,7 @@ IcsTextMenuEntry icsTextMenuEntry[ICS_TEXT_MENU_SIZE]; void ParseIcsTextMenu(char *icsTextMenuString) { - int flags = 0; +// int flags = 0; IcsTextMenuEntry *e = icsTextMenuEntry; char *p = icsTextMenuString; while (e->item != NULL && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) { @@ -7939,8 +7937,8 @@ LRESULT CALLBACK ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static SnapData sd; - static HWND hText, hInput, hFocus; - InputSource *is = consoleInputSource; + static HWND hText, hInput /*, hFocus*/; +// InputSource *is = consoleInputSource; RECT rect; static int sizeX, sizeY; int newSizeX, newSizeY; @@ -8305,7 +8303,7 @@ void CheckForInputBufferFull( InputSource * is ) if( p >= is->next ) { if (appData.debugMode) { - fprintf( debugFP, "Input line exceeded buffer size (source id=%u)\n", is->id ); + fprintf( debugFP, "Input line exceeded buffer size (source id=%lu)\n", is->id ); } is->error = ERROR_BROKEN_PIPE; /* [AS] Just any non-successful code! */ @@ -8354,7 +8352,7 @@ InputThread(LPVOID arg) CloseHandle(is->hFile); if (appData.debugMode) { - fprintf( debugFP, "Input thread terminated (id=%u, error=%d, count=%d)\n", is->id, is->error, is->count ); + fprintf( debugFP, "Input thread terminated (id=%lu, error=%d, count=%ld)\n", is->id, is->error, is->count ); } return 0; @@ -9236,7 +9234,7 @@ LRESULT CALLBACK GameListOptions_Proc(HWND hDlg, UINT message, WPARAM wParam, LP { char * pc = lpUserGLT; int idx = 0; - int cnt = (int) SendDlgItemMessage( hDlg, IDC_GameListTags, LB_GETCOUNT, 0, 0 ); +// int cnt = (int) SendDlgItemMessage( hDlg, IDC_GameListTags, LB_GETCOUNT, 0, 0 ); char id; do { @@ -9787,7 +9785,7 @@ DestroyChildProcess(ProcRef pr, int/*boolean*/ signal) result = TerminateProcess( cp->hProcess, 0 ); if ( appData.debugMode) { - fprintf( debugFP, "Terminating process %u, result=%d\n", cp->pid, result ); + fprintf( debugFP, "Terminating process %lu, result=%d\n", cp->pid, result ); } } else if( signal == 10 ) { @@ -9797,7 +9795,7 @@ DestroyChildProcess(ProcRef pr, int/*boolean*/ signal) result = TerminateProcess( cp->hProcess, 0 ); if ( appData.debugMode) { - fprintf( debugFP, "Process %u still alive after timeout, killing... result=%d\n", cp->pid, result ); + fprintf( debugFP, "Process %lu still alive after timeout, killing... result=%d\n", cp->pid, result ); } } @@ -10701,4 +10699,3 @@ void SetProgramStats( FrontEndProgramStats * stats ) EngineOutputUpdate( stats ); } -/// \ No newline at end of file diff --git a/winboard/winboard.rc b/winboard/winboard.rc index 588c9a4..59c0e9e 100644 --- a/winboard/winboard.rc +++ b/winboard/winboard.rc @@ -33,12 +33,12 @@ MANIFEST_RESOURCE_ID 24 MOVEABLE PURE "res\\winboard.exe.manifest" // Dialog // -ABOUTBOX DIALOG DISCARDABLE 22, 17, 180, 108 +ABOUTBOX DIALOG DISCARDABLE 22, 17, 180, 88 STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "About WinBoard" FONT 8, "MS Sans Serif" BEGIN - DEFPUSHBUTTON "OK",IDOK,126,89,50,14,WS_GROUP + DEFPUSHBUTTON "OK",IDOK,126,69,50,14,WS_GROUP ICON "icon_white",IDC_STATIC,3,6,20,20 LTEXT "Chessboard for Windows",400,25,15,121,8 LTEXT "Copyright 1991 Digital Equipment Corporation",201,6,34, @@ -49,9 +49,6 @@ BEGIN LTEXT "WinBoard 0.0.0",ABOUTBOX_Version,25,5,61,8 LTEXT "Enhancements Copyright 2005\r\nAlessandro Scotti", IDC_STATIC,6,65,120,24 - LTEXT "Enhancements Copyright 2007\r\nH.G. Muller", - IDC_STATIC,6,85,120,24 - LTEXT "(""WinBoard_F"")",IDC_STATIC,88,4,71,8 END DLG_TimeControl DIALOG DISCARDABLE 6, 18, 174, 134 diff --git a/winboard/woptions.c b/winboard/woptions.c index d685200..b1f50b6 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -28,6 +28,7 @@ #include #include #include /* [AS] Requires NT 4.0 or Win95 */ +#include #include "common.h" #include "winboard.h" @@ -66,7 +67,7 @@ extern char installDir[]; extern HWND hCommPort; /* currently open comm port */ extern DCB dcb; extern BOOLEAN chessProgram; -extern startedFromPositionFile; /* [HGM] loadPos */ +extern int startedFromPositionFile; /* [HGM] loadPos */ /* types */ @@ -127,6 +128,7 @@ void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value); VOID SetLoadOptionEnables(HWND hDlg); VOID SetSaveOptionEnables(HWND hDlg); VOID SetTimeControlEnables(HWND hDlg); +void NewSettingEvent(int option, char *command, int value); /*---------------------------------------------------------------------------*\ * @@ -311,7 +313,7 @@ PaintSampleSquare( HBRUSH brushSquareOutline; HBRUSH brushPiece; HBRUSH brushPieceDetail; - HBRUSH oldBrushPiece; + HBRUSH oldBrushPiece = NULL; HBRUSH oldBrushSquare; HBITMAP oldBitmapMem; HBITMAP oldBitmapTemp; @@ -567,6 +569,7 @@ BoardOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) break; case SizeTitanic: CheckDlgButton(hDlg, OPT_SizeTitanic, TRUE); + default: ; // should not happen, but suppresses warning on pedantic compilers } if (appData.monoMode) @@ -796,10 +799,7 @@ VariantWhichRadio(HWND hDlg) LRESULT CALLBACK NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static Boolean mono; static VariantClass v; - static COLORREF lsc, dsc, wpc, bpc, hsc, phc; - static HBITMAP pieces[3]; static int n1_ok, n2_ok, n3_ok; switch (message) { @@ -881,6 +881,10 @@ NewVariantDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case VariantNoCastle: CheckDlgButton(hDlg, OPT_VariantNocastle, TRUE); break; +// case VariantGreat: // Note to self: must still make this button (and GiveAway too). +// CheckDlgButton(hDlg, OPT_VariantGreat, TRUE); +// break; + default: ; } SetDlgItemInt( hDlg, IDC_Files, -1, TRUE ); @@ -1771,7 +1775,7 @@ InitSoundCombo(HWND hwndCombo, SoundComboData *scd) err = SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) scd->label); if (err != cnt++) { sprintf(buf, "InitSoundCombo(): err '%d', cnt '%d'\n", - err, cnt); + (int)err, (int)cnt); MessageBox(NULL, buf, NULL, MB_OK); } scd++; @@ -2166,7 +2170,7 @@ VOID PrintCommSettings(FILE *f, char *name, DCB *dcb) flow = cdFlow[FLOW_NONE].label; } fprintf(f, "/%s=%d,%d,%s,%s,%s\n", name, - dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow); + (int)dcb->BaudRate, dcb->ByteSize, parity, stopBits, flow); } @@ -2228,7 +2232,7 @@ CommPortOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) hwndCombo = GetDlgItem(hDlg, OPT_DataRate); InitCombo(hwndCombo, cdDataRate); - sprintf(buf, "%u", dcb.BaudRate); + sprintf(buf, "%u", (int)dcb.BaudRate); if (SendMessage(hwndCombo, CB_SELECTSTRING, (WPARAM) -1, (LPARAM) buf) == CB_ERR) { SendMessage(hwndCombo, CB_SETCURSEL, (WPARAM) -1, (LPARAM) 0); SendMessage(hwndCombo, WM_SETTEXT, (WPARAM) 0, (LPARAM) buf); diff --git a/xboard.c b/xboard.c index ed688da..a292a9f 100644 --- a/xboard.c +++ b/xboard.c @@ -9184,7 +9184,7 @@ DragPieceBegin(x, y) boardX == BOARD_LEFT-2 && PieceForSquare(boardX+1, boardY) > 1) XCopyArea(xDisplay, xBoardWindow, player.saveBuf, player.blitGC, corner.x, corner.y, squareSize, squareSize, - 0, 0); // [HGM] xh: unstack in stead of grab + 0, 0); // [HGM] zh: unstack in stead of grab damage[boardY][boardX] = True; } else { player.dragActive = False; diff --git a/zippy.c b/zippy.c index 6d61ff7..8114437 100644 --- a/zippy.c +++ b/zippy.c @@ -92,6 +92,7 @@ extern char *getenv(); #include "backendz.h" char *SendMoveToBookUser P((int nr, ChessProgramState *cps, int initial)); // [HGM] book +void HandleMachineMove P((char *message, ChessProgramState *cps)); static char zippyPartner[MSG_SIZ]; static char zippyLastOpp[MSG_SIZ]; @@ -803,7 +804,7 @@ void ZippyHandleChallenge(srated, swild, sbase, sincrement, opponent) return; } if (StrStr(appData.zippyVariants, varname) == NULL || - (i=first.protocolVersion) != 1 && StrStr(first.variants, varname) == NULL /* [HGM] zippyvar */ + ((i=first.protocolVersion) != 1 && StrStr(first.variants, varname) == NULL) /* [HGM] zippyvar */ ) { sprintf(buf, "%stell %s This computer can't play %s [%s], only %s\n%sdecline %s\n",