X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsystem.c;h=e67cbaeb80c1701f879022671243aaf716f64115;hb=76c6cf34f934b80bcd42ed1f0940c6c56ac1c209;hp=bccb5fddddbc847b0208998eb783968cb86b9dd9;hpb=41def9c1d8c6939b8754fdab43579272e49d4da4;p=rocksndiamonds.git diff --git a/src/libgame/system.c b/src/libgame/system.c index bccb5fdd..e67cbaeb 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -527,19 +527,23 @@ static boolean ValidClippedRectangle(Bitmap *bitmap, int *x, int *y, if (*x < 0) { - *x = 0; *width += *x; + *x = 0; } else if (*x + *width > bitmap->width) + { *width = bitmap->width - *x; + } if (*y < 0) { - *y = 0; *height += *y; + *y = 0; } else if (*y + *height > bitmap->height) + { *height = bitmap->height - *y; + } return TRUE; } @@ -548,6 +552,9 @@ void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap, int src_x, int src_y, int width, int height, int dst_x, int dst_y) { + int dst_x_unclipped = dst_x; + int dst_y_unclipped = dst_y; + if (DrawingDeactivated(dst_x, dst_y, width, height)) return; @@ -555,6 +562,11 @@ void BlitBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap, if (!ValidClippedRectangle(src_bitmap, &src_x, &src_y, &width, &height) || !ValidClippedRectangle(dst_bitmap, &dst_x, &dst_y, &width, &height)) return; + + /* source x/y might need adjustment if destination x/y was clipped top/left */ + src_x += dst_x - dst_x_unclipped; + src_y += dst_y - dst_y_unclipped; + #else /* skip if rectangle starts outside bitmap */ if (src_x >= src_bitmap->width ||