mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-20 19:02:34 +00:00
Fix #1393
This commit is contained in:
parent
8701ef41f6
commit
68588a4a46
5 changed files with 34 additions and 49 deletions
|
@ -3166,7 +3166,10 @@ static int lib_rCheckTextureNumForName(lua_State *L)
|
||||||
{
|
{
|
||||||
const char *name = luaL_checkstring(L, 1);
|
const char *name = luaL_checkstring(L, 1);
|
||||||
//HUDSAFE
|
//HUDSAFE
|
||||||
lua_pushinteger(L, R_CheckTextureNumForName(name));
|
INT32 num = R_CheckTextureNumForName(name, TEXTURETYPE_TEXTURE);
|
||||||
|
if (num == -1)
|
||||||
|
num = R_CheckTextureNumForName(name, TEXTURETYPE_FLAT);
|
||||||
|
lua_pushinteger(L, num);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -609,15 +609,15 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize)
|
||||||
levelflat->type = LEVELFLAT_TEXTURE;
|
levelflat->type = LEVELFLAT_TEXTURE;
|
||||||
|
|
||||||
// Look for a flat
|
// Look for a flat
|
||||||
int texturenum = R_CheckFlatNumForName(levelflat->name);
|
int texturenum = R_CheckTextureNumForName(levelflat->name, TEXTURETYPE_FLAT);
|
||||||
if (texturenum < 0)
|
if (texturenum < 0)
|
||||||
{
|
{
|
||||||
// If we can't find a flat, try looking for a texture!
|
// If we can't find a flat, try looking for a texture!
|
||||||
texturenum = R_CheckTextureNumForName(levelflat->name);
|
texturenum = R_CheckTextureNumForName(levelflat->name, TEXTURETYPE_TEXTURE);
|
||||||
if (texturenum < 0)
|
if (texturenum < 0)
|
||||||
{
|
{
|
||||||
// Use "not found" texture
|
// Use "not found" texture
|
||||||
texturenum = R_CheckTextureNumForName("REDWALL");
|
texturenum = R_CheckTextureNumForName("REDWALL", TEXTURETYPE_TEXTURE);
|
||||||
|
|
||||||
// Give up?
|
// Give up?
|
||||||
if (texturenum < 0)
|
if (texturenum < 0)
|
||||||
|
|
14
src/p_spec.c
14
src/p_spec.c
|
@ -135,22 +135,24 @@ void P_ParseAnimationDefintion(SINT8 istexture);
|
||||||
|
|
||||||
static boolean P_FindTextureForAnimation(anim_t *anim, animdef_t *animdef)
|
static boolean P_FindTextureForAnimation(anim_t *anim, animdef_t *animdef)
|
||||||
{
|
{
|
||||||
if (R_CheckTextureNumForName(animdef->startname) == -1)
|
INT32 start = R_CheckTextureNumForName(animdef->startname, TEXTURETYPE_TEXTURE);
|
||||||
|
if (start == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
anim->picnum = R_TextureNumForName(animdef->endname);
|
anim->basepic = start;
|
||||||
anim->basepic = R_TextureNumForName(animdef->startname);
|
anim->picnum = R_CheckTextureNumForName(animdef->endname, TEXTURETYPE_TEXTURE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean P_FindFlatForAnimation(anim_t *anim, animdef_t *animdef)
|
static boolean P_FindFlatForAnimation(anim_t *anim, animdef_t *animdef)
|
||||||
{
|
{
|
||||||
if (R_CheckFlatNumForName(animdef->startname) == -1)
|
INT32 start = R_CheckTextureNumForName(animdef->startname, TEXTURETYPE_FLAT);
|
||||||
|
if (start == -1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
anim->picnum = R_CheckFlatNumForName(animdef->endname);
|
anim->basepic = start;
|
||||||
anim->basepic = R_CheckFlatNumForName(animdef->startname);
|
anim->picnum = R_CheckTextureNumForName(animdef->endname, TEXTURETYPE_FLAT);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -925,7 +925,7 @@ Rloadtextures (INT32 i, INT32 w)
|
||||||
|
|
||||||
// printf("\"%s\" (wad: %u, lump: %u) is a single patch, dimensions %d x %d\n",W_CheckNameForNumPwad(wadnum,lumpnum),wadnum,lumpnum,width,height);
|
// printf("\"%s\" (wad: %u, lump: %u) is a single patch, dimensions %d x %d\n",W_CheckNameForNumPwad(wadnum,lumpnum),wadnum,lumpnum,width,height);
|
||||||
|
|
||||||
R_AddSinglePatchTexture(i, wadnum, lumpnum, width, height, TEXTURETYPE_SINGLEPATCH);
|
R_AddSinglePatchTexture(i, wadnum, lumpnum, width, height, TEXTURETYPE_TEXTURE);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
@ -1494,7 +1494,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
|
||||||
resultTexture->hash = quickncasehash(newTextureName, 8);
|
resultTexture->hash = quickncasehash(newTextureName, 8);
|
||||||
resultTexture->width = newTextureWidth;
|
resultTexture->width = newTextureWidth;
|
||||||
resultTexture->height = newTextureHeight;
|
resultTexture->height = newTextureHeight;
|
||||||
resultTexture->type = TEXTURETYPE_COMPOSITE;
|
resultTexture->type = TEXTURETYPE_TEXTURE;
|
||||||
}
|
}
|
||||||
Z_Free(texturesToken);
|
Z_Free(texturesToken);
|
||||||
texturesToken = M_GetToken(NULL);
|
texturesToken = M_GetToken(NULL);
|
||||||
|
@ -1680,7 +1680,7 @@ static void AddTextureToCache(const char *name, UINT32 hash, INT32 id, UINT8 typ
|
||||||
//
|
//
|
||||||
// Check whether texture is available. Filter out NoTexture indicator.
|
// Check whether texture is available. Filter out NoTexture indicator.
|
||||||
//
|
//
|
||||||
INT32 R_CheckTextureNumForName(const char *name)
|
INT32 R_CheckTextureNumForName(const char *name, UINT8 type)
|
||||||
{
|
{
|
||||||
INT32 i;
|
INT32 i;
|
||||||
UINT32 hash;
|
UINT32 hash;
|
||||||
|
@ -1692,14 +1692,14 @@ INT32 R_CheckTextureNumForName(const char *name)
|
||||||
hash = quickncasehash(name, 8);
|
hash = quickncasehash(name, 8);
|
||||||
|
|
||||||
for (i = 0; i < tidcachelen; i++)
|
for (i = 0; i < tidcachelen; i++)
|
||||||
if (tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8))
|
if (tidcache[i].type == type && tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8))
|
||||||
return tidcache[i].id;
|
return tidcache[i].id;
|
||||||
|
|
||||||
// Need to parse the list backwards, so textures loaded more recently are used in lieu of ones loaded earlier
|
// Need to parse the list backwards, so textures loaded more recently are used in lieu of ones loaded earlier
|
||||||
for (i = numtextures - 1; i >= 0; i--)
|
for (i = numtextures - 1; i >= 0; i--)
|
||||||
if (textures[i]->hash == hash && !strncasecmp(textures[i]->name, name, 8))
|
if (textures[i]->type == type && textures[i]->hash == hash && !strncasecmp(textures[i]->name, name, 8))
|
||||||
{
|
{
|
||||||
AddTextureToCache(name, hash, i, textures[i]->type);
|
AddTextureToCache(name, hash, i, type);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1738,47 +1738,29 @@ const char *R_TextureNameForNum(INT32 num)
|
||||||
//
|
//
|
||||||
// R_TextureNumForName
|
// R_TextureNumForName
|
||||||
//
|
//
|
||||||
// Calls R_CheckTextureNumForName, aborts with error message.
|
// Calls R_CheckTextureNumForName. Returns REDWALL if not found.
|
||||||
//
|
//
|
||||||
INT32 R_TextureNumForName(const char *name)
|
INT32 R_TextureNumForName(const char *name)
|
||||||
{
|
{
|
||||||
const INT32 i = R_CheckTextureNumForName(name);
|
INT32 i = R_CheckTextureNumForName(name, TEXTURETYPE_TEXTURE);
|
||||||
|
|
||||||
|
// Didn't find it, so look for a flat
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
i = R_CheckTextureNumForName(name, TEXTURETYPE_FLAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Still didn't find it, so return REDWALL
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
{
|
{
|
||||||
static INT32 redwall = -2;
|
static INT32 redwall = -2;
|
||||||
CONS_Debug(DBG_SETUP, "WARNING: R_TextureNumForName: %.8s not found\n", name);
|
CONS_Debug(DBG_SETUP, "WARNING: R_TextureNumForName: %.8s not found\n", name);
|
||||||
if (redwall == -2)
|
if (redwall == -2)
|
||||||
redwall = R_CheckTextureNumForName("REDWALL");
|
redwall = R_CheckTextureNumForName("REDWALL", TEXTURETYPE_TEXTURE);
|
||||||
if (redwall != -1)
|
if (redwall != -1)
|
||||||
return redwall;
|
return redwall;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Like R_CheckTextureNumForName, but only looks in the flat namespace specifically.
|
|
||||||
INT32 R_CheckFlatNumForName(const char *name)
|
|
||||||
{
|
|
||||||
INT32 i;
|
|
||||||
UINT32 hash;
|
|
||||||
|
|
||||||
// "NoTexture" marker.
|
|
||||||
if (name[0] == '-')
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
hash = quickncasehash(name, 8);
|
|
||||||
|
|
||||||
for (i = 0; i < tidcachelen; i++)
|
|
||||||
if (tidcache[i].type == TEXTURETYPE_FLAT && tidcache[i].hash == hash && !strncasecmp(tidcache[i].name, name, 8))
|
|
||||||
return tidcache[i].id;
|
|
||||||
|
|
||||||
for (i = numtextures - 1; i >= 0; i--)
|
|
||||||
if (textures[i]->hash == hash && !strncasecmp(textures[i]->name, name, 8) && textures[i]->type == TEXTURETYPE_FLAT)
|
|
||||||
{
|
|
||||||
AddTextureToCache(name, hash, i, TEXTURETYPE_FLAT);
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,8 +40,7 @@ typedef struct
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
TEXTURETYPE_UNKNOWN,
|
TEXTURETYPE_UNKNOWN,
|
||||||
TEXTURETYPE_SINGLEPATCH,
|
TEXTURETYPE_TEXTURE,
|
||||||
TEXTURETYPE_COMPOSITE,
|
|
||||||
TEXTURETYPE_FLAT
|
TEXTURETYPE_FLAT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -100,8 +99,7 @@ void R_SetFlatVars(size_t length);
|
||||||
|
|
||||||
// Returns the texture number for the texture name.
|
// Returns the texture number for the texture name.
|
||||||
INT32 R_TextureNumForName(const char *name);
|
INT32 R_TextureNumForName(const char *name);
|
||||||
INT32 R_CheckTextureNumForName(const char *name);
|
INT32 R_CheckTextureNumForName(const char *name, UINT8 type);
|
||||||
INT32 R_CheckFlatNumForName(const char *name);
|
|
||||||
|
|
||||||
// Returns the texture name for the texture number (in case you ever needed it)
|
// Returns the texture name for the texture number (in case you ever needed it)
|
||||||
const char *R_CheckTextureNameForNum(INT32 num);
|
const char *R_CheckTextureNameForNum(INT32 num);
|
||||||
|
|
Loading…
Reference in a new issue