Merge branch 'master' into gtk
authorArun Persaud <arun@nubati.net>
Sat, 10 Oct 2009 17:01:37 +0000 (10:01 -0700)
committerArun Persaud <arun@nubati.net>
Sat, 10 Oct 2009 17:01:37 +0000 (10:01 -0700)
Conflicts:
backend.c
xboard.c
xhistory.c

1  2 
backend.c
xboard.c
xengineoutput.c

diff --cc backend.c
+++ b/backend.c
@@@ -5077,12 -4986,14 +4987,14 @@@ UserMoveTest(fromX, fromY, toX, toY, pr
              (WhitePawn <= pdown && pdown < BlackPawn &&
               WhitePawn <= pup && pup < BlackPawn  ||
               BlackPawn <= pdown && pdown < EmptySquare &&
 -             BlackPawn <= pup && pup < EmptySquare 
 +             BlackPawn <= pup && pup < EmptySquare
              ) && !((gameInfo.variant == VariantFischeRandom || gameInfo.variant == VariantCapaRandom) &&
                      (pup == WhiteRook && pdown == WhiteKing && fromY == 0 && toY == 0||
-                      pup == BlackRook && pdown == BlackKing && fromY == BOARD_HEIGHT-1 && toY == BOARD_HEIGHT-1  )
+                      pup == BlackRook && pdown == BlackKing && fromY == BOARD_HEIGHT-1 && toY == BOARD_HEIGHT-1 ||
+                      pup == WhiteKing && pdown == WhiteRook && fromY == 0 && toY == 0|| // also allow RxK
+                      pup == BlackKing && pdown == BlackRook && fromY == BOARD_HEIGHT-1 && toY == BOARD_HEIGHT-1  ) 
          )           )
-          return ImpossibleMove;
+          return Comment;
  
      /* Check if the user is playing in turn.  This is complicated because we
         let the user "pick up" a piece before it is his turn.  So the piece he
@@@ -5496,9 -5347,9 +5395,9 @@@ UserMoveEvent(fromX, fromY, toX, toY, p
         slip a promotion popup in between. But that it always needs two
         calls, to the first part, (now called UserMoveTest() ), and to
         FinishMove if the first part succeeded. Calls that do not need
 -       to do anything in between, can call this routine the old way. 
 +       to do anything in between, can call this routine the old way.
      */
-     ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar);
+     ChessMove moveType = UserMoveTest(fromX, fromY, toX, toY, promoChar, FALSE);
  if(appData.debugMode) fprintf(debugFP, "moveType 4 = %d, promochar = %x\n", moveType, promoChar);
      if(moveType == AmbiguousMove)
        DrawPosition(FALSE, boards[currentMove]);
