- use a local bit array in Blood's precacher.

This commit is contained in:
Christoph Oelckers 2020-09-08 19:18:11 +02:00
parent 298949ceb8
commit 5d7a51df9d
12 changed files with 236 additions and 231 deletions

View file

@ -354,13 +354,13 @@ void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4)
} }
} }
void fxPrecache(void) void fxPrecache(HitList &hits)
{ {
for (int i = 0; i < kFXMax; i++) for (int i = 0; i < kFXMax; i++)
{ {
tilePrecacheTile(gFXData[i].at12, 0); tilePrecacheTile(gFXData[i].at12, 0, hits);
if (gFXData[i].at2) if (gFXData[i].at2)
seqPrecacheId(gFXData[i].at2); seqPrecacheId(gFXData[i].at2, hits);
} }
} }

View file

@ -102,8 +102,6 @@ void sub_746D4(spritetype *pSprite, int a2);
void fxSpawnEjectingBrass(spritetype *pSprite, int z, int a3, int a4); void fxSpawnEjectingBrass(spritetype *pSprite, int z, int a3, int a4);
void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4); void fxSpawnEjectingShell(spritetype *pSprite, int z, int a3, int a4);
void fxPrecache(void);
extern CFX gFX; extern CFX gFX;
END_BLD_NS END_BLD_NS

View file

@ -511,7 +511,7 @@ void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel)
} }
} }
void gibPrecache(void) void gibPrecache(HitList &hits)
{ {
for (int i = 0; i < kGibMax; i++) for (int i = 0; i < kGibMax; i++)
{ {
@ -521,7 +521,7 @@ void gibPrecache(void)
for (int j = 0; j < gibList[i].atc; j++) for (int j = 0; j < gibList[i].atc; j++)
{ {
if (pThing[j].Kills >= 0) if (pThing[j].Kills >= 0)
tilePrecacheTile(pThing[j].Kills); tilePrecacheTile(pThing[j].Kills, -1, hits);
} }
} }
} }

View file

@ -74,5 +74,4 @@ public:
void GibSprite(spritetype *pSprite, GIBTYPE nGibType, CGibPosition *pPos, CGibVelocity *pVel); 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 GibFX(int nWall, GIBFX * pGFX, int a3, int a4, int a5, int a6, CGibVelocity * pVel);
void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel); void GibWall(int nWall, GIBTYPE nGibType, CGibVelocity *pVel);
void gibPrecache(void);
END_BLD_NS END_BLD_NS

View file

