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.
This commit is contained in:
TehRealSalt 2018-11-08 14:58:31 -05:00
parent ed1c108992
commit f5a45534fa
2 changed files with 22 additions and 13 deletions

View file

@ -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

View file

@ -720,21 +720,12 @@ 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);
break;
case side_bottomtexture:
if (lua_isstring(L, 3))
side->bottomtexture = R_TextureNumForName(lua_tostring(L, 3));
else
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);
break;
case side_repeatcnt: