diff --git a/src/r_data.cpp b/src/r_data.cpp index 0be54a8ad..ee40e29ca 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -421,80 +421,15 @@ void R_DeinitData () void R_PrecacheLevel (void) { BYTE *hitlist; - BYTE *spritelist; - int i; if (demoplayback) return; hitlist = new BYTE[TexMan.NumTextures()]; - spritelist = new BYTE[sprites.Size()]; - - // Precache textures (and sprites). memset (hitlist, 0, TexMan.NumTextures()); - memset (spritelist, 0, sprites.Size()); - { - AActor *actor; - TThinkerIterator iterator; - - while ( (actor = iterator.Next ()) ) - spritelist[actor->sprite] = 1; - } - - for (i = (int)(sprites.Size () - 1); i >= 0; i--) - { - if (spritelist[i]) - { - int j, k; - for (j = 0; j < sprites[i].numframes; j++) - { - const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j]; - - for (k = 0; k < 16; k++) - { - FTextureID pic = frame->Texture[k]; - if (pic.isValid()) - { - hitlist[pic.GetIndex()] = 1; - } - } - } - } - } - - delete[] spritelist; - - for (i = numsectors - 1; i >= 0; i--) - { - hitlist[sectors[i].GetTexture(sector_t::floor).GetIndex()] = - hitlist[sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= 2; - } - - for (i = numsides - 1; i >= 0; i--) - { - hitlist[sides[i].GetTexture(side_t::top).GetIndex()] = - hitlist[sides[i].GetTexture(side_t::mid).GetIndex()] = - hitlist[sides[i].GetTexture(side_t::bottom).GetIndex()] |= 1; - } - - // Sky texture is always present. - // Note that F_SKY1 is the name used to - // indicate a sky floor/ceiling as a flat, - // while the sky texture is stored like - // a wall texture, with an episode dependant - // name. - - if (sky1texture.isValid()) - { - hitlist[sky1texture.GetIndex()] |= 1; - } - if (sky2texture.isValid()) - { - hitlist[sky2texture.GetIndex()] |= 1; - } - - for (i = TexMan.NumTextures() - 1; i >= 0; i--) + screen->GetHitlist(hitlist); + for (int i = TexMan.NumTextures() - 1; i >= 0; i--) { screen->PrecacheTexture(TexMan.ByIndex(i), hitlist[i]); } @@ -502,6 +437,8 @@ void R_PrecacheLevel (void) delete[] hitlist; } + + //========================================================================== // // R_GetColumn diff --git a/src/v_video.cpp b/src/v_video.cpp index 24ed1a562..2327529be 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -62,6 +62,7 @@ #include "m_png.h" #include "colormatcher.h" #include "v_palette.h" +#include "r_sky.h" IMPLEMENT_ABSTRACT_CLASS (DCanvas) @@ -1196,6 +1197,83 @@ void DFrameBuffer::WipeCleanup() wipe_Cleanup(); } +//=========================================================================== +// +// Create texture hitlist +// +//=========================================================================== + +void DFrameBuffer::GetHitlist(BYTE *hitlist) +{ + BYTE *spritelist; + int i; + + spritelist = new BYTE[sprites.Size()]; + + // Precache textures (and sprites). + memset (spritelist, 0, sprites.Size()); + + { + AActor *actor; + TThinkerIterator iterator; + + while ( (actor = iterator.Next ()) ) + spritelist[actor->sprite] = 1; + } + + for (i = (int)(sprites.Size () - 1); i >= 0; i--) + { + if (spritelist[i]) + { + int j, k; + for (j = 0; j < sprites[i].numframes; j++) + { + const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j]; + + for (k = 0; k < 16; k++) + { + FTextureID pic = frame->Texture[k]; + if (pic.isValid()) + { + hitlist[pic.GetIndex()] = 1; + } + } + } + } + } + + delete[] spritelist; + + for (i = numsectors - 1; i >= 0; i--) + { + hitlist[sectors[i].GetTexture(sector_t::floor).GetIndex()] = + hitlist[sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= 2; + } + + for (i = numsides - 1; i >= 0; i--) + { + hitlist[sides[i].GetTexture(side_t::top).GetIndex()] = + hitlist[sides[i].GetTexture(side_t::mid).GetIndex()] = + hitlist[sides[i].GetTexture(side_t::bottom).GetIndex()] |= 1; + } + + // Sky texture is always present. + // Note that F_SKY1 is the name used to + // indicate a sky floor/ceiling as a flat, + // while the sky texture is stored like + // a wall texture, with an episode dependant + // name. + + if (sky1texture.isValid()) + { + hitlist[sky1texture.GetIndex()] |= 1; + } + if (sky2texture.isValid()) + { + hitlist[sky2texture.GetIndex()] |= 1; + } +} + //=========================================================================== // // Texture precaching diff --git a/src/v_video.h b/src/v_video.h index 6beaeea7b..77a3f8a65 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -398,6 +398,7 @@ public: virtual FNativePalette *CreatePalette(FRemapTable *remap); // Precaches or unloads a texture + virtual void GetHitlist(BYTE *hitlist); virtual void PrecacheTexture(FTexture *tex, int cache); // Screen wiping