@ -22,11 +22,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#pragma once #pragma once
#include "build.h"
#include "m_fixed.h" #include "m_fixed.h"
#include "filesystem.h" #include "filesystem.h"
BEGIN_BLD_NS BEGIN_BLD_NS
using HitList = FixedBitArray<MAXTILES>;
void playlogos(); void playlogos();
unsigned int qrand(void); unsigned int qrand(void);
int wrand(void); int wrand(void);
@ -56,7 +59,7 @@ void WeaponProcess(PLAYER *pPlayer);
void WeaponUpdateState(PLAYER* pPlayer); void WeaponUpdateState(PLAYER* pPlayer);
void sub_51340(spritetype *pMissile, int a2); void sub_51340(spritetype *pMissile, int a2);
void StartQAV(PLAYER* pPlayer, int nWeaponQAV, int a3 = -1, char a4 = 0); void StartQAV(PLAYER* pPlayer, int nWeaponQAV, int a3 = -1, char a4 = 0);
void WeaponPrecache(void); void WeaponPrecache(HitList &hits);
struct ZONE { struct ZONE {
int x, y, z; int x, y, z;
@ -121,13 +124,12 @@ extern signed char tileShade[MAXTILES];
extern short voxelIndex[MAXTILES]; extern short voxelIndex[MAXTILES];
extern int nPrecacheCount; extern int nPrecacheCount;
extern char precachehightile[2][(MAXTILES+7)>>3];
int tileInit(char a1, const char *a2); int tileInit(char a1, const char *a2);
void tileProcessGLVoxels(void); void tileProcessGLVoxels(void);
void tilePreloadTile(int nTile); void tilePreloadTile(int nTile);
void tilePrecacheTile(int nTile, int nType, HitList& hits);
void tilePrecacheTile(int nTile, int nType = 1);
char tileGetSurfType(int hit); char tileGetSurfType(int hit);
void scrLoadPalette(void); void scrLoadPalette(void);

View file

@ -33,36 +33,139 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
BEGIN_BLD_NS BEGIN_BLD_NS
#define gotpic blafasl
int nPrecacheCount;
void fxPrecache(HitList &hits);
void gibPrecache(HitList &hits);
void tilePreloadTile(int nTile)
{
if (!r_precache) return;
int n = 1;
switch (picanm[nTile].extra & 7)
{
case 0:
n = 1;
break;
case 1:
n = 5;
break;
case 2:
n = 8;
break;
case 3:
n = 2;
break;
case 6:
case 7:
if (voxelIndex[nTile] < 0 || voxelIndex[nTile] >= kMaxVoxels)
{
voxelIndex[nTile] = -1;
picanm[nTile].extra &= ~7;
}
break;
}
while (n--)
{
if (picanm[nTile].sf & PICANM_ANIMTYPE_MASK)
{
for (int frame = picanm[nTile].num; frame >= 0; frame--)
{
if ((picanm[nTile].sf & PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK)
PrecacheHardwareTextures(nTile - frame);
else
PrecacheHardwareTextures(nTile + frame);
}
}
else
PrecacheHardwareTextures(nTile);
nTile += 1 + picanm[nTile].num;
}
}
void tilePrecacheTile(int nTile, int nType, HitList &hits)
{
int n = 1;
switch (picanm[nTile].extra & 7)
{
case 0:
n = 1;
break;
case 1:
n = 5;
break;
case 2:
n = 8;
break;
case 3:
n = 2;
break;
}
while (n--)
{
if (picanm[nTile].sf & PICANM_ANIMTYPE_MASK)
{
for (int frame = picanm[nTile].num; frame >= 0; frame--)
{
int tile;
if ((picanm[nTile].sf & PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK)
tile = nTile - frame;
else
tile = nTile + frame;
if (!hits[tile])
{
nPrecacheCount++;
hits.Set(tile);
}
}
}
else
{
if (!hits[nTile])
{
nPrecacheCount++;
hits.Set(nTile);
}
}
nTile += 1 + picanm[nTile].num;
}
}
// To do: This needs to handle the sprite palettes as well to properly precache the needed content. // To do: This needs to handle the sprite palettes as well to properly precache the needed content.
void viewPrecacheTiles(void) void viewPrecacheTiles(HitList &hits)
{ {
tilePrecacheTile(2173, 0); tilePrecacheTile(2173, 0, hits);
tilePrecacheTile(2200, 0); tilePrecacheTile(2200, 0, hits);
tilePrecacheTile(2201, 0); tilePrecacheTile(2201, 0, hits);
tilePrecacheTile(2202, 0); tilePrecacheTile(2202, 0, hits);
tilePrecacheTile(2207, 0); tilePrecacheTile(2207, 0, hits);
tilePrecacheTile(2208, 0); tilePrecacheTile(2208, 0, hits);
tilePrecacheTile(2209, 0); tilePrecacheTile(2209, 0, hits);
tilePrecacheTile(2229, 0); tilePrecacheTile(2229, 0, hits);
tilePrecacheTile(2260, 0); tilePrecacheTile(2260, 0, hits);
tilePrecacheTile(2559, 0); tilePrecacheTile(2559, 0, hits);
tilePrecacheTile(2169, 0); tilePrecacheTile(2169, 0, hits);
tilePrecacheTile(2578, 0); tilePrecacheTile(2578, 0, hits);
tilePrecacheTile(2586, 0); tilePrecacheTile(2586, 0, hits);
tilePrecacheTile(2602, 0); tilePrecacheTile(2602, 0, hits);
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
tilePrecacheTile(2190 + i, 0); tilePrecacheTile(2190 + i, 0, hits);
tilePrecacheTile(2230 + i, 0); tilePrecacheTile(2230 + i, 0, hits);
tilePrecacheTile(2240 + i, 0); tilePrecacheTile(2240 + i, 0, hits);
tilePrecacheTile(2250 + i, 0); tilePrecacheTile(2250 + i, 0, hits);
tilePrecacheTile(kSBarNumberHealth + i, 0); tilePrecacheTile(kSBarNumberHealth + i, 0, hits);
tilePrecacheTile(kSBarNumberAmmo + i, 0); tilePrecacheTile(kSBarNumberAmmo + i, 0, hits);
tilePrecacheTile(kSBarNumberInv + i, 0); tilePrecacheTile(kSBarNumberInv + i, 0, hits);
tilePrecacheTile(kSBarNumberArmor1 + i, 0); tilePrecacheTile(kSBarNumberArmor1 + i, 0, hits);
tilePrecacheTile(kSBarNumberArmor2 + i, 0); tilePrecacheTile(kSBarNumberArmor2 + i, 0, hits);
tilePrecacheTile(kSBarNumberArmor3 + i, 0); tilePrecacheTile(kSBarNumberArmor3 + i, 0, hits);
} }
/* /*
for (int i = 0; i < 5; i++) for (int i = 0; i < 5; i++)
@ -73,54 +176,54 @@ void viewPrecacheTiles(void)
*/ */
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
tilePrecacheTile(2220 + i, 0); tilePrecacheTile(2220 + i, 0, hits);
tilePrecacheTile(2552 + i, 0); tilePrecacheTile(2552 + i, 0, hits);
} }
} }
void PrecacheDude(spritetype *pSprite) void PrecacheDude(spritetype *pSprite, HitList &hits)
{ {
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type); DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
seqPrecacheId(pDudeInfo->seqStartID); seqPrecacheId(pDudeInfo->seqStartID , hits);
seqPrecacheId(pDudeInfo->seqStartID+5); seqPrecacheId(pDudeInfo->seqStartID+5, hits);
seqPrecacheId(pDudeInfo->seqStartID+1); seqPrecacheId(pDudeInfo->seqStartID+1, hits);
seqPrecacheId(pDudeInfo->seqStartID+2); seqPrecacheId(pDudeInfo->seqStartID+2, hits);
switch (pSprite->type) switch (pSprite->type)
{ {
case kDudeCultistTommy: case kDudeCultistTommy:
case kDudeCultistShotgun: case kDudeCultistShotgun:
case kDudeCultistTesla: case kDudeCultistTesla:
case kDudeCultistTNT: case kDudeCultistTNT:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6 , hits);
seqPrecacheId(pDudeInfo->seqStartID+7); seqPrecacheId(pDudeInfo->seqStartID+7 , hits);
seqPrecacheId(pDudeInfo->seqStartID+8); seqPrecacheId(pDudeInfo->seqStartID+8 , hits);
seqPrecacheId(pDudeInfo->seqStartID+9); seqPrecacheId(pDudeInfo->seqStartID+9 , hits);
seqPrecacheId(pDudeInfo->seqStartID+13); seqPrecacheId(pDudeInfo->seqStartID+13, hits);
seqPrecacheId(pDudeInfo->seqStartID+14); seqPrecacheId(pDudeInfo->seqStartID+14, hits);
seqPrecacheId(pDudeInfo->seqStartID+15); seqPrecacheId(pDudeInfo->seqStartID+15, hits);
break; break;
case kDudeZombieButcher: case kDudeZombieButcher:
case kDudeGillBeast: case kDudeGillBeast:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
seqPrecacheId(pDudeInfo->seqStartID+7); seqPrecacheId(pDudeInfo->seqStartID+7, hits);
seqPrecacheId(pDudeInfo->seqStartID+8); seqPrecacheId(pDudeInfo->seqStartID+8, hits);
seqPrecacheId(pDudeInfo->seqStartID+9); seqPrecacheId(pDudeInfo->seqStartID+9, hits);
seqPrecacheId(pDudeInfo->seqStartID+10); seqPrecacheId(pDudeInfo->seqStartID+10, hits);
seqPrecacheId(pDudeInfo->seqStartID+11); seqPrecacheId(pDudeInfo->seqStartID+11, hits);
break; break;
case kDudeGargoyleStatueFlesh: case kDudeGargoyleStatueFlesh:
case kDudeGargoyleStatueStone: case kDudeGargoyleStatueStone:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits); //???
fallthrough__; fallthrough__;
case kDudeGargoyleFlesh: case kDudeGargoyleFlesh:
case kDudeGargoyleStone: case kDudeGargoyleStone:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
seqPrecacheId(pDudeInfo->seqStartID+7); seqPrecacheId(pDudeInfo->seqStartID+7, hits);
seqPrecacheId(pDudeInfo->seqStartID+8); seqPrecacheId(pDudeInfo->seqStartID+8, hits);
seqPrecacheId(pDudeInfo->seqStartID+9); seqPrecacheId(pDudeInfo->seqStartID+9, hits);
break; break;
case kDudePhantasm: case kDudePhantasm:
case kDudeHellHound: case kDudeHellHound:
@ -129,88 +232,88 @@ void PrecacheDude(spritetype *pSprite)
case kDudeSpiderBlack: case kDudeSpiderBlack:
case kDudeSpiderMother: case kDudeSpiderMother:
case kDudeTchernobog: case kDudeTchernobog:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
seqPrecacheId(pDudeInfo->seqStartID+7); seqPrecacheId(pDudeInfo->seqStartID+7, hits);
seqPrecacheId(pDudeInfo->seqStartID+8); seqPrecacheId(pDudeInfo->seqStartID+8, hits);
break; break;
case kDudeCerberusTwoHead: case kDudeCerberusTwoHead:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
seqPrecacheId(pDudeInfo->seqStartID+7); seqPrecacheId(pDudeInfo->seqStartID+7, hits);
fallthrough__; fallthrough__;
case kDudeHand: case kDudeHand:
case kDudeBoneEel: case kDudeBoneEel:
case kDudeBat: case kDudeBat:
case kDudeRat: case kDudeRat:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
seqPrecacheId(pDudeInfo->seqStartID+7); seqPrecacheId(pDudeInfo->seqStartID+7, hits);
break; break;
case kDudeCultistBeast: case kDudeCultistBeast:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
break; break;
case kDudeZombieAxeBuried: case kDudeZombieAxeBuried:
seqPrecacheId(pDudeInfo->seqStartID+12); seqPrecacheId(pDudeInfo->seqStartID+12, hits);
seqPrecacheId(pDudeInfo->seqStartID+9); seqPrecacheId(pDudeInfo->seqStartID+9, hits);
fallthrough__; fallthrough__;
case kDudeZombieAxeLaying: case kDudeZombieAxeLaying:
seqPrecacheId(pDudeInfo->seqStartID+10); seqPrecacheId(pDudeInfo->seqStartID+10, hits);
fallthrough__; fallthrough__;
case kDudeZombieAxeNormal: case kDudeZombieAxeNormal:
seqPrecacheId(pDudeInfo->seqStartID+6); seqPrecacheId(pDudeInfo->seqStartID+6, hits);
seqPrecacheId(pDudeInfo->seqStartID+7); seqPrecacheId(pDudeInfo->seqStartID+7, hits);
seqPrecacheId(pDudeInfo->seqStartID+8); seqPrecacheId(pDudeInfo->seqStartID+8, hits);
seqPrecacheId(pDudeInfo->seqStartID+11); seqPrecacheId(pDudeInfo->seqStartID+11, hits);
seqPrecacheId(pDudeInfo->seqStartID+13); seqPrecacheId(pDudeInfo->seqStartID+13, hits);
seqPrecacheId(pDudeInfo->seqStartID+14); seqPrecacheId(pDudeInfo->seqStartID+14, hits);
break; break;
} }
} }
void PrecacheThing(spritetype *pSprite) { void PrecacheThing(spritetype *pSprite, HitList &hits) {
switch (pSprite->type) { switch (pSprite->type) {
case kThingGlassWindow: // worthless... case kThingGlassWindow: // worthless...
case kThingFluorescent: case kThingFluorescent:
seqPrecacheId(12); seqPrecacheId(12, hits);
break; break;
case kThingSpiderWeb: case kThingSpiderWeb:
seqPrecacheId(15); seqPrecacheId(15, hits);
break; break;
case kThingMetalGrate: case kThingMetalGrate:
seqPrecacheId(21); seqPrecacheId(21, hits);
break; break;
case kThingFlammableTree: case kThingFlammableTree:
seqPrecacheId(25); seqPrecacheId(25, hits);
seqPrecacheId(26); seqPrecacheId(26, hits);
break; break;
case kTrapMachinegun: case kTrapMachinegun:
seqPrecacheId(38); seqPrecacheId(38, hits);
seqPrecacheId(40); seqPrecacheId(40, hits);
seqPrecacheId(28); seqPrecacheId(28, hits);
break; break;
case kThingObjectGib: case kThingObjectGib:
//case kThingObjectExplode: weird that only gib object is precached and this one is not //case kThingObjectExplode: weird that only gib object is precached and this one is not
break; break;
} }
tilePrecacheTile(pSprite->picnum); tilePrecacheTile(pSprite->picnum, -1, hits);
} }
void PreloadTiles(void) void PreloadTiles(HitList & hits)
{ {
nPrecacheCount = 0; nPrecacheCount = 0;
int skyTile = -1; int skyTile = -1;
memset(gotpic,0,sizeof(gotpic)); hits.Zero();
// Fonts // Fonts
for (int i = 0; i < numsectors; i++) for (int i = 0; i < numsectors; i++)
{ {
tilePrecacheTile(sector[i].floorpicnum, 0); tilePrecacheTile(sector[i].floorpicnum, 0, hits);
tilePrecacheTile(sector[i].ceilingpicnum, 0); tilePrecacheTile(sector[i].ceilingpicnum, 0, hits);
if ((sector[i].ceilingstat&1) != 0 && skyTile == -1) if ((sector[i].ceilingstat&1) != 0 && skyTile == -1)
skyTile = sector[i].ceilingpicnum; skyTile = sector[i].ceilingpicnum;
} }
for (int i = 0; i < numwalls; i++) for (int i = 0; i < numwalls; i++)
{ {
tilePrecacheTile(wall[i].picnum, 0); tilePrecacheTile(wall[i].picnum, 0, hits);
if (wall[i].overpicnum >= 0) if (wall[i].overpicnum >= 0)
tilePrecacheTile(wall[i].overpicnum, 0); tilePrecacheTile(wall[i].overpicnum, 0, hits);
} }
for (int i = 0; i < kMaxSprites; i++) for (int i = 0; i < kMaxSprites; i++)
{ {
@ -220,13 +323,13 @@ void PreloadTiles(void)
switch (pSprite->statnum) switch (pSprite->statnum)
{ {
case kStatDude: case kStatDude:
PrecacheDude(pSprite); PrecacheDude(pSprite, hits);
break; break;
case kStatThing: case kStatThing:
PrecacheThing(pSprite); PrecacheThing(pSprite, hits);
break; break;
default: default:
tilePrecacheTile(pSprite->picnum); tilePrecacheTile(pSprite->picnum, -1, hits);
break; break;
} }
} }
@ -235,49 +338,50 @@ void PreloadTiles(void)
// Precache common SEQs // Precache common SEQs
for (int i = 0; i < 100; i++) for (int i = 0; i < 100; i++)
{ {
seqPrecacheId(i); seqPrecacheId(i, hits);
} }
tilePrecacheTile(1147); // water drip tilePrecacheTile(1147, -1, hits); // water drip
tilePrecacheTile(1160); // blood drip tilePrecacheTile(1160, -1, hits); // blood drip
// Player SEQs // Player SEQs
seqPrecacheId(dudeInfo[31].seqStartID+6); seqPrecacheId(dudeInfo[31].seqStartID+6, hits);
seqPrecacheId(dudeInfo[31].seqStartID+7); seqPrecacheId(dudeInfo[31].seqStartID+7, hits);
seqPrecacheId(dudeInfo[31].seqStartID+8); seqPrecacheId(dudeInfo[31].seqStartID+8, hits);
seqPrecacheId(dudeInfo[31].seqStartID+9); seqPrecacheId(dudeInfo[31].seqStartID+9, hits);
seqPrecacheId(dudeInfo[31].seqStartID+10); seqPrecacheId(dudeInfo[31].seqStartID+10, hits);
seqPrecacheId(dudeInfo[31].seqStartID+14); seqPrecacheId(dudeInfo[31].seqStartID+14, hits);
seqPrecacheId(dudeInfo[31].seqStartID+15); seqPrecacheId(dudeInfo[31].seqStartID+15, hits);
seqPrecacheId(dudeInfo[31].seqStartID+12); seqPrecacheId(dudeInfo[31].seqStartID+12, hits);
seqPrecacheId(dudeInfo[31].seqStartID+16); seqPrecacheId(dudeInfo[31].seqStartID+16, hits);
seqPrecacheId(dudeInfo[31].seqStartID+17); seqPrecacheId(dudeInfo[31].seqStartID+17, hits);
seqPrecacheId(dudeInfo[31].seqStartID+18); seqPrecacheId(dudeInfo[31].seqStartID+18, hits);
if (skyTile > -1 && skyTile < kMaxTiles) if (skyTile > -1 && skyTile < kMaxTiles)
{ {
for (int i = 1; i < gSkyCount; i++) for (int i = 1; i < gSkyCount; i++)
tilePrecacheTile(skyTile+i, 0); tilePrecacheTile(skyTile+i, 0, hits);
} }
WeaponPrecache(); WeaponPrecache(hits);
viewPrecacheTiles(); viewPrecacheTiles(hits);
fxPrecache(); fxPrecache(hits);
gibPrecache(); gibPrecache(hits);
I_GetEvent(); I_GetEvent();
} }
void PreloadCache(void) void PreloadCache()
{ {
if (!r_precache) return; if (!r_precache) return;
PreloadTiles(); HitList hits;
PreloadTiles(hits);
int cnt = 0; int cnt = 0;
int percentDisplayed = -1; int percentDisplayed = -1;
for (int i = 0; i < kMaxTiles; i++) for (int i = 0; i < kMaxTiles; i++)
{ {
if (TestBitString(gotpic, i)) if (hits[i])
{ {
PrecacheHardwareTextures(i); PrecacheHardwareTextures(i);
@ -285,7 +389,6 @@ void PreloadCache(void)
I_GetEvent(); I_GetEvent();
} }
} }
memset(gotpic,0,sizeof(gotpic));
} }
END_BLD_NS END_BLD_NS

