- refactored all access to the fake picanm[] array.

Also use symbolic names in precache calls in Blood.
This commit is contained in:
Christoph Oelckers 2022-12-08 19:56:55 +01:00
parent e23a5095cb
commit 1a6f808fca
9 changed files with 63 additions and 82 deletions

View file

@ -812,7 +812,7 @@ int hitscan(const DVector3& start, const sectortype* startsect, const DVector3&
break;
case CSTAT_SPRITE_ALIGNMENT_WALL:
hit = intersectWallSprite(actor, start, vect, v, hitfactor, (picanm[actor->spr.picnum].sf & PICANM_TEXHITSCAN_BIT));
hit = intersectWallSprite(actor, start, vect, v, hitfactor, GetExtInfo(actor->spr.spritetexture()).picanm.sf & PICANM_TEXHITSCAN_BIT);
break;
case CSTAT_SPRITE_ALIGNMENT_FLOOR:

View file

@ -101,15 +101,17 @@ TMap<int64_t, bool> cachemap;
void markTileForPrecache(int tilenum, int palnum)
{
int i, j;
if (picanm[tilenum].type() == PICANM_ANIMTYPE_BACK)
auto nTex = tileGetTextureID(tilenum);
auto& picanm = GetExtInfo(nTex).picanm;
if (picanm.type() == PICANM_ANIMTYPE_BACK)
{
i = tilenum - picanm[tilenum].num;
i = tilenum - picanm.num;
j = tilenum;
}
else
{
i = tilenum;
j = tilenum + picanm[tilenum].num * ((picanm[tilenum].type() == PICANM_ANIMTYPE_OSC) ? 2 : 1);
j = tilenum + picanm.num * ((picanm.type() == PICANM_ANIMTYPE_OSC) ? 2 : 1);
}
for (; i <= j; i++)

View file

@ -69,18 +69,6 @@ inline int tileForName(const char* name)
return legacyTileNum(texid);
}
// Some hacks to allow accessing the no longer existing arrays as if they still were arrays to avoid changing hundreds of lines of code.
struct PicAnm
{
//[[deprecated]]
const picanm_t& operator[](int index) const
{
assert((unsigned)index < MAXTILES);
return GetExtInfo(tileGetTextureID(index)).picanm;
}
};
inline PicAnm picanm;
//[[deprecated]]
inline int tileWidth(int num)
{

View file

@ -332,8 +332,8 @@ static void GetImagesFromFile(TArray<FImageSource*>& array, TArray<unsigned>& pi
unsigned tileend = LittleLong(((unsigned*)tiles)[3]);
const uint16_t* tilesizx = &((const uint16_t*)tiles)[8];
const uint16_t* tilesizy = &tilesizx[tileend - tilestart + 1];
const uint32_t* picanm = (const uint32_t*)&tilesizy[tileend - tilestart + 1];
const uint8_t* tiledata = (const uint8_t*)&picanm[tileend - tilestart + 1];
const uint32_t* picanmraw = (const uint32_t*)&tilesizy[tileend - tilestart + 1];
const uint8_t* tiledata = (const uint8_t*)&picanmraw[tileend - tilestart + 1];
unsigned oldsize = array.Size();
if (array.Size() < tileend + 1)
@ -355,10 +355,10 @@ static void GetImagesFromFile(TArray<FImageSource*>& array, TArray<unsigned>& pi
int pic = i - tilestart;
int width = LittleShort(tilesizx[pic]);
int height = LittleShort(tilesizy[pic]);
uint32_t anm = LittleLong(picanm[pic]);
uint32_t anm = LittleLong(picanmraw[pic]);
int size = width * height;
picanmarray[i] = picanm[pic]; // this must also be retained for invalid tiles.
picanmarray[i] = picanmraw[pic]; // this must also be retained for invalid tiles.
if (width <= 0 || height <= 0)
{
// If an existing tile is discarded, add it to the free list

View file

@ -543,16 +543,16 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
pTSprite->scale = DVector2(0, 0);
continue;
}
int nTile = pTSprite->picnum;
if (nTile < 0 || nTile >= kMaxTiles)
auto nTex = pTSprite->spritetexture();
if (!nTex.isValid())
{
pTSprite->scale = DVector2(0, 0);
continue;
}
// skip picnum 0 on face sprites. picnum 0 is a simple wall texture in Blood,
// but there are maps that use 0 on some operator sprites that may show up in potals as a result.
// but there are maps that use 0 on some operator sprites that may show up in portals as a result.
// Since the wall texture is perfectly fine for wall and floor sprites, these will be allowed to pass.
if (nTile == 0 && (pTSprite->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FACING)
if (legacyTileNum(nTex) == 0 && (pTSprite->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FACING)
{
pTSprite->scale = DVector2(0, 0);
continue;
@ -564,10 +564,13 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
pTSprite->Angles.Yaw = owneractor->interpolatedyaw(interpfrac);
}
int nAnim = 0;
switch (picanm[nTile].extra & 7) {
int nAnimType = GetExtInfo(nTex).picanm.extra & 7;
switch (nAnimType)
{
case 0:
if (!owneractor->hasX()) break;
switch (pTSprite->type) {
switch (pTSprite->type)
{
#ifdef NOONE_EXTENSIONS
case kModernCondition:
case kModernConditionFalse:
@ -642,7 +645,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
pTSprite->cstat &= ~(CSTAT_SPRITE_XFLIP | CSTAT_SPRITE_YFLIP);
auto tex = TexMan.GetGameTexture(pTSprite->spritetexture());
pTSprite->yoffset += (uint8_t)tex->GetDisplayTopOffset();
if ((picanm[nTile].extra & 7) == 7)
if (nAnimType == 7)
{
pTSprite->Angles.Yaw = myclock.Normalized360();
}
@ -653,7 +656,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
while (nAnim > 0)
{
pTSprite->picnum += picanm[pTSprite->picnum].num + 1;
pTSprite->picnum += GetExtInfo(pTSprite->spritetexture()).picanm.num + 1;
nAnim--;
}
@ -913,7 +916,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
{
tspritetype* pTSprite = tsprites.get(nTSprite);
int nAnim = 0;
switch (picanm[pTSprite->picnum].extra & 7)
switch (GetExtInfo(pTSprite->spritetexture()).picanm.extra & 7)
{
case 1:
{
@ -937,7 +940,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
while (nAnim > 0)
{
pTSprite->picnum += picanm[pTSprite->picnum].num + 1;
pTSprite->picnum += GetExtInfo(pTSprite->spritetexture()).picanm.num + 1;
nAnim--;
}
}

View file

@ -97,6 +97,7 @@ extern int nPrecacheCount;
inline FTextureID mirrortile;
void tilePrecacheTile(int nTile, int nType, int palette);
void tilePrecacheTile(FTextureID nTile, int nType, int palette);
int tileGetSurfType(CollisionBase& hit);

View file

@ -14,9 +14,6 @@ x(LoadScreenWideMiddle, 9219)
x(SBarNumberHealth, 9220)
x(SBarNumberAmmo, 9230)
x(SBarNumberInv, 9240)
x(SBarNumberArmor1, 9250)
x(SBarNumberArmor2, 9260)
x(SBarNumberArmor3, 9270)
x(SBarSlash, 9280)
x(PackBG, 2568)
@ -182,15 +179,15 @@ x(SBarAmmoAmount8, 2238)
x(SBarAmmoAmount9, 2239)
x(SBarWaponNum0, 2240)
x(SBarWaponNum0, 2241)
x(SBarWaponNum0, 2242)
x(SBarWaponNum0, 2243)
x(SBarWaponNum0, 2244)
x(SBarWaponNum0, 2245)
x(SBarWaponNum0, 2246)
x(SBarWaponNum0, 2247)
x(SBarWaponNum0, 2248)
x(SBarWaponNum0, 2249)
x(SBarWaponNum1, 2241)
x(SBarWaponNum2, 2242)
x(SBarWaponNum3, 2243)
x(SBarWaponNum4, 2244)
x(SBarWaponNum5, 2245)
x(SBarWaponNum6, 2246)
x(SBarWaponNum7, 2247)
x(SBarWaponNum8, 2248)
x(SBarWaponNum9, 2249)
x(MIRRORTILE, 504)

View file

@ -44,8 +44,9 @@ void gibPrecache();
void tilePrecacheTile(int nTile, int nType, int palette)
{
auto nTex = tileGetTextureID(nTile);
int n = 1;
switch (picanm[nTile].extra & 7)
switch (GetExtInfo(nTex).picanm.extra & 7)
{
case 0:
n = 1;
@ -63,7 +64,7 @@ void tilePrecacheTile(int nTile, int nType, int palette)
while (n--)
{
markTileForPrecache(nTile, palette);
nTile += 1 + picanm[nTile].num;
nTile += 1 + GetExtInfo(nTex).picanm.num;
}
}
@ -78,32 +79,32 @@ void tilePrecacheTile(int nTile, int nType, int palette)
void viewPrecacheTiles()
{
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);
tilePrecacheTile(kArmorbox, 0, 0);
tilePrecacheTile(kStatusbar, 0, 0);
tilePrecacheTile(kFullHUD, 0, 0);
tilePrecacheTile(kBlinkIcon, 0, 0);
tilePrecacheTile(kArmor1Gauge, 0, 0);
tilePrecacheTile(kArmor2Gauge, 0, 0);
tilePrecacheTile(kArmor3Gauge, 0, 0);
tilePrecacheTile(kSBPlayerSlot, 0, 0);
tilePrecacheTile(kThrowGauge, 0, 0);
tilePrecacheTile(kPackSelect, 0, 0);
tilePrecacheTile(kHealthicon, 0, 0);
tilePrecacheTile(kArmor1Icon, 0, 0);
tilePrecacheTile(kArmor2Icon, 0, 0);
tilePrecacheTile(kArmor3Icon, 0, 0);
for (int i = 0; i < 10; i++)
{
tilePrecacheTile(2190 + i, 0, 0);
tilePrecacheTile(2230 + i, 0, 0);
tilePrecacheTile(2240 + i, 0, 0);
tilePrecacheTile(2250 + i, 0, 0);
tilePrecacheTile(kSBarHealthAmount0 + i, 0, 0);
tilePrecacheTile(kSBarAmmoAmount0 + i, 0, 0);
tilePrecacheTile(kSBarWaponNum0 + i, 0, 0);
tilePrecacheTile(kSBarPackAmount0 + 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);
tilePrecacheTile(kSBarNumberArmor1_1 + i, 0, 0);
tilePrecacheTile(kSBarNumberArmor2_1 + i, 0, 0);
tilePrecacheTile(kSBarNumberArmor3_1 + i, 0, 0);
}
/*
for (int i = 0; i < 5; i++)
@ -114,8 +115,8 @@ void viewPrecacheTiles()
*/
for (int i = 0; i < 6; i++)
{
tilePrecacheTile(2220 + i, 0, 0);
tilePrecacheTile(2552 + i, 0, 0);
tilePrecacheTile(kKeyIcon1 + i, 0, 0);
tilePrecacheTile(kHudKeyIcon1 + i, 0, 0);
}
}

View file

@ -61,24 +61,13 @@ enum VIEWPOS {
VIEWPOS_1
};
#define x(a, b) k##a = b,
enum
{
kBackTile = 253,
kCrosshairTile = 2319,
kLoadScreen = 2049,
kLoadScreenWideBack = 9216,
kLoadScreenWideLeft = 9217,
kLoadScreenWideRight = 9218,
kLoadScreenWideMiddle = 9219,
kSBarNumberHealth = 9220,
kSBarNumberAmmo = 9230,
kSBarNumberInv = 9240,
kSBarNumberArmor1 = 9250,
kSBarNumberArmor2 = 9260,
kSBarNumberArmor3 = 9270,
#include "namelist.h"
};
#undef x
enum { kFontNum = 5 };