From 040542c239a2fbfe9c8720ca7cae065d3773bc1f Mon Sep 17 00:00:00 2001 From: Arun Persaud Date: Sat, 1 Aug 2009 16:39:05 -0700 Subject: [PATCH] removed all my printf's for debugging guess a normal debugger is more useful ;) --- backend.c | 89 ++++++++++++++++------------------------------------------- callback.c | 13 -------- interface.c | 3 +- xboard.c | 49 +------------------------------- 4 files changed, 27 insertions(+), 127 deletions(-) diff --git a/backend.c b/backend.c index 6891eb1..d07d1ed 100644 --- a/backend.c +++ b/backend.c @@ -1076,39 +1076,30 @@ ParseTimeControl(tc, ti, mps) void InitBackEnd2() { - printf ("DEBUG: in init backend 2\n"); - - if (appData.debugMode) { - fprintf(debugFP, "%s\n", programVersion); - } - - if (appData.matchGames > 0) { - appData.matchMode = TRUE; - } else if (appData.matchMode) { - appData.matchGames = 1; - } - if(appData.matchMode && appData.sameColorGames > 0) /* [HGM] alternate: overrule matchGames */ - appData.matchGames = appData.sameColorGames; - if(appData.rewindIndex > 1) { /* [HGM] autoinc: rewind implies auto-increment and overrules given index */ - if(appData.loadPositionIndex >= 0) appData.loadPositionIndex = -1; - if(appData.loadGameIndex >= 0) appData.loadGameIndex = -1; - } - printf ("DEBUG: before reset\n"); - Reset(TRUE, FALSE); - printf ("DEBUG: after reset\n"); - if (appData.noChessProgram || first.protocolVersion == 1) { - printf ("DEBUG: first if\n"); - InitBackEnd3(); - } else { - printf ("DEBUG: second if 0\n"); - /* kludge: allow timeout for initial "feature" commands */ - FreezeUI(); - printf ("DEBUG: second if 1\n"); - DisplayMessage("", _("Starting chess program")); - printf ("DEBUG: second if 2\n"); - ScheduleDelayedEvent(InitBackEnd3, FEATURE_TIMEOUT); - printf ("DEBUG: second if 3\n"); } - printf ("DEBUG: end of init2\n"); + if (appData.debugMode) { + fprintf(debugFP, "%s\n", programVersion); + } + + if (appData.matchGames > 0) { + appData.matchMode = TRUE; + } else if (appData.matchMode) { + appData.matchGames = 1; + } + if(appData.matchMode && appData.sameColorGames > 0) /* [HGM] alternate: overrule matchGames */ + appData.matchGames = appData.sameColorGames; + if(appData.rewindIndex > 1) { /* [HGM] autoinc: rewind implies auto-increment and overrules given index */ + if(appData.loadPositionIndex >= 0) appData.loadPositionIndex = -1; + if(appData.loadGameIndex >= 0) appData.loadGameIndex = -1; + } + Reset(TRUE, FALSE); + if (appData.noChessProgram || first.protocolVersion == 1) { + InitBackEnd3(); + } else { + /* kludge: allow timeout for initial "feature" commands */ + FreezeUI(); + DisplayMessage("", _("Starting chess program")); + ScheduleDelayedEvent(InitBackEnd3, FEATURE_TIMEOUT); + } } void @@ -4503,8 +4494,6 @@ InitPosition(redraw) oldh = gameInfo.holdingsWidth, oldv = gameInfo.variant; - printf ("DEBUG: in init position\n"); - currentMove = forwardMostMove = backwardMostMove = 0; if(appData.icsActive) shuffleOpenings = FALSE; // [HGM] shuffle: in ICS mode, only shuffle on ICS request @@ -4642,7 +4631,6 @@ InitPosition(redraw) shuffleOpenings = 1; break; } - printf ("DEBUG: in init position 1\n"); overrule = 0; if(appData.NrFiles >= 0) { @@ -4701,9 +4689,6 @@ InitPosition(redraw) initialPosition[BOARD_HEIGHT-2][j] = BlackBishop; } - printf ("DEBUG: in init position 2\n"); - - if( nrCastlingRights == -1) { /* [HGM] Build normal castling rights (must be done after board sizing!) */ /* This sets default castling rights from none to normal corners */ @@ -4752,11 +4737,7 @@ InitPosition(redraw) startedFromSetupPosition = TRUE; } - printf ("DEBUG: in init position 3\n"); - - CopyBoard(boards[0], initialPosition); - printf ("DEBUG: in init position 3.1\n"); if(oldx != gameInfo.boardWidth || oldy != gameInfo.boardHeight || oldh != gameInfo.holdingsWidth @@ -4770,15 +4751,12 @@ InitPosition(redraw) #endif ) { - printf ("DEBUG: in init position 3.2\n"); InitDrawingSizes(-2 ,0); } - printf ("DEBUG: init position 99\n"); if (redraw) DrawPosition(TRUE, boards[currentMove]); - printf ("DEBUG: end init position\n"); } void @@ -8157,7 +8135,6 @@ Reset(redraw, init) int redraw, init; { int i; - printf ("DEBUG: in reset\n"); if (appData.debugMode) { fprintf(debugFP, "Reset(%d, %d) from gameMode %d\n", @@ -8183,9 +8160,6 @@ Reset(redraw, init) white_holding[0] = black_holding[0] = NULLCHAR; ClearProgramStats(); opponentKibitzes = FALSE; // [HGM] kibitz: do not reserve space in engine-output window in zippy mode - - printf ("DEBUG: in reset 1\n"); - ResetFrontEnd(); ClearHighlights(); @@ -8194,11 +8168,7 @@ Reset(redraw, init) gotPremove = FALSE; alarmSounded = FALSE; - printf ("DEBUG: in reset 2\n"); - - GameEnds((ChessMove) 0, NULL, GE_PLAYER); - printf ("DEBUG: in reset2.1\n"); if(appData.serverMovesName != NULL) { /* [HGM] prepare to make moves file for broadcasting */ clock_t t = clock(); @@ -8212,23 +8182,18 @@ Reset(redraw, init) serverMoves = fopen(appData.serverMovesName, "w"); } - printf ("DEBUG: in reset 3\n"); - ExitAnalyzeMode(); gameMode = BeginningOfGame; ModeHighlight(); - printf ("DEBUG: in reset 3.0.1\n"); if(appData.icsActive) gameInfo.variant = VariantNormal; InitPosition(redraw); - printf ("DEBUG: in reset 3.0.1.1\n"); for (i = 0; i < MAX_MOVES; i++) { if (commentList[i] != NULL) { free(commentList[i]); commentList[i] = NULL; } } - printf ("DEBUG: in reset 3.1\n"); ResetClocks(); timeRemaining[0][0] = whiteTimeRemaining; @@ -8240,16 +8205,10 @@ Reset(redraw, init) InitChessProgram(&first, startedFromSetupPosition); } - printf ("DEBUG: in reset 4\n"); - - GUI_DisplayTitle(""); - printf ("DEBUG: in reset 5\n"); DisplayMessage("", ""); - printf ("DEBUG: in reset 6\n"); HistorySet(parseList, backwardMostMove, forwardMostMove, currentMove-1); - printf ("DEBUG: end reset \n"); } void diff --git a/callback.c b/callback.c index 2aec851..2cdddc1 100644 --- a/callback.c +++ b/callback.c @@ -165,8 +165,6 @@ void PauseProc(object, user_data) { // todo this toggling of the pause button doesn't seem to work? // e.g. select pause from buttonbar doesn't activate menumode.pause - // fprintf(stderr,"DEBUG: in pause\n"); - // fflush(stderr); PauseEvent(); } @@ -266,7 +264,6 @@ void UserMoveProc(window, event, data) if (flipView && x >= 0) { x = BOARD_WIDTH - 1 - x; } - printf("DEBUG::UserMoveProc: x %d y %d\n",x,y); if (fromX == -1) { if (event->type == ButtonPress) { @@ -275,7 +272,6 @@ void UserMoveProc(window, event, data) fromX = x; fromY = y; second = 0; - printf("DEBUG::UserMoveProc: a\n"); DragPieceBegin(event->button.x, event->button.y); if (appData.highlightDragging) { SetHighlights(x, y, -1, -1); @@ -293,7 +289,6 @@ void UserMoveProc(window, event, data) /* Check if clicking again on the same color piece */ fromP = boards[currentMove][fromY][fromX]; toP = boards[currentMove][y][x]; - printf("DEBUG::UserMoveProc: b\n"); if ((WhitePawn <= fromP && fromP <= WhiteKing && WhitePawn <= toP && toP <= WhiteKing) || (BlackPawn <= fromP && fromP <= BlackKing && @@ -315,7 +310,6 @@ void UserMoveProc(window, event, data) } if (event->type == GDK_BUTTON_RELEASE && x == fromX && y == fromY) { - printf("DEBUG::UserMoveProc: c\n"); DragPieceEnd(event->button.x, event->button.y); if (appData.animateDragging) { /* Undo animation damage if any */ @@ -339,9 +333,7 @@ void UserMoveProc(window, event, data) toX = x; toY = y; saveAnimate = appData.animate; - printf("DEBUG::UserMoveProc: d\n"); if (event->type == GDK_BUTTON_PRESS) { - printf("DEBUG::UserMoveProc: e\n"); /* Finish clickclick move */ if (appData.animate || appData.highlightLastMove) { SetHighlights(fromX, fromY, toX, toY); @@ -359,9 +351,7 @@ void UserMoveProc(window, event, data) /* Don't animate move and drag both */ appData.animate = FALSE; } - printf("DEBUG::UserMoveProc: f\n"); if (IsPromotion(fromX, fromY, toX, toY)) { - printf("DEBUG::UserMoveProc: f1\n"); if (appData.alwaysPromoteToQueen) { UserMoveEvent(fromX, fromY, toX, toY, 'q'); if (!appData.highlightLastMove || gotPremove) ClearHighlights(); @@ -372,16 +362,13 @@ void UserMoveProc(window, event, data) PromotionPopUp(); } } else { - printf("DEBUG::UserMoveProc: f2\n"); UserMoveEvent(fromX, fromY, toX, toY, NULLCHAR); - printf("DEBUG::UserMoveProc: f3\n"); if (!appData.highlightLastMove || gotPremove) ClearHighlights(); if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY); fromX = fromY = -1; } appData.animate = saveAnimate; - printf("DEBUG::UserMoveProc: g\n"); if (appData.animate || appData.animateDragging) { /* Undo animation damage if needed */ DrawPosition(FALSE, NULL); diff --git a/interface.c b/interface.c index 05975a9..733bf78 100644 --- a/interface.c +++ b/interface.c @@ -86,7 +86,8 @@ void GUI_SetAspectRatio(ratio) GdkGeometry hints; extern GtkWidget *GUI_Window; - hints.min_aspect = hints.max_aspect = ratio; + hints.min_aspect = ratio; + hints.max_aspect = ratio; gtk_window_set_geometry_hints (GTK_WINDOW (GUI_Window), GTK_WIDGET (GUI_Window), diff --git a/xboard.c b/xboard.c index 023da04..87c2727 100644 --- a/xboard.c +++ b/xboard.c @@ -2379,7 +2379,6 @@ main(argc, argv) // don't unref the builder, since we use it to get references to widgets // g_object_unref (G_OBJECT (builder)); - printf("DEBUG:finished building gtk\n"); /* end parse glade file */ if (argc > 1) { @@ -2522,8 +2521,6 @@ main(argc, argv) tinyLayout = szd->tinyLayout; } - printf("DEBUG::main: squareSize %d\n",squareSize); - boardWidth = lineGap + BOARD_WIDTH * (squareSize + lineGap); boardHeight = lineGap + BOARD_HEIGHT * (squareSize + lineGap); if (appData.showJail == 1) { @@ -2681,8 +2678,6 @@ main(argc, argv) textColors[ColorNone].fg = textColors[ColorNone].bg = -1; textColors[ColorNone].attr = 0; - printf("DEBUG: I'm here 0\n"); - // XtAppAddActions(appContext, boardActions, XtNumber(boardActions)); /* @@ -2727,7 +2722,6 @@ main(argc, argv) XtSetArg(args[1], XtNtop, XtChainTop); XtSetArg(args[2], XtNbottom, XtChainTop); XtSetValues(blackTimerWidget, args, 3); - printf("DEBUG: I'm here 1\n"); if (appData.titleInWindow) { widgetList[j++] = titleWidget = @@ -2786,8 +2780,6 @@ main(argc, argv) /* end gtk set properties of widgets */ - printf("DEBUG: made it.\n"); - /* * formWidget uses these constraints but they are stored * in the children. @@ -2797,7 +2789,6 @@ main(argc, argv) // XtSetValues(menuBarWidget, args, i); // if (appData.titleInWindow) { // if (smallLayout) { -// printf("DEBUG: made it a.\n"); // i = 0; // XtSetArg(args[i], XtNfromVert, menuBarWidget); i++; // XtSetValues(whiteTimerWidget, args, i); @@ -2820,7 +2811,6 @@ main(argc, argv) // XtSetValues(buttonBarWidget, args, i); // } // } else { -// printf("DEBUG: made it b.\n"); // i = 0; // XtSetArg(args[i], XtNfromVert, titleWidget); i++; // XtSetValues(whiteTimerWidget, args, i); @@ -2842,7 +2832,7 @@ main(argc, argv) // XtSetValues(buttonBarWidget, args, i); // } // } -// } else { printf("DEBUG: made it c.\n"); +// } else { // // i = 0; // XtSetArg(args[i], XtNfromVert, menuBarWidget); i++; @@ -2862,7 +2852,6 @@ main(argc, argv) // XtSetValues(buttonBarWidget, args, i); // } // } -// printf("DEBUG: made it 1.\n"); // i = 0; // XtSetArg(args[0], XtNfromVert, messageWidget); // XtSetArg(args[1], XtNtop, XtChainTop); @@ -2873,7 +2862,6 @@ main(argc, argv) // // XtRealizeWidget(shellWidget); // - printf("DEBUG: made it 2.\n"); /* * Correct the width of the message and title widgets. @@ -3043,8 +3031,6 @@ main(argc, argv) // XtSetValues(shellWidget, args, i); // - printf("DEBUG: creating svgs.\n"); - /* load square colors */ SVGLightSquare = load_pixbuf("svg/LightSquare.svg",squareSize); SVGDarkSquare = load_pixbuf("svg/DarkSquare.svg",squareSize); @@ -3062,8 +3048,6 @@ main(argc, argv) /* realize window */ gtk_widget_show (GUI_Window); - printf("DEBUG: before created stuff squareSize %d.\n",squareSize); - CreateGCs(); CreateGrid(); CreatePieces(); @@ -3073,9 +3057,6 @@ main(argc, argv) if (appData.animate || appData.animateDragging) CreateAnimVars(); - printf("DEBUG: created stuff squareSize %d.\n",squareSize); - - // XtAugmentTranslations(formWidget, // XtParseTranslationTable(globalTranslations)); // XtAugmentTranslations(boardWidget, @@ -3087,8 +3068,6 @@ main(argc, argv) // InitBackEnd2(); - printf("DEBUG: back end initiated.\n"); - if (errorExitStatus == -1) { if (appData.icsActive) { /* We now wait until we see "login:" from the ICS before @@ -3116,8 +3095,6 @@ main(argc, argv) gdk_cursor_destroy(BoardCursor); /* end cursor */ - printf("DEBUG: going into gtk-main.\n"); - gtk_main (); if (appData.debugMode) fclose(debugFP); // [DM] debug @@ -4230,7 +4207,6 @@ static void colorDrawPiece(piece, square_color, x, y, dest) int square_color, x, y; Drawable dest; { - printf("DEBUG::colorDrawPiece: piece %d square_color %d x %d y %d \n",piece,square_color,x,y); gdk_draw_pixbuf(GDK_WINDOW(GUI_Board->window),NULL,GDK_PIXBUF(SVGpieces[piece]),0,0,x,y,-1,-1, GDK_RGB_DITHER_NORMAL, 0, 0); return ; @@ -4294,7 +4270,6 @@ typedef void (*DrawFunc)(); DrawFunc ChooseDrawFunc() { - printf("DEBUG::ChooseDrawFunc: appData.monoMode %d useImages %d\n",appData.monoMode,useImages); if (appData.monoMode) { if (DefaultDepth(xDisplay, xScreen) == 1) { return monoDrawPiece_1bit; @@ -4349,8 +4324,6 @@ void DrawSquare(row, column, piece, do_flash) /* Calculate delay in milliseconds (2-delays per complete flash) */ flash_delay = 500 / appData.flashRate; - printf("DEBUG: linegap %d squareSize %d \n",lineGap,squareSize); - /* calculate x and y coordinates from row and column */ if (flipView) { x = lineGap + ((BOARD_WIDTH-1)-column) * @@ -4364,8 +4337,6 @@ void DrawSquare(row, column, piece, do_flash) square_color = SquareColor(row, column); - printf("DEBUG::DrawSquare: row %d column %d piece %d do_flash %d square_color %d x %d y %d\n",row,column,piece,do_flash,square_color,x,y); - if ( // [HGM] holdings: blank out area between board and holdings column == BOARD_LEFT-1 || column == BOARD_RGHT || (column == BOARD_LEFT-2 && row < BOARD_HEIGHT-gameInfo.holdingsSize) @@ -4535,9 +4506,6 @@ void DrawPosition( repaint, board) Arg args[16]; int rrow, rcol; - printf ("DEBUG::DrawPosition: start\n"); - - if (board == NULL) { if (!lastBoardValid) return; board = lastBoard; @@ -4553,13 +4521,7 @@ void DrawPosition( repaint, board) * but this causes a very distracting flicker. */ - printf ("DEBUG::DrawPosition: in draw position 0.1\n"); - printf("DEBUG::DrawPosition: squareSize %d\n",squareSize); - - if (!repaint && lastBoardValid && lastFlipView == flipView) { - - printf ("DEBUG::DrawPosition: in draw position 0.1a\n"); /* If too much changes (begin observing new game, etc.), don't do flashing */ do_flash = too_many_diffs(board, lastBoard) ? 0 : 1; @@ -4592,7 +4554,6 @@ void DrawPosition( repaint, board) DrawSquare(i, j, board[i][j], do_flash); } } else { - printf("DEBUG::DrawPosition: in else linegap %d squareSize %d\n",lineGap,squareSize); if (lineGap > 0) { /* todo move GC to setupgc */ @@ -4618,7 +4579,6 @@ void DrawPosition( repaint, board) squareSize=108; for (i = 0; i < BOARD_HEIGHT; i++) for (j = 0; j < BOARD_WIDTH; j++) { - printf("DEBUG::DrawPosition: squareSize %d\n",squareSize); DrawSquare(i, j, board[i][j], 0); damage[i][j] = False; } @@ -5635,8 +5595,6 @@ void ErrorPopUp(title, label, modal) { GtkWidget *dialog; - printf ("DEBUG: error %s %s\n\n",title,label); - dialog = gtk_message_dialog_new(GTK_WINDOW(GUI_Window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, @@ -5728,9 +5686,6 @@ void ModeHighlight() // todo this toggling of the pause button doesn't seem to work? // e.g. select pause from buttonbar doesn't activate menumode.pause - // fprintf(stderr,"DEBUG: oldmode %d newmode %d oldpause %d newpause %d\n",oldmode,gameMode,oldPausing,pausing); - //fflush(stderr); - // if (!boardWidget || !XtIsRealized(boardWidget)) return; if (pausing != oldPausing) { @@ -7024,8 +6979,6 @@ void DisplayMessage(message, extMessage) message = extMessage; } } - - printf("TODO: message %s\n",message); gtk_label_set_text( GTK_LABEL(gtk_builder_get_object (builder, "Messages")),message); } -- 1.7.0.4