View file

@ -170,14 +170,14 @@ void QAV::Preload(void)
} }
} }
void QAV::Precache(void) void QAV::Precache(HitList &hits)
{ {
for (int i = 0; i < nFrames; i++) for (int i = 0; i < nFrames; i++)
{ {
for (int j = 0; j < 8; j++) for (int j = 0; j < 8; j++)
{ {
if (frames[i].tiles[j].picnum >= 0) if (frames[i].tiles[j].picnum >= 0)
tilePrecacheTile(frames[i].tiles[j].picnum, 0); tilePrecacheTile(frames[i].tiles[j].picnum, 0, hits);
} }
} }
} }

View file

@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "build.h" #include "build.h"
#include "common_game.h" #include "common_game.h"
#include "blood.h" #include "blood.h"
#include "misc.h"
class F2DDrawer; class F2DDrawer;
@ -85,7 +86,7 @@ struct QAV
void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool in3dscene); void Draw(double x, double y, int ticks, int stat, int shade, int palnum, bool in3dscene);
void Play(int, int, int, void *); void Play(int, int, int, void *);
void Preload(void); void Preload(void);
void Precache(void); void Precache(HitList &hits);
void PlaySound(int nSound); void PlaySound(int nSound);
void PlaySound3D(spritetype *pSprite, int nSound, int a3, int a4); void PlaySound3D(spritetype *pSprite, int nSound, int a3, int a4);