@@@ -7522,9 -7356,12 +7404,12 @@@ MakeMove(fromX, fromY, toX, toY, promoC
      }
      CopyBoard(boards[forwardMostMove+1], boards[forwardMostMove]);
      {int i; for(i=0; i<BOARD_SIZE; i++) castlingRights[forwardMostMove+1][i] = castlingRights[forwardMostMove][i];}
 -    ApplyMove(fromX, fromY, toX, toY, promoChar, boards[forwardMostMove+1], 
 +    ApplyMove(fromX, fromY, toX, toY, promoChar, boards[forwardMostMove+1],
                                castlingRights[forwardMostMove+1], &epStatus[forwardMostMove+1]);
      forwardMostMove++; // [HGM] bare: moved to after ApplyMove, to make sure clock interrupt finds complete board
+     SwitchClocks(); // uses forwardMostMove, so must be done after incrementing it !
+     timeRemaining[0][forwardMostMove] = whiteTimeRemaining;
+     timeRemaining[1][forwardMostMove] = blackTimeRemaining;
      gameInfo.result = GameUnfinished;
      if (gameInfo.resultDetails != NULL) {
        free(gameInfo.resultDetails);
diff --cc xboard.c
+++ b/xboard.c
@@@ -2207,51 -2414,17 +2211,52 @@@ main(argc, argv
        XtAppInitialize(&appContext, "XBoard", shellOptions,
                      XtNumber(shellOptions),
                      &argc, argv, xboardResources, NULL, 0);
 -    if (argc > 1) 
 -      { /* left over command line arguments, print out help and exit.
 -       * Use two columns to print help
 -       */
 +
 +    /* set up GTK */
 +    gtk_init (&argc, &argv);
 +
 +    /* parse glade file to build widgets */
 +
 +    builder = gtk_builder_new ();
 +    gtk_builder_add_from_file (builder, "gtk-interface.xml", NULL);
 +
 +    /* test if everything worked ok */
 +
 +    GUI_Window = GTK_WIDGET (gtk_builder_get_object (builder, "MainWindow"));
 +    if(!GUI_Window) printf("Error: gtk_builder didn't work!\n");
 +
 +    GUI_History = GTK_WIDGET (gtk_builder_get_object (builder, "MoveHistory"));
 +    if(!GUI_History) printf("Error: gtk_builder didn't work!\n");
 +
 +    GUI_Board  = GTK_WIDGET (gtk_builder_get_object (builder, "Board"));
 +    if(!GUI_Board) printf("Error: gtk_builder didn't work!\n");
 +
 +    GUI_Whiteclock  = GTK_WIDGET (gtk_builder_get_object (builder, "WhiteClock"));
 +    if(!GUI_Whiteclock) printf("Error: gtk_builder didn't work!\n");
 +
 +    GUI_Blackclock  = GTK_WIDGET (gtk_builder_get_object (builder, "BlackClock"));
 +    if(!GUI_Blackclock) printf("Error: gtk_builder didn't work!\n");
 +
 +    LIST_MoveHistory = GTK_LIST_STORE (gtk_builder_get_object (builder, "MoveHistoryStore"));
 +    if(!LIST_MoveHistory) printf("Error: gtk_builder didn't work!\n");
 +
 +
 +    gtk_builder_connect_signals (builder, NULL);
 +
 +    // don't unref the builder, since we use it to get references to widgets
 +    //    g_object_unref (G_OBJECT (builder));
 +
 +    /* end parse glade file */
 +
 +    if (argc > 1)
 +      {
        fprintf(stderr, _("%s: unrecognized argument %s\n"),
                programName, argv[1]);
        fprintf(stderr, "Recognized options:\n");
-       for(i = 0; i < XtNumber(shellOptions); i++)
+       for(i = 0; i < XtNumber(shellOptions); i++) 
          {
+           /* print first column */
            j = fprintf(stderr, "  %s%s", shellOptions[i].option,
                        (shellOptions[i].argKind == XrmoptionSepArg
                         ? " ARG" : ""));
      xScreen = DefaultScreen(xDisplay);
      wm_delete_window = XInternAtom(xDisplay, "WM_DELETE_WINDOW", True);
  
 -      gameInfo.variant = StringToVariant(appData.variant);
 -      InitPosition(FALSE);
 +    gameInfo.variant = StringToVariant(appData.variant);
 +    InitPosition(FALSE);
- #if 0
-     /*
-      * Determine boardSize
-      */
-     gameInfo.boardWidth = gameInfo.boardHeight = 8; // [HGM] boardsize: make sure we start as 8x8
-     //#ifndef IDSIZE
-     // [HGM] as long as we have not created the possibility to change size while running, start with requested size
-     gameInfo.boardWidth    = appData.NrFiles > 0 ? appData.NrFiles : 8;
-     gameInfo.boardHeight   = appData.NrRanks > 0 ? appData.NrRanks : 8;
-     gameInfo.holdingsWidth = appData.holdingsSize > 0 ? 2 : 0;
- #endif
 +
  
  #ifdef IDSIZE
      InitDrawingSizes(-1, 0); // [HGM] initsize: make this into a subroutine
@@@ -4127,21 -5160,11 +4136,12 @@@ void HandleUserMove(w, event, prms, npr
        }
      }
  
-     x = EventToSquare(event->xbutton.x, BOARD_WIDTH);
-     y = EventToSquare(event->xbutton.y, BOARD_HEIGHT);
-     if (!flipView && y >= 0) {
-       y = BOARD_HEIGHT - 1 - y;
-     }
-     if (flipView && x >= 0) {
-       x = BOARD_WIDTH - 1 - x;
-     }
      /* [HGM] holdings: next 5 lines: ignore all clicks between board and holdings */
      if(event->type == ButtonPress
 -            && ( 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-1 || 
 +               x == BOARD_RGHT   || 
 +               (x == BOARD_LEFT-2 && y < BOARD_HEIGHT-gameInfo.holdingsSize ) || 
 +               (x == BOARD_RGHT+1 && y >= gameInfo.holdingsSize)) )
        return;
  
      if (fromX == -1) {
diff --cc xengineoutput.c
Simple merge