diff --git a/src/common/rendering/hwrenderer/hw_draw2d.cpp b/src/common/rendering/hwrenderer/hw_draw2d.cpp index fc0b850a9..1d5c47773 100644 --- a/src/common/rendering/hwrenderer/hw_draw2d.cpp +++ b/src/common/rendering/hwrenderer/hw_draw2d.cpp @@ -150,6 +150,9 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state) sciY = screen->ScreenToWindowY(cmd.mScissor[3]); sciW = screen->ScreenToWindowX(cmd.mScissor[2]) - sciX; sciH = screen->ScreenToWindowY(cmd.mScissor[1]) - sciY; + // If coordinates turn out negative, clip to sceen here to avoid undefined behavior. + if (sciX < 0) sciW += sciX, sciX = 0; + if (sciY < 0) sciH += sciY, sciY = 0; } else { diff --git a/src/common/textures/texturemanager.h b/src/common/textures/texturemanager.h index 2aa53da24..90ad35209 100644 --- a/src/common/textures/texturemanager.h +++ b/src/common/textures/texturemanager.h @@ -11,7 +11,6 @@ class FxAddSub; struct BuildInfo; class FMultipatchTextureBuilder; class FScanner; -int PalCheck(int tex); // Texture manager class FTextureManager