Prevent odd-width line shift in length direction
[xboard.git] / draw.c
diff --git a/draw.c b/draw.c
index ea6e4be..82c5582 100644 (file)
--- a/draw.c
+++ b/draw.c
@@ -287,8 +287,13 @@ ScaleOnePiece (int color, int piece)
   }
 
   if(!pngPieceImages[color][piece]) { // we still did not manage to acquire a piece bitmap
-    if(!(svgPieces[color][piece] = LoadSVG(SVGDIR, color, piece))) // try to fall back on installed svg
-      DisplayError(_("No default pieces installed\nSelect your own -pieceImageDirectory"), 0); // give up
+    static int warned = 0;
+    if(!(svgPieces[color][piece] = LoadSVG(SVGDIR, color, piece)) && !warned) { // try to fall back on installed svg
+      char *msg = _("No default pieces installed\nSelect your own -pieceImageDirectory");
+      printf("%s\n", msg); // give up
+      DisplayError(msg, 0);
+      warned = 1; // prevent error message being repeated for each piece type
+    }
   }
 
   img = pngPieceImages[color][piece];
@@ -298,6 +303,8 @@ ScaleOnePiece (int color, int piece)
   pngPieceBitmaps2[color][piece] = cs = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, squareSize, squareSize);
   if(piece <= WhiteKing) pngPieceBitmaps[color][piece] = cs;
 
+  if(!img) return;
+
   // scaled copying of the raw png image
   cr = cairo_create(cs);
   w = cairo_image_surface_get_width (img);
@@ -355,7 +362,6 @@ void
 InitDrawingParams (int reloadPieces)
 {
     int i, p;
-    MakeColors();
     if(reloadPieces)
     for(i=0; i<2; i++) for(p=0; p<BlackPawn+4; p++) {
        if(pngPieceImages[i][p]) cairo_surface_destroy(pngPieceImages[i][p]);
@@ -512,8 +518,9 @@ DrawGrid()
   /* lines in X */
   for (i = 0; i < BOARD_WIDTH + BOARD_HEIGHT + 2; i++)
     {
-      cairo_move_to (cr, gridSegments[i].x1 + odd, gridSegments[i].y1 + odd);
-      cairo_line_to (cr, gridSegments[i].x2 + odd, gridSegments[i].y2 + odd);
+      int h = (gridSegments[i].y1 == gridSegments[i].y2); // horizontal
+      cairo_move_to (cr, gridSegments[i].x1 + !h*odd, gridSegments[i].y1 + h*odd);
+      cairo_line_to (cr, gridSegments[i].x2 + !h*odd, gridSegments[i].y2 + h*odd);
       cairo_stroke (cr);
     }