From f5a45534fa560f462298045f74a9b59524f2ee62 Mon Sep 17 00:00:00 2001 From: TehRealSalt Date: Thu, 8 Nov 2018 14:58:31 -0500 Subject: [PATCH] Make the texture stuff completely integer-based again, but expose R_TextureNumForName Decided that being able to set a string and then have it return an integer when retrieving would ultimately be confusing, so let's just let the user handle the string functions. --- src/lua_baselib.c | 20 +++++++++++++++++++- src/lua_maplib.c | 15 +++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/lua_baselib.c b/src/lua_baselib.c index a536593b..179cedc7 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1722,7 +1722,23 @@ static int lib_rSetPlayerSkin(lua_State *L) // R_DATA //////////// -// This also doesn't exist, but we need it for texture find+replace to not be a horrible chore. +static int lib_rCheckTextureNumForName(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + //HUDSAFE + lua_pushinteger(L, R_CheckTextureNumForName(name)); + return 1; +} + +static int lib_rTextureNumForName(lua_State *L) +{ + const char *name = luaL_checkstring(L, 1); + //HUDSAFE + lua_pushinteger(L, R_TextureNumForName(name)); + return 1; +} + +// This doesn't exist, but we need it for texture find+replace to not be a horrible chore. static int lib_rGetTextureName(lua_State *L) { INT32 texnum = luaL_checkinteger(L, 1); @@ -2585,6 +2601,8 @@ static luaL_Reg lib[] = { {"R_SetPlayerSkin",lib_rSetPlayerSkin}, // r_data + {"R_CheckTextureNumForName",lib_rCheckTextureNumForName), + {"R_TextureNumForName",lib_rTextureNumForName), {"R_GetTextureName",lib_rGetTextureName}, // s_sound diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 0b60c9c9..2e342278 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -720,22 +720,13 @@ static int side_set(lua_State *L) side->rowoffset = luaL_checkfixed(L, 3); break; case side_toptexture: - if (lua_isstring(L, 3)) - side->toptexture = R_TextureNumForName(lua_tostring(L, 3)); - else - side->toptexture = luaL_checkinteger(L, 3); + side->toptexture = luaL_checkinteger(L, 3); break; case side_bottomtexture: - if (lua_isstring(L, 3)) - side->bottomtexture = R_TextureNumForName(lua_tostring(L, 3)); - else - side->bottomtexture = luaL_checkinteger(L, 3); + side->bottomtexture = luaL_checkinteger(L, 3); break; case side_midtexture: - if (lua_isstring(L, 3)) - side->midtexture = R_TextureNumForName(lua_tostring(L, 3)); - else - side->midtexture = luaL_checkinteger(L, 3); + side->midtexture = luaL_checkinteger(L, 3); break; case side_repeatcnt: side->repeatcnt = luaL_checkinteger(L, 3);