From 936e89e3d4d22e5f7cc3a89e7f1f6ee6ee829b43 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 20 Oct 2022 16:44:05 +0200 Subject: [PATCH] - fixed F2DDrawer::SetClipRect. --- src/common/2d/v_draw.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/common/2d/v_draw.cpp b/src/common/2d/v_draw.cpp index b5cc614bc..f78446fc8 100644 --- a/src/common/2d/v_draw.cpp +++ b/src/common/2d/v_draw.cpp @@ -393,10 +393,14 @@ DEFINE_ACTION_FUNCTION(FCanvas, DrawShapeFill) void F2DDrawer::SetClipRect(int x, int y, int w, int h) { - clipleft = clamp(x, 0, GetWidth()); - clipwidth = clamp(w, -1, GetWidth() - x); - cliptop = clamp(y, 0, GetHeight()); - clipheight = clamp(h, -1, GetHeight() - y); + if (x < 0) { w += x; x = 0; } + if (y < 0) { h += y; y = 0; } + if (x >= GetWidth()) { x = GetWidth(); w = 0; } + if (y >= GetHeight()) { x = GetHeight(); h = 0; } + clipleft = x; + clipwidth = w; + cliptop = y; + clipheight = h; } DEFINE_ACTION_FUNCTION(_Screen, SetClipRect)