View file

@ -66,20 +66,20 @@ void Seq::Preload(void)
tilePreloadTile(seqGetTile(&frames[i])); tilePreloadTile(seqGetTile(&frames[i]));
} }
void Seq::Precache(void) void Seq::Precache(HitList &hits)
{ {
if (memcmp(signature, "SEQ\x1a", 4) != 0) if (memcmp(signature, "SEQ\x1a", 4) != 0)
ThrowError("Invalid sequence"); ThrowError("Invalid sequence");
if ((version & 0xff00) != 0x300) if ((version & 0xff00) != 0x300)
ThrowError("Obsolete sequence version"); ThrowError("Obsolete sequence version");
for (int i = 0; i < nFrames; i++) for (int i = 0; i < nFrames; i++)
tilePrecacheTile(seqGetTile(&frames[i])); tilePrecacheTile(seqGetTile(&frames[i]), -1, hits);
} }
void seqPrecacheId(int id) void seqPrecacheId(int id, HitList &hits)
{ {
auto pSeq = getSequence(id); auto pSeq = getSequence(id);
if (pSeq) pSeq->Precache(); if (pSeq) pSeq->Precache(hits);
} }
SEQINST siWall[kMaxXWalls]; SEQINST siWall[kMaxXWalls];

View file

@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
#pragma once #pragma once
#include "misc.h"
BEGIN_BLD_NS BEGIN_BLD_NS
@ -58,7 +59,7 @@ struct Seq {
int atc; int atc;
SEQFRAME frames[1]; SEQFRAME frames[1];
void Preload(void); void Preload(void);
void Precache(void); void Precache(HitList &);
}; };
struct ACTIVE struct ACTIVE
@ -84,7 +85,7 @@ inline int seqGetTile(SEQFRAME* pFrame)
} }
int seqRegisterClient(void(*pClient)(int, int)); int seqRegisterClient(void(*pClient)(int, int));
void seqPrecacheId(int id); void seqPrecacheId(int id, HitList &hits);
SEQINST * GetInstance(int a1, int a2); SEQINST * GetInstance(int a1, int a2);
void UnlockInstance(SEQINST *pInst); void UnlockInstance(SEQINST *pInst);
void seqSpawn(int a1, int a2, int a3, int a4 = -1); void seqSpawn(int a1, int a2, int a3, int a4 = -1);

