From a403d96204e2f292c34871487c88ce01474044cf Mon Sep 17 00:00:00 2001 From: Alug Date: Sat, 15 Feb 2025 14:27:52 +0100 Subject: [PATCH] also precache animated flats i have no clue how tf animated textures work --- src/hardware/hw_cache.c | 34 +++++++++++++++++++++++++++++----- src/p_setup.c | 2 ++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/hardware/hw_cache.c b/src/hardware/hw_cache.c index 186b00c6d..5a7cd8b33 100644 --- a/src/hardware/hw_cache.c +++ b/src/hardware/hw_cache.c @@ -550,14 +550,14 @@ void HWR_FreeTextureCache(void) static void HWR_PrecacheLevelFlats(void) { + levelflat_t levelflat; lumpnum_t lump; size_t i, j; + INT32 k; // special case for encore remapping if (encoremode) { - // this does not account for fofs and polyobjects - // TODO: handle atleast fofs for (i = 0; i < numsectors; i++) { for (j = 0; j < 2; j++) @@ -565,8 +565,20 @@ static void HWR_PrecacheLevelFlats(void) boolean ceiling = (j == 1); INT32 pic = ceiling ? sectors[i].ceilingpic : sectors[i].floorpic; - lump = levelflats[pic].lumpnum; + levelflat = levelflats[pic]; + + lump = levelflat.lumpnum; HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + + if (levelflat.speed) // it is an animated flat + { + for (k = 0; k < levelflat.numpics; k++) + { + levelflat.lumpnum = levelflat.baselumpnum + k; + lump = levelflat.lumpnum; + HWR_GetFlat(lump, R_NoEncore(§ors[i], ceiling)); + } + } } } } @@ -576,8 +588,20 @@ static void HWR_PrecacheLevelFlats(void) // just load every flat for (i = 0; i < numlevelflats; i++) { - lump = levelflats[i].lumpnum; + levelflat = levelflats[i]; + lump = levelflat.lumpnum; + HWR_GetFlat(lump, false); + + if (levelflat.speed) // it is an animated flat + { + for (k = 0; k < levelflat.numpics; k++) + { + levelflat.lumpnum = levelflat.baselumpnum + k; + lump = levelflat.lumpnum; + HWR_GetFlat(lump, false); + } + } } } } @@ -661,7 +685,7 @@ static void HWR_PrecacheLevelSprites(void) mo = (mobj_t *)th; - //FIXME: cant really precache colorized sprites without a colormap + // ogl is weird if (mo->color || mo->colorized) continue; diff --git a/src/p_setup.c b/src/p_setup.c index ff4b5384d..92abf44b6 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -624,6 +624,7 @@ INT32 P_AddLevelFlat(const char *flatname, levelflat_t *levelflat) // store the flat lump number levelflat->lumpnum = R_GetFlatNumForName(flatname); + levelflat->baselumpnum = LUMPERROR; #ifndef ZDEBUG CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name); @@ -668,6 +669,7 @@ INT32 P_AddLevelFlatRuntime(const char *flatname) // store the flat lump number levelflat->lumpnum = R_GetFlatNumForName(flatname); + levelflat->baselumpnum = LUMPERROR; #ifndef ZDEBUG CONS_Debug(DBG_SETUP, "flat #%03d: %s\n", atoi(sizeu1(numlevelflats)), levelflat->name);