From 91e88690e42957335f9aa19448b405f36fa58bb9 Mon Sep 17 00:00:00 2001 From: NepDisk <16447892+NepDisk@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:38:54 -0400 Subject: [PATCH] Revert "Stuff for Ivo's texture crunching" This reverts commit 60f65f3998b5ca3b9216cc7d2fc0eb2b4d6c4f2b. --- src/p_setup.c | 60 +++++++++++++++++++++++++++++++++++++----------- src/r_textures.h | 5 ---- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 7bf370d5b..9249e1202 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -624,23 +624,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.h b/src/r_textures.h index 3011d11a1..8e24d276c 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -23,13 +23,8 @@ #pragma interface #endif -<<<<<<< HEAD #define MISSING_TEXTURE "MISSTEX" // Replacement for invalid textures -======= -#define MISSING_TEXTURE "AASMELLY" // Replacement for invalid textures - ->>>>>>> 559222f991 (Stuff for Ivo's texture crunching) // A single patch from a texture definition, // basically a rectangular area within // the texture rectangle.