mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-07 00:41:26 +00:00
fix accessing spriteinfo[] with a string as a key
This commit is contained in:
parent
f739956e89
commit
23d89bec1d
1 changed files with 10 additions and 4 deletions
|
@ -229,14 +229,13 @@ static int lib_spr2namelen(lua_State *L)
|
||||||
|
|
||||||
static int lib_getSpriteInfo(lua_State *L)
|
static int lib_getSpriteInfo(lua_State *L)
|
||||||
{
|
{
|
||||||
UINT32 i = 0;
|
UINT32 i = NUMSPRITES;
|
||||||
lua_remove(L, 1);
|
lua_remove(L, 1);
|
||||||
|
|
||||||
/*if (lua_isstring(L, 1))
|
if (lua_isstring(L, 1))
|
||||||
{
|
{
|
||||||
const char *name = lua_tostring(L, 1);
|
const char *name = lua_tostring(L, 1);
|
||||||
INT32 spr;
|
INT32 spr;
|
||||||
CONS_Printf("%s\n",name);
|
|
||||||
for (spr = 0; spr < NUMSPRITES; spr++)
|
for (spr = 0; spr < NUMSPRITES; spr++)
|
||||||
{
|
{
|
||||||
if (fastcmp(name, sprnames[spr]))
|
if (fastcmp(name, sprnames[spr]))
|
||||||
|
@ -245,8 +244,15 @@ static int lib_getSpriteInfo(lua_State *L)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (i == NUMSPRITES)
|
||||||
|
{
|
||||||
|
char *check;
|
||||||
|
i = strtol(name, &check, 10);
|
||||||
|
if (check == name || *check != '\0')
|
||||||
|
return luaL_error(L, "unknown sprite name %s", name);
|
||||||
}
|
}
|
||||||
else*/
|
}
|
||||||
|
else
|
||||||
i = luaL_checkinteger(L, 1);
|
i = luaL_checkinteger(L, 1);
|
||||||
|
|
||||||
if (i == 0 || i >= NUMSPRITES)
|
if (i == 0 || i >= NUMSPRITES)
|
||||||
|
|
Loading…
Reference in a new issue