From 60d0102d7e63f8beb98fed2ab268ac054bee671f Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Mon, 29 Jul 2024 15:41:51 -0400 Subject: [PATCH] Revert "Stuff for Ivo's texture crunching" This reverts commit 559222f9915f9a2be7615641ddb309f51368a605. --- src/p_setup.c | 60 +++++++++++++++++++++++++++++++++++++----------- src/r_textures.c | 2 +- src/r_textures.h | 2 -- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 8a14b5692..66010552d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -607,23 +607,57 @@ Ploadflat (levelflat_t *levelflat, const char *flatname, boolean resize) strlcpy(levelflat->name, flatname, sizeof (levelflat->name)); strupr(levelflat->name); - if (( texturenum = R_CheckTextureNumForName(levelflat->name) ) == -1) + /* If we can't find a flat, try looking for a texture! */ + if (( flatnum = R_GetFlatNumForName(levelflat->name) ) == LUMPERROR) { - // check for missing texture - if (( texturenum = R_CheckTextureNumForName(MISSING_TEXTURE) ) != -1) - goto texturefound; - - // nevermind - levelflat->type = LEVELFLAT_NONE; + if (( texturenum = R_CheckTextureNumForName(levelflat->name) ) == -1) + { + // check for REDWALL + if (( texturenum = R_CheckTextureNumForName("REDWALL") ) != -1) + goto texturefound; + // check for REDFLR + else if (( flatnum = R_GetFlatNumForName("REDFLR") ) != LUMPERROR) + goto flatfound; + // nevermind + levelflat->type = LEVELFLAT_NONE; + } + else + { +texturefound: + levelflat->type = LEVELFLAT_TEXTURE; + levelflat->u.texture. num = texturenum; + levelflat->u.texture.lastnum = texturenum; + /* start out unanimated */ + levelflat->u.texture.basenum = -1; + } } else { -texturefound: - levelflat->type = LEVELFLAT_TEXTURE; - levelflat->u.texture. num = texturenum; - levelflat->u.texture.lastnum = texturenum; - /* start out unanimated */ - levelflat->u.texture.basenum = -1; +flatfound: + /* This could be a flat, patch, or PNG. */ + flatpatch = W_CacheLumpNum(flatnum, PU_CACHE); + lumplength = W_LumpLength(flatnum); + if (Picture_CheckIfDoomPatch((softwarepatch_t *)flatpatch, lumplength)) + levelflat->type = LEVELFLAT_PATCH; + else + { +#ifndef NO_PNG_LUMPS + /* + Only need eight bytes for PNG headers. + FIXME: Put this elsewhere. + */ + W_ReadLumpHeader(flatnum, buffer, 8, 0); + if (Picture_IsLumpPNG(buffer, lumplength)) + levelflat->type = LEVELFLAT_PNG; + else +#endif/*NO_PNG_LUMPS*/ + levelflat->type = LEVELFLAT_FLAT;/* phew */ + } + if (flatpatch) + Z_Free(flatpatch); + + levelflat->u.flat. lumpnum = flatnum; + levelflat->u.flat.baselumpnum = LUMPERROR; } levelflat->terrain = diff --git a/src/r_textures.c b/src/r_textures.c index 39976a3c8..d04935b3e 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -1712,7 +1712,7 @@ INT32 R_TextureNumForName(const char *name) 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("REDWALL"); if (redwall != -1) return redwall; return 1; diff --git a/src/r_textures.h b/src/r_textures.h index d4c9302e5..007da38ac 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -23,8 +23,6 @@ #pragma interface #endif -#define MISSING_TEXTURE "AASMELLY" // Replacement for invalid textures - // A single patch from a texture definition, // basically a rectangular area within // the texture rectangle.