From 3e9edab7b0d76ca89a84f4096fd2d563194399ca Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Wed, 21 Aug 2019 21:25:45 -0400 Subject: [PATCH 1/4] Use correct integer format --- src/lua_playerlib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index dd7439321..1b219c70a 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -628,7 +628,7 @@ static int power_get(lua_State *L) UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %u", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); lua_pushinteger(L, powers[p]); return 1; } @@ -640,7 +640,7 @@ static int power_set(lua_State *L) powertype_t p = luaL_checkinteger(L, 2); UINT16 i = (UINT16)luaL_checkinteger(L, 3); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %u", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); powers[p] = i; From 8e5dd1af19e007a83fc54603e354ed2aefa961af Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 24 Aug 2019 18:22:18 -0400 Subject: [PATCH 2/4] Typecast p to INT16 Since the enum type is implementation-defined, and could be either signed or unsigned. --- src/lua_playerlib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 1b219c70a..d5b949f43 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -628,19 +628,19 @@ static int power_get(lua_State *L) UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p); lua_pushinteger(L, powers[p]); return 1; } // powers, p, value -> powers[p] = value -static int power_set(lua_State *L) -{ +static int power_set(lua_State *L){ + UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); UINT16 i = (UINT16)luaL_checkinteger(L, 3); if (p >= NUMPOWERS) - return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", p); + return luaL_error(L, LUA_QL("powertype_t") " cannot be %d", (INT16)p); if (hud_running) return luaL_error(L, "Do not alter player_t in HUD rendering code!"); powers[p] = i; From 4aa06071c3c8b69eea393c4d7ffe1bef82ad1505 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 24 Aug 2019 18:27:07 -0400 Subject: [PATCH 3/4] I don't even know how this happened --- src/lua_playerlib.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index d5b949f43..b3bda2520 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -634,7 +634,8 @@ static int power_get(lua_State *L) } // powers, p, value -> powers[p] = value -static int power_set(lua_State *L){ +static int power_set(lua_State *L) +{ UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); From a2787437088592f7f17a0db1d32078839653ed10 Mon Sep 17 00:00:00 2001 From: Steel Titanium Date: Sat, 24 Aug 2019 18:29:56 -0400 Subject: [PATCH 4/4] Remove extra whitespace --- src/lua_playerlib.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index b3bda2520..68e3e7891 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -636,7 +636,6 @@ static int power_get(lua_State *L) // powers, p, value -> powers[p] = value static int power_set(lua_State *L) { - UINT16 *powers = *((UINT16 **)luaL_checkudata(L, 1, META_POWERS)); powertype_t p = luaL_checkinteger(L, 2); UINT16 i = (UINT16)luaL_checkinteger(L, 3);