Merge branch 'blankart-dev' into AirDrop

This commit is contained in:
NepDisk 2025-09-20 14:01:38 -04:00
commit 78a9947662
9 changed files with 62 additions and 61 deletions

View file

@ -233,10 +233,22 @@ void K_InitBrightmapsPwad(INT32 wadNum)
break;
}
texNum = R_CheckTextureNumForName(bms->textureName);
texNum = R_CheckTextureNumForName(bms->textureName, TEXTURETYPE_TEXTURE);
if (texNum == -1)
{
texNum = R_CheckTextureNumForName(bms->textureName, TEXTURETYPE_FLAT);
}
if (texNum != -1)
{
bmNum = R_CheckTextureNumForName(bms->brightmapName);
bmNum = R_CheckTextureNumForName(bms->brightmapName, TEXTURETYPE_TEXTURE);
if (bmNum == -1)
{
bmNum = R_CheckTextureNumForName(bms->brightmapName, TEXTURETYPE_FLAT);
}
R_UpdateTextureBrightmap(texNum, (bmNum == -1 ? 0 : bmNum));
}
}

View file

@ -2136,7 +2136,13 @@ static boolean K_TERRAINLumpParser(char *data, size_t size)
f->terrainID = K_GetTerrainHeapIndex(t);
CONS_Printf("Texture '%s' set to Terrain '%s'\n", f->textureName, tkn);
INT32 tex = R_CheckTextureNumForName(f->textureName);
INT32 tex = R_CheckTextureNumForName(f->textureName, TEXTURETYPE_TEXTURE);
if (tex == -1)
{
R_CheckTextureNumForName(f->textureName, TEXTURETYPE_FLAT);
}
if (tex != -1)
{
textures[tex]->terrainID = f->terrainID;

View file

@ -2552,7 +2552,10 @@ static int lib_rCheckTextureNumForName(lua_State *L)
{
const char *name = luaL_checkstring(L, 1);
//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;
}

View file

@ -587,15 +587,15 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize)
levelflat->type = LEVELFLAT_TEXTURE;
// Look for a flat
int texturenum = R_CheckFlatNumForName(levelflat->name);
if (texturenum <= 0)
int texturenum = R_CheckTextureNumForName(levelflat->name, TEXTURETYPE_FLAT);
if (texturenum < 0)
{
// If we can't find a flat, try looking for a texture!
texturenum = R_CheckTextureNumForName(levelflat->name);
if (texturenum <= 0)
texturenum = R_CheckTextureNumForName(levelflat->name, TEXTURETYPE_TEXTURE);
if (texturenum < 0)
{
// Use "not found" texture
texturenum = R_CheckTextureNumForName(MISSING_TEXTURE);
texturenum = R_CheckTextureNumForName(MISSING_TEXTURE, TEXTURETYPE_TEXTURE);
// Give up?
if (texturenum <= 0)

View file

@ -104,22 +104,24 @@ void P_ParseAnimationDefintion(SINT8 istexture, boolean compat);
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;
anim->picnum = R_TextureNumForName(animdef->endname);
anim->basepic = R_TextureNumForName(animdef->startname);
anim->basepic = start;
anim->picnum = R_CheckTextureNumForName(animdef->endname, TEXTURETYPE_TEXTURE);
return true;
}
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;
anim->picnum = R_CheckFlatNumForName(animdef->endname);
anim->basepic = R_CheckFlatNumForName(animdef->startname);
anim->basepic = start;
anim->picnum = R_CheckTextureNumForName(animdef->endname, TEXTURETYPE_FLAT);
return true;
}

View file

@ -2055,7 +2055,7 @@ void R_StoreWallRange(INT32 start, INT32 stop)
{
//srb2::r_debug::add_texture_to_frame_list(texnum);
// R_DrawWallColumn cannot render holey textures
return R_GetTextureNum(R_CheckTextureNumForName("TRANSER1"));
return R_GetTextureNum(R_CheckTextureNumForName("TRANSER1", TEXTURETYPE_TEXTURE));
}
return texnum;
};

View file

