From 154b9cfc40189ea662cc2fa6173d2b541c9301dc Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Sun, 30 May 2021 09:45:25 -0400
Subject: [PATCH] Rect20to12 needs to clamp negative dimensions to zero.
Otherwise the unsigned conversion will make the values extremely bogus.
Fixes the weird lines in icebreaker's high score.
Fixes #68.
---
src/SDL12_compat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/SDL12_compat.c b/src/SDL12_compat.c
index e16980c..db9ec6e 100644
--- a/src/SDL12_compat.c
+++ b/src/SDL12_compat.c
@@ -2640,8 +2640,8 @@ Rect20to12(const SDL_Rect *rect20, SDL12_Rect *rect12)
{
rect12->x = (Sint16) rect20->x;
rect12->y = (Sint16) rect20->y;
- rect12->w = (Uint16) rect20->w;
- rect12->h = (Uint16) rect20->h;
+ rect12->w = (Uint16) ((rect20->w <= 0) ? 0 : rect20->w);
+ rect12->h = (Uint16) ((rect20->h <= 0) ? 0 : rect20->h);
return rect12;
}