From 6145442a34ad838009d15bdb36d0a443dc1f77a5 Mon Sep 17 00:00:00 2001
From: Jaime Passos <lazymyuutsu@gmail.com>
Date: Sat, 10 Oct 2020 19:06:29 -0300
Subject: [PATCH] Fix rotated flipped patches

---
 src/r_patchrotation.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c
index 83eb4eeba0..803e159ef5 100644
--- a/src/r_patchrotation.c
+++ b/src/r_patchrotation.c
@@ -127,17 +127,15 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
 #define ROTSPRITE_YCENTER (newheight / 2)
 
 	if (flip)
-		idx += rotsprite->angles;
-
-	if (rotsprite->patches[idx])
-		return;
-
-	if (bflip)
 	{
+		idx += rotsprite->angles;
 		xpivot = width - xpivot;
 		leftoffset = width - leftoffset;
 	}
 
+	if (rotsprite->patches[idx])
+		return;
+
 	// Find the dimensions of the rotated patch.
 	{
 		INT32 w1 = abs(FixedMul(width << FRACBITS, ca) - FixedMul(height << FRACBITS, sa));
@@ -226,7 +224,7 @@ void RotatedPatch_DoRotation(rotsprite_t *rotsprite, patch_t *patch, INT32 angle
 	rotated = (patch_t *)Picture_Convert(PICFMT_FLAT16, rawdst, PICFMT_PATCH, 0, &size, newwidth, newheight, 0, 0, 0);
 
 	Z_ChangeTag(rotated, PU_PATCH_ROTATED);
-	Z_SetUser(rotated, (void **)(&rotsprite->patches[angle]));
+	Z_SetUser(rotated, (void **)(&rotsprite->patches[idx]));
 
 	rotated->leftoffset = (rotated->width / 2) + (leftoffset - xpivot);
 	rotated->topoffset = (rotated->height / 2) + (patch->topoffset - ypivot);
-- 
GitLab