@ -69,7 +69,7 @@ void R_SetupSkyDraw(void)
skytexturemid = (textures[skytexture]->height / 2) << FRACBITS;
skytextureoffset = 0;
if (textures[skytexture]->type == TEXTURETYPE_SINGLEPATCH)
if (textures[skytexture]->type == TEXTURETYPE_TEXTURE)
{
// Sal: Allow for sky offsets
texpatch_t *const tex_patch = &textures[skytexture]->patches[0];

View file

@ -1279,7 +1279,7 @@ Rloadtextures (INT32 i, INT32 w)
texture->height = SHORT(patchlump.height);
}
texture->type = TEXTURETYPE_SINGLEPATCH;
texture->type = TEXTURETYPE_TEXTURE;
texture->patchcount = 1;
texture->holes = false;
texture->flip = 0;
@ -1453,7 +1453,7 @@ static void R_FinishLoadingTextures(INT32 add)
HWR_LoadMapTextures(numtextures);
#endif
g_texturenum_dbgline = R_CheckTextureNumForName("DBGLINE");
g_texturenum_dbgline = R_CheckTextureNumForName("DBGLINE", TEXTURETYPE_TEXTURE);
}
//
@ -1802,7 +1802,7 @@ static texture_t *R_ParseTexture(boolean actuallyLoadTexture)
resultTexture->hash = quickncasehash(newTextureName, 8);
resultTexture->width = newTextureWidth;
resultTexture->height = newTextureHeight;
resultTexture->type = TEXTURETYPE_COMPOSITE;
resultTexture->type = TEXTURETYPE_TEXTURE;
resultTexture->terrainID = K_GetTerrainIDForTextureName(newTextureName);
}
Z_Free(texturesToken);
@ -2003,7 +2003,7 @@ static void AddTextureToCache(const char *name, UINT32 hash, INT32 id, UINT8 typ
//
// 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;
UINT32 hash;
@ -2017,13 +2017,13 @@ INT32 R_CheckTextureNumForName(const char *name)
hash = quickncasehash(name, 8);
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;
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;
}
@ -2033,19 +2033,26 @@ INT32 R_CheckTextureNumForName(const char *name)
//
// R_TextureNumForName
//
// Calls R_CheckTextureNumForName, aborts with error message.
// Calls R_CheckTextureNumForName. Returns REDWALL if not found.
//
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)
{
static INT32 redwall = -2;
CONS_Debug(DBG_SETUP, "WARNING: R_TextureNumForName: %.8s not found\n", name);
if (redwall == -2)
{
redwall = R_CheckTextureNumForName(MISSING_TEXTURE);
redwall = R_CheckTextureNumForName(MISSING_TEXTURE, TEXTURETYPE_TEXTURE);
if (redwall <= 256)
// see P_SetBinaryFOFAlpha
I_Error(MISSING_TEXTURE " resolved to ID <= 256. Shit's fucked man");
@ -2054,33 +2061,6 @@ INT32 R_TextureNumForName(const char *name)
return redwall;
return 1;
}
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;
PaletteTextureHack(&name);
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;
}

View file

@ -24,7 +24,7 @@ extern "C" {
#endif
#define MISSING_TEXTURE "MISSTEX" // Replacement for invalid textures
// A single patch from a texture definition,
// basically a rectangular area within
// the texture rectangle.
@ -42,9 +42,8 @@ struct texpatch_t
enum
{
TEXTURETYPE_UNKNOWN,
TEXTURETYPE_SINGLEPATCH,
TEXTURETYPE_COMPOSITE,
TEXTURETYPE_FLAT,
TEXTURETYPE_TEXTURE,
TEXTURETYPE_FLAT
};
// A texture_t describes a rectangular texture,
@ -109,8 +108,7 @@ void R_UpdateTextureBrightmap(INT32 tx, INT32 bm);
// Returns the texture number for the texture name.
INT32 R_TextureNumForName(const char *name);
INT32 R_CheckTextureNumForName(const char *name);
INT32 R_CheckFlatNumForName(const char *name);
INT32 R_CheckTextureNumForName(const char *name, UINT8 type);
extern INT32 numtextures;