From 4d740ff7836b01ece3e8a35d33f1e64a0ad5250e Mon Sep 17 00:00:00 2001
From: Monster Iestyn <iestynjealous@ntlworld.com>
Date: Mon, 17 Jul 2017 21:31:33 +0100
Subject: [PATCH] Change getSpritePatch and getSpritePatch to accept angles 1-8
 instead of 0-7, and just decrement the numbers internally

0 now just defaults to front angle (1, or 0 internally), in case people thought it was a separate angle from 1-8 for some reason
---
 src/lua_hudlib.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c
index de923ab17..0a6415697 100644
--- a/src/lua_hudlib.c
+++ b/src/lua_hudlib.c
@@ -384,8 +384,15 @@ static int libd_getSpritePatch(lua_State *L)
 		return 0;
 	// set angle number
 	sprframe = &sprdef->spriteframes[frame];
-	angle = luaL_optinteger(L, 3, 0);
-	if (angle >= 8)
+	angle = luaL_optinteger(L, 3, 1);
+
+	// convert WAD editor angle numbers (1-8) to internal angle numbers (0-7)
+	// keep 0 the same since we'll make it default to angle 1 (which is internally 0)
+	// in case somebody didn't know that angle 0 really just maps all 8 angles to the same patch
+	if (angle != 0)
+		angle--;
+
+	if (angle >= 8) // out of range?
 		return 0;
 
 	// push both the patch and it's "flip" value
@@ -470,8 +477,15 @@ static int libd_getSprite2Patch(lua_State *L)
 		return 0;
 	// set angle number
 	sprframe = &sprdef->spriteframes[frame];
-	angle = luaL_optinteger(L, 3, 0);
-	if (angle >= 8)
+	angle = luaL_optinteger(L, 3, 1);
+
+	// convert WAD editor angle numbers (1-8) to internal angle numbers (0-7)
+	// keep 0 the same since we'll make it default to angle 1 (which is internally 0)
+	// in case somebody didn't know that angle 0 really just maps all 8 angles to the same patch
+	if (angle != 0)
+		angle--;
+
+	if (angle >= 8) // out of range?
 		return 0;
 
 	// push both the patch and it's "flip" value
-- 
GitLab