2020-09-01 17:39:30 +00:00
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
/*
|
|
|
|
Copyright (C) 2010-2019 EDuke32 developers and contributors
|
|
|
|
Copyright (C) 2019 Nuke.YKT
|
|
|
|
|
|
|
|
This file is part of NBlood.
|
|
|
|
|
|
|
|
NBlood is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License version 2
|
|
|
|
as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
//-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "ns.h" // Must come before everything else!
|
|
|
|
#include "build.h"
|
2020-12-09 14:56:32 +00:00
|
|
|
#include "blood.h"
|
2020-09-01 17:39:30 +00:00
|
|
|
#include "view.h"
|
|
|
|
#include "g_input.h"
|
2021-04-11 07:59:55 +00:00
|
|
|
#include "precache.h"
|
2020-09-01 17:39:30 +00:00
|
|
|
|
|
|
|
BEGIN_BLD_NS
|
|
|
|
|
2020-09-08 17:18:11 +00:00
|
|
|
int nPrecacheCount;
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
void fxPrecache();
|
|
|
|
void gibPrecache();
|
2020-09-08 17:18:11 +00:00
|
|
|
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
void tilePrecacheTile(int nTile, int nType, int palette)
|
2020-09-08 17:18:11 +00:00
|
|
|
{
|
|
|
|
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;
|
2021-04-11 10:42:59 +00:00
|
|
|
|
|
|
|
markTileForPrecache(tile, palette);
|
2020-09-08 17:18:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-04-11 10:42:59 +00:00
|
|
|
markTileForPrecache(nTile, palette);
|
2020-09-08 17:18:11 +00:00
|
|
|
}
|
|
|
|
nTile += 1 + picanm[nTile].num;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-09-01 17:39:30 +00:00
|
|
|
// To do: This needs to handle the sprite palettes as well to properly precache the needed content.
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
void viewPrecacheTiles()
|
2020-09-01 17:39:30 +00:00
|
|
|
{
|
2021-04-11 10:42:59 +00:00
|
|
|
tilePrecacheTile(2173, 0, 0);
|
|
|
|
tilePrecacheTile(2200, 0, 0);
|
|
|
|
tilePrecacheTile(2201, 0, 0);
|
|
|
|
tilePrecacheTile(2202, 0, 0);
|
|
|
|
tilePrecacheTile(2207, 0, 0);
|
|
|
|
tilePrecacheTile(2208, 0, 0);
|
|
|
|
tilePrecacheTile(2209, 0, 0);
|
|
|
|
tilePrecacheTile(2229, 0, 0);
|
|
|
|
tilePrecacheTile(2260, 0, 0);
|
|
|
|
tilePrecacheTile(2559, 0, 0);
|
|
|
|
tilePrecacheTile(2169, 0, 0);
|
|
|
|
tilePrecacheTile(2578, 0, 0);
|
|
|
|
tilePrecacheTile(2586, 0, 0);
|
|
|
|
tilePrecacheTile(2602, 0, 0);
|
2020-09-01 17:39:30 +00:00
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
{
|
2021-04-11 10:42:59 +00:00
|
|
|
tilePrecacheTile(2190 + i, 0, 0);
|
|
|
|
tilePrecacheTile(2230 + i, 0, 0);
|
|
|
|
tilePrecacheTile(2240 + i, 0, 0);
|
|
|
|
tilePrecacheTile(2250 + i, 0, 0);
|
|
|
|
tilePrecacheTile(kSBarNumberHealth + i, 0, 0);
|
|
|
|
tilePrecacheTile(kSBarNumberAmmo + i, 0, 0);
|
|
|
|
tilePrecacheTile(kSBarNumberInv + i, 0, 0);
|
|
|
|
tilePrecacheTile(kSBarNumberArmor1 + i, 0, 0);
|
|
|
|
tilePrecacheTile(kSBarNumberArmor2 + i, 0, 0);
|
|
|
|
tilePrecacheTile(kSBarNumberArmor3 + i, 0, 0);
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
|
|
|
/*
|
|
|
|
for (int i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
tilePrecacheTile(gPackIcons[i], 0);
|
|
|
|
tilePrecacheTile(gPackIcons2[i].nTile, 0);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
for (int i = 0; i < 6; i++)
|
|
|
|
{
|
2021-04-11 10:42:59 +00:00
|
|
|
tilePrecacheTile(2220 + i, 0, 0);
|
|
|
|
tilePrecacheTile(2552 + i, 0, 0);
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
void PrecacheDude(spritetype *pSprite)
|
2020-09-01 17:39:30 +00:00
|
|
|
{
|
2021-04-11 10:42:59 +00:00
|
|
|
int palette = pSprite->pal;
|
2020-09-01 17:39:30 +00:00
|
|
|
DUDEINFO *pDudeInfo = getDudeInfo(pSprite->type);
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID , palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+5, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+1, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+2, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
switch (pSprite->type)
|
|
|
|
{
|
|
|
|
case kDudeCultistTommy:
|
|
|
|
case kDudeCultistShotgun:
|
|
|
|
case kDudeCultistTesla:
|
|
|
|
case kDudeCultistTNT:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6 , palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7 , palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8 , palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9 , palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+13, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+14, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+15, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kDudeZombieButcher:
|
|
|
|
case kDudeGillBeast:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+10, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+11, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kDudeGargoyleStatueFlesh:
|
|
|
|
case kDudeGargoyleStatueStone:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette); //???
|
2021-12-14 11:05:24 +00:00
|
|
|
[[fallthrough]];
|
2020-09-01 17:39:30 +00:00
|
|
|
case kDudeGargoyleFlesh:
|
|
|
|
case kDudeGargoyleStone:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kDudePhantasm:
|
|
|
|
case kDudeHellHound:
|
|
|
|
case kDudeSpiderBrown:
|
|
|
|
case kDudeSpiderRed:
|
|
|
|
case kDudeSpiderBlack:
|
|
|
|
case kDudeSpiderMother:
|
|
|
|
case kDudeTchernobog:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kDudeCerberusTwoHead:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7, palette);
|
2021-12-14 11:05:24 +00:00
|
|
|
[[fallthrough]];
|
2020-09-01 17:39:30 +00:00
|
|
|
case kDudeHand:
|
|
|
|
case kDudeBoneEel:
|
|
|
|
case kDudeBat:
|
|
|
|
case kDudeRat:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kDudeCultistBeast:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kDudeZombieAxeBuried:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+12, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+9, palette);
|
2021-12-14 11:05:24 +00:00
|
|
|
[[fallthrough]];
|
2020-09-01 17:39:30 +00:00
|
|
|
case kDudeZombieAxeLaying:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+10, palette);
|
2021-12-14 11:05:24 +00:00
|
|
|
[[fallthrough]];
|
2020-09-01 17:39:30 +00:00
|
|
|
case kDudeZombieAxeNormal:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+6, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+7, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+8, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+11, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+13, palette);
|
|
|
|
seqPrecacheId(pDudeInfo->seqStartID+14, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
void PrecacheThing(spritetype *pSprite)
|
|
|
|
{
|
|
|
|
int palette = pSprite->pal;
|
2020-09-01 17:39:30 +00:00
|
|
|
switch (pSprite->type) {
|
|
|
|
case kThingGlassWindow: // worthless...
|
|
|
|
case kThingFluorescent:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(12, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kThingSpiderWeb:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(15, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kThingMetalGrate:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(21, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kThingFlammableTree:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(25, palette);
|
|
|
|
seqPrecacheId(26, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kTrapMachinegun:
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(38, palette);
|
|
|
|
seqPrecacheId(40, palette);
|
|
|
|
seqPrecacheId(28, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
break;
|
|
|
|
case kThingObjectGib:
|
|
|
|
//case kThingObjectExplode: weird that only gib object is precached and this one is not
|
|
|
|
break;
|
|
|
|
}
|
2021-04-11 10:42:59 +00:00
|
|
|
tilePrecacheTile(pSprite->picnum, -1, palette);
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
void PreloadCache()
|
2020-09-01 17:39:30 +00:00
|
|
|
{
|
2021-04-11 10:42:59 +00:00
|
|
|
if (!r_precache) return;
|
2020-09-01 17:39:30 +00:00
|
|
|
int skyTile = -1;
|
|
|
|
// Fonts
|
2021-11-23 22:39:10 +00:00
|
|
|
for(auto& sect : sectors())
|
2020-09-01 17:39:30 +00:00
|
|
|
{
|
2021-11-23 22:39:10 +00:00
|
|
|
tilePrecacheTile(sect.floorpicnum, 0, sect.floorpal);
|
|
|
|
tilePrecacheTile(sect.ceilingpicnum, 0, sect.ceilingpal);
|
2021-12-18 12:14:56 +00:00
|
|
|
if ((sect.ceilingstat & CSTAT_SECTOR_SKY) != 0 && skyTile == -1)
|
2021-11-23 22:39:10 +00:00
|
|
|
skyTile = sect.ceilingpicnum;
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
2021-11-23 22:39:10 +00:00
|
|
|
for(auto& wal : walls())
|
2020-09-01 17:39:30 +00:00
|
|
|
{
|
2021-11-23 22:39:10 +00:00
|
|
|
tilePrecacheTile(wal.picnum, 0, wal.pal);
|
|
|
|
if (wal.overpicnum >= 0)
|
|
|
|
tilePrecacheTile(wal.overpicnum, 0, wal.pal);
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
2021-09-04 20:24:34 +00:00
|
|
|
BloodSpriteIterator it;
|
|
|
|
while (auto actor = it.Next())
|
2020-09-01 17:39:30 +00:00
|
|
|
{
|
2021-09-04 20:24:34 +00:00
|
|
|
spritetype *pSprite = &actor->s();
|
|
|
|
switch (pSprite->statnum)
|
2020-09-01 17:39:30 +00:00
|
|
|
{
|
2021-09-04 20:24:34 +00:00
|
|
|
case kStatDude:
|
|
|
|
PrecacheDude(pSprite);
|
|
|
|
break;
|
|
|
|
case kStatThing:
|
|
|
|
PrecacheThing(pSprite);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
tilePrecacheTile(pSprite->picnum, -1, pSprite->pal);
|
|
|
|
break;
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Precache common SEQs
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
{
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(i, 0);
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
tilePrecacheTile(1147, -1, 0); // water drip
|
|
|
|
tilePrecacheTile(1160, -1, 0); // blood drip
|
2020-09-01 17:39:30 +00:00
|
|
|
|
|
|
|
// Player SEQs
|
2021-04-11 10:42:59 +00:00
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+6, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+7, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+8, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+9, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+10, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+14, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+15, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+12, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+16, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+17, 0);
|
|
|
|
seqPrecacheId(dudeInfo[31].seqStartID+18, 0);
|
2020-09-01 17:39:30 +00:00
|
|
|
|
|
|
|
if (skyTile > -1 && skyTile < kMaxTiles)
|
|
|
|
{
|
|
|
|
for (int i = 1; i < gSkyCount; i++)
|
2021-04-11 10:42:59 +00:00
|
|
|
tilePrecacheTile(skyTile+i, 0, 0);
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
|
|
|
|
2021-04-11 10:42:59 +00:00
|
|
|
WeaponPrecache();
|
|
|
|
viewPrecacheTiles();
|
|
|
|
fxPrecache();
|
|
|
|
gibPrecache();
|
2020-09-01 17:39:30 +00:00
|
|
|
|
|
|
|
I_GetEvent();
|
2021-04-11 10:42:59 +00:00
|
|
|
precacheMarkedTiles();
|
2020-09-01 17:39:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
END_BLD_NS
|
|
|
|
|