mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Use R_GetSpriteNumByName everywhere
This commit is contained in:
parent
45d54c38f7
commit
a6b71826f9
5 changed files with 29 additions and 43 deletions
|
@ -450,17 +450,19 @@ static int ScanConstants(lua_State *L, boolean mathlib, const char *word)
|
||||||
}
|
}
|
||||||
else if (fastncmp("SPR_",word,4)) {
|
else if (fastncmp("SPR_",word,4)) {
|
||||||
p = word+4;
|
p = word+4;
|
||||||
for (i = 0; i < NUMSPRITES; i++)
|
i = R_GetSpriteNumByName(p);
|
||||||
if (fastcmp(p,sprnames[i])) {
|
if (i != NUMSPRITES)
|
||||||
// updating overridden sprnames is not implemented for soc parser,
|
{
|
||||||
// so don't use cache
|
// updating overridden sprnames is not implemented for soc parser,
|
||||||
if (mathlib)
|
// so don't use cache
|
||||||
lua_pushinteger(L, i);
|
if (mathlib)
|
||||||
else
|
lua_pushinteger(L, i);
|
||||||
CacheAndPushConstant(L, word, i);
|
else
|
||||||
return 1;
|
CacheAndPushConstant(L, word, i);
|
||||||
}
|
return 1;
|
||||||
if (mathlib) return luaL_error(L, "sprite '%s' could not be found.\n", word);
|
}
|
||||||
|
else if (mathlib)
|
||||||
|
return luaL_error(L, "sprite '%s' could not be found.\n", word);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else if (fastncmp("SPR2_",word,5)) {
|
else if (fastncmp("SPR2_",word,5)) {
|
||||||
|
|
|
@ -4180,9 +4180,9 @@ spritenum_t get_sprite(const char *word)
|
||||||
return atoi(word);
|
return atoi(word);
|
||||||
if (fastncmp("SPR_",word,4))
|
if (fastncmp("SPR_",word,4))
|
||||||
word += 4; // take off the SPR_
|
word += 4; // take off the SPR_
|
||||||
for (i = 0; i < NUMSPRITES; i++)
|
i = R_GetSpriteNumByName(word);
|
||||||
if (!strcmp(word, sprnames[i]))
|
if (i != NUMSPRITES)
|
||||||
return i;
|
return i;
|
||||||
deh_warning("Couldn't find sprite named 'SPR_%s'",word);
|
deh_warning("Couldn't find sprite named 'SPR_%s'",word);
|
||||||
return SPR_NULL;
|
return SPR_NULL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -492,9 +492,7 @@ static int libd_getSpritePatch(lua_State *L)
|
||||||
else if (lua_isstring(L, 1)) // sprite prefix name given, e.g. "THOK"
|
else if (lua_isstring(L, 1)) // sprite prefix name given, e.g. "THOK"
|
||||||
{
|
{
|
||||||
const char *name = lua_tostring(L, 1);
|
const char *name = lua_tostring(L, 1);
|
||||||
for (i = 0; i < NUMSPRITES; i++)
|
i = R_GetSpriteNumByName(name);
|
||||||
if (fastcmp(name, sprnames[i]))
|
|
||||||
break;
|
|
||||||
if (i >= NUMSPRITES)
|
if (i >= NUMSPRITES)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,12 +88,12 @@ static int lib_getSprname(lua_State *L)
|
||||||
else if (lua_isstring(L, 1))
|
else if (lua_isstring(L, 1))
|
||||||
{
|
{
|
||||||
const char *name = lua_tostring(L, 1);
|
const char *name = lua_tostring(L, 1);
|
||||||
for (i = 0; i < NUMSPRITES; i++)
|
i = R_GetSpriteNumByName(name);
|
||||||
if (fastcmp(name, sprnames[i]))
|
if (i != NUMSPRITES)
|
||||||
{
|
{
|
||||||
lua_pushinteger(L, i);
|
lua_pushinteger(L, i);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -245,22 +245,15 @@ static int lib_getSpriteInfo(lua_State *L)
|
||||||
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 = R_GetSpriteNumByName(name);
|
||||||
for (spr = 0; spr < NUMSPRITES; spr++)
|
if (spr == NUMSPRITES)
|
||||||
{
|
|
||||||
if (fastcmp(name, sprnames[spr]))
|
|
||||||
{
|
|
||||||
i = spr;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (i == NUMSPRITES)
|
|
||||||
{
|
{
|
||||||
char *check;
|
char *check;
|
||||||
i = strtol(name, &check, 10);
|
i = strtol(name, &check, 10);
|
||||||
if (check == name || *check != '\0')
|
if (check == name || *check != '\0')
|
||||||
return luaL_error(L, "unknown sprite name %s", name);
|
return luaL_error(L, "unknown sprite name %s", name);
|
||||||
}
|
}
|
||||||
|
i = spr;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
i = luaL_checkinteger(L, 1);
|
i = luaL_checkinteger(L, 1);
|
||||||
|
|
|
@ -1592,16 +1592,9 @@ static void R_ParseSpriteInfo(boolean spr2)
|
||||||
|
|
||||||
if (!spr2)
|
if (!spr2)
|
||||||
{
|
{
|
||||||
for (i = 0; i <= NUMSPRITES; i++)
|
sprnum = R_GetSpriteNumByName(newSpriteName);
|
||||||
{
|
if (sprnum == NUMSPRITES)
|
||||||
if (i == NUMSPRITES)
|
I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName);
|
||||||
I_Error("Error parsing SPRTINFO lump: Unknown sprite name \"%s\"", newSpriteName);
|
|
||||||
if (!strcmp(newSpriteName, sprnames[i]))
|
|
||||||
{
|
|
||||||
sprnum = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue