diff --git a/source/blood/src/blood.cpp b/source/blood/src/blood.cpp index b7dd92b85..c9f2a5505 100644 --- a/source/blood/src/blood.cpp +++ b/source/blood/src/blood.cpp @@ -43,6 +43,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "eventq.h" #include "fire.h" #include "fx.h" +#include "gib.h" #include "getopt.h" #include "globals.h" #include "levels.h" @@ -291,14 +292,8 @@ void PrecacheThing(spritetype *pSprite) { case kThingObjectGib: //case kThingObjectExplode: weird that only gib object is precached and this one is not break; - default: - tilePreloadTile(pSprite->picnum); - break; } - seqPrecacheId(3); - seqPrecacheId(4); - seqPrecacheId(5); - seqPrecacheId(9); + tilePrecacheTile(pSprite->picnum); } void PreloadTiles(void) @@ -345,25 +340,40 @@ void PreloadTiles(void) } } } - if (numplayers > 1) + + // Precache common SEQs + for (int i = 0; i < 100; i++) { - seqPrecacheId(dudeInfo[31].seqStartID+6); - seqPrecacheId(dudeInfo[31].seqStartID+7); - seqPrecacheId(dudeInfo[31].seqStartID+8); - seqPrecacheId(dudeInfo[31].seqStartID+9); - seqPrecacheId(dudeInfo[31].seqStartID+10); - seqPrecacheId(dudeInfo[31].seqStartID+14); - seqPrecacheId(dudeInfo[31].seqStartID+15); - seqPrecacheId(dudeInfo[31].seqStartID+12); - seqPrecacheId(dudeInfo[31].seqStartID+16); - seqPrecacheId(dudeInfo[31].seqStartID+17); - seqPrecacheId(dudeInfo[31].seqStartID+18); + seqPrecacheId(i); } + + tilePrecacheTile(1147); // water drip + tilePrecacheTile(1160); // blood drip + + // Player SEQs + seqPrecacheId(dudeInfo[31].seqStartID+6); + seqPrecacheId(dudeInfo[31].seqStartID+7); + seqPrecacheId(dudeInfo[31].seqStartID+8); + seqPrecacheId(dudeInfo[31].seqStartID+9); + seqPrecacheId(dudeInfo[31].seqStartID+10); + seqPrecacheId(dudeInfo[31].seqStartID+14); + seqPrecacheId(dudeInfo[31].seqStartID+15); + seqPrecacheId(dudeInfo[31].seqStartID+12); + seqPrecacheId(dudeInfo[31].seqStartID+16); + seqPrecacheId(dudeInfo[31].seqStartID+17); + seqPrecacheId(dudeInfo[31].seqStartID+18); + if (skyTile > -1 && skyTile < kMaxTiles) { for (int i = 1; i < gSkyCount; i++) tilePrecacheTile(skyTile+i, 0); } + + WeaponPrecache(); + viewPrecacheTiles(); + fxPrecache(); + gibPrecache(); + gameHandleEvents(); } diff --git a/source/blood/src/fx.cpp b/source/blood/src/fx.cpp index 04ccfc00a..6fbcbca21 100644 --- a/source/blood/src/fx.cpp +++ b/source/blood/src/fx.cpp @@ -36,6 +36,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gameutil.h" #include "levels.h" #include "seq.h" +#include "tile.h" #include "trig.h" #include "view.h" @@ -355,4 +356,14 @@ void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4) } } +void fxPrecache(void) +{ + for (int i = 0; i < kFXMax; i++) + { + tilePrecacheTile(gFXData[i].at12, 0); + if (gFXData[i].at2) + seqPrecacheId(gFXData[i].at2); + } +} + END_BLD_NS diff --git a/source/blood/src/fx.h b/source/blood/src/fx.h index 8104fffc0..6c9a70f8f 100644 --- a/source/blood/src/fx.h +++ b/source/blood/src/fx.h @@ -102,6 +102,8 @@ void sub_746D4(spritetype *pSprite, int a2); void fxSpawnEjectingBrass(spritetype *pSprite, int z, int a3, int a4); void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4); +void fxPrecache(void); + extern CFX gFX; END_BLD_NS diff --git a/source/blood/src/gib.cpp b/source/blood/src/gib.cpp index b2751894f..e3201a5b7 100644 --- a/source/blood/src/gib.cpp +++ b/source/blood/src/gib.cpp @@ -37,6 +37,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "gib.h" #include "levels.h" #include "sfx.h" +#include "tile.h" #include "trig.h" BEGIN_BLD_NS @@ -512,4 +513,18 @@ void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel) } } -END_BLD_NS +void gibPrecache(void) +{ + for (int i = 0; i < kGibMax; i++) + { + auto const pThing = gibList[i].at8; + if (pThing) + { + for (int j = 0; j < gibList[i].atc; j++) + { + if (pThing[j].at4 >= 0) + tilePrecacheTile(pThing[j].at4); + } + } + } +} diff --git a/source/blood/src/gib.h b/source/blood/src/gib.h index 957db5fa1..d5fc5cb66 100644 --- a/source/blood/src/gib.h +++ b/source/blood/src/gib.h @@ -74,5 +74,5 @@ public: void GibSprite(spritetype *pSprite, GIBTYPE nGibType, CGibPosition *pPos, CGibVelocity *pVel); //void GibFX(int nWall, GIBFX * pGFX, int a3, int a4, int a5, int a6, CGibVelocity * pVel); void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel); +void gibPrecache(void); -END_BLD_NS diff --git a/source/blood/src/qav.cpp b/source/blood/src/qav.cpp index 9455289eb..50c0a3bd4 100644 --- a/source/blood/src/qav.cpp +++ b/source/blood/src/qav.cpp @@ -145,4 +145,14 @@ void QAV::Preload(void) } } -END_BLD_NS +void QAV::Precache(void) +{ + for (int i = 0; i < nFrames; i++) + { + for (int j = 0; j < 8; j++) + { + if (frames[i].tiles[j].picnum >= 0) + tilePrecacheTile(frames[i].tiles[j].picnum, 0); + } + } +} \ No newline at end of file diff --git a/source/blood/src/qav.h b/source/blood/src/qav.h index e52394c74..3d08430c7 100644 --- a/source/blood/src/qav.h +++ b/source/blood/src/qav.h @@ -82,6 +82,7 @@ struct QAV void Draw(int ticks, int stat, int shade, int palnum); void Play(int, int, int, void *); void Preload(void); + void Precache(void); void PlaySound(int nSound); void PlaySound3D(spritetype *pSprite, int nSound, int a3, int a4); diff --git a/source/blood/src/tile.cpp b/source/blood/src/tile.cpp index cfb857af2..bb9cc3b93 100644 --- a/source/blood/src/tile.cpp +++ b/source/blood/src/tile.cpp @@ -156,7 +156,7 @@ uint8_t * tileAllocTile(int nTile, int x, int y, int ox, int oy) void tilePreloadTile(int nTile) { - int n = 0; + int n = 1; switch (picanm[nTile].extra&7) { case 0: @@ -205,7 +205,7 @@ char precachehightile[2][(MAXTILES+7)>>3]; void tilePrecacheTile(int nTile, int nType) { - int n = 0; + int n = 1; switch (picanm[nTile].extra&7) { case 0: diff --git a/source/blood/src/view.cpp b/source/blood/src/view.cpp index c9149d650..61b76543a 100644 --- a/source/blood/src/view.cpp +++ b/source/blood/src/view.cpp @@ -1715,6 +1715,47 @@ void UpdateStatusBar(ClockTicks arg) } } +void viewPrecacheTiles(void) +{ + tilePrecacheTile(2173, 0); + tilePrecacheTile(2200, 0); + tilePrecacheTile(2201, 0); + tilePrecacheTile(2202, 0); + tilePrecacheTile(2207, 0); + tilePrecacheTile(2208, 0); + tilePrecacheTile(2209, 0); + tilePrecacheTile(2229, 0); + tilePrecacheTile(2260, 0); + tilePrecacheTile(2559, 0); + tilePrecacheTile(2169, 0); + tilePrecacheTile(2578, 0); + tilePrecacheTile(2586, 0); + tilePrecacheTile(2602, 0); + for (int i = 0; i < 10; i++) + { + tilePrecacheTile(2190 + i, 0); + tilePrecacheTile(2230 + i, 0); + tilePrecacheTile(2240 + i, 0); + tilePrecacheTile(2250 + i, 0); + tilePrecacheTile(kSBarNumberHealth + i, 0); + tilePrecacheTile(kSBarNumberAmmo + i, 0); + tilePrecacheTile(kSBarNumberInv + i, 0); + tilePrecacheTile(kSBarNumberArmor1 + i, 0); + tilePrecacheTile(kSBarNumberArmor2 + i, 0); + tilePrecacheTile(kSBarNumberArmor3 + i, 0); + } + for (int i = 0; i < 5; i++) + { + tilePrecacheTile(gPackIcons[i], 0); + tilePrecacheTile(gPackIcons2[i].nTile, 0); + } + for (int i = 0; i < 6; i++) + { + tilePrecacheTile(2220 + i, 0); + tilePrecacheTile(2552 + i, 0); + } +} + int *lensTable; int gZoom = 1024; diff --git a/source/blood/src/view.h b/source/blood/src/view.h index 04e73baf6..adcae4f9c 100644 --- a/source/blood/src/view.h +++ b/source/blood/src/view.h @@ -153,6 +153,7 @@ void viewUpdateShake(void); void viewSetCrosshairColor(int32_t r, int32_t g, int32_t b); void viewResetCrosshairToDefault(void); void viewSetSystemMessage(const char* pMessage, ...); +void viewPrecacheTiles(void); inline void viewInterpolateSector(int nSector, sectortype *pSector) { diff --git a/source/blood/src/weapon.cpp b/source/blood/src/weapon.cpp index efee1e5a2..45ebce1d8 100644 --- a/source/blood/src/weapon.cpp +++ b/source/blood/src/weapon.cpp @@ -228,6 +228,15 @@ void WeaponInit(void) } } +void WeaponPrecache(void) +{ + for (int i = 0; i < kQAVEnd; i++) + { + if (weaponQAV[i]) + weaponQAV[i]->Precache(); + } +} + void WeaponDraw(PLAYER *pPlayer, int a2, int a3, int a4, int a5) { dassert(pPlayer != NULL); diff --git a/source/blood/src/weapon.h b/source/blood/src/weapon.h index 147261900..0097c59d4 100644 --- a/source/blood/src/weapon.h +++ b/source/blood/src/weapon.h @@ -40,4 +40,5 @@ void WeaponProcess(PLAYER *pPlayer); void WeaponUpdateState(PLAYER* pPlayer); void sub_51340(spritetype *pMissile, int a2); void StartQAV(PLAYER* pPlayer, int nWeaponQAV, int a3 = -1, char a4 = 0); +void WeaponPrecache(void); END_BLD_NS