View file

@ -111,105 +111,6 @@ void tileProcessGLVoxels(void)
} }
#endif #endif
void tilePreloadTile(int nTile)
{
if (!r_precache) return;
int n = 1;
switch (picanm[nTile].extra&7)
{
case 0:
n = 1;
break;
case 1:
n = 5;
break;
case 2:
n = 8;
break;
case 3:
n = 2;
break;
case 6:
case 7:
if (voxelIndex[nTile] < 0 || voxelIndex[nTile] >= kMaxVoxels)
{
voxelIndex[nTile] = -1;
picanm[nTile].extra &= ~7;
}
break;
}
while(n--)
{
if (picanm[nTile].sf&PICANM_ANIMTYPE_MASK)
{
for (int frame = picanm[nTile].num; frame >= 0; frame--)
{
if ((picanm[nTile].sf&PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK)
PrecacheHardwareTextures(nTile-frame);
else
PrecacheHardwareTextures(nTile+frame);
}
}
else
PrecacheHardwareTextures(nTile);
nTile += 1+picanm[nTile].num;
}
}
int nPrecacheCount;
char precachehightile[2][(MAXTILES+7)>>3];
void tilePrecacheTile(int nTile, int nType)
{
int n = 1;
switch (picanm[nTile].extra&7)
{
case 0:
n = 1;
break;
case 1:
n = 5;
break;
case 2:
n = 8;
break;
case 3:
n = 2;
break;
}
while(n--)
{
if (picanm[nTile].sf&PICANM_ANIMTYPE_MASK)
{
for (int frame = picanm[nTile].num; frame >= 0; frame--)
{
int tile;
if ((picanm[nTile].sf&PICANM_ANIMTYPE_MASK) == PICANM_ANIMTYPE_BACK)
tile = nTile-frame;
else
tile = nTile+frame;
if (!TestBitString(gotpic, tile))
{
nPrecacheCount++;
SetBitString(gotpic, tile);
}
SetBitString(precachehightile[nType], tile);
}
}
else
{
if (!TestBitString(gotpic, nTile))
{
nPrecacheCount++;
SetBitString(gotpic, nTile);
}
SetBitString(precachehightile[nType], nTile);
}
nTile += 1+picanm[nTile].num;
}
}
char tileGetSurfType(int hit) char tileGetSurfType(int hit)
{ {
int n = hit & 0x3fff; int n = hit & 0x3fff;

View file

@ -223,12 +223,12 @@ void WeaponInit(void)
} }
} }
void WeaponPrecache(void) void WeaponPrecache(HitList &hits)
{ {
for (int i = 0; i < kQAVEnd; i++) for (int i = 0; i < kQAVEnd; i++)
{ {
if (weaponQAV[i]) if (weaponQAV[i])
weaponQAV[i]->Precache(); weaponQAV[i]->Precache(hits);
} }
} }