- added back the hijacked 'detail' member to spritetype.

This changes the Blood map loader to not use the in-game sprite structure for loading a level and moves the qsprite_filler array back into the sprite.
This commit is contained in:
Christoph Oelckers 2020-10-02 22:14:01 +02:00
parent c86af08a19
commit 4e67197838
9 changed files with 53 additions and 75 deletions

View file

@ -453,7 +453,7 @@ void viewProcessSprites(int32_t cX, int32_t cY, int32_t cZ, int32_t cA, int32_t
//int nXSprite = pTSprite->extra;
int nXSprite = sprite[pTSprite->owner].extra;
XSPRITE *pTXSprite = NULL;
if (qsprite_filler[pTSprite->owner] > gDetail)
if (sprite[pTSprite->owner].deteil > gDetail)
{
pTSprite->xrepeat = 0;
continue;

View file

@ -51,7 +51,7 @@ SPRITEHIT gSpriteHit[kMaxXSprites];
int xvel[kMaxSprites], yvel[kMaxSprites], zvel[kMaxSprites];
char qsprite_filler[kMaxSprites], qsector_filler[kMaxSectors];
char qsector_filler[kMaxSectors];
int gVisibility;
@ -917,35 +917,36 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
for (int i = 0; i < mapHeader.at23; i++)
{
RemoveSpriteStat(i);
spritetypev7 load;
spritetype *pSprite = &sprite[i];
fr.Read(pSprite, sizeof(spritetype));
if (byte_1A76C8)
fr.Read(&load, sizeof(spritetypev7)); // load into an intermediate buffer so that spritetype is no longer bound by file formats.
if (byte_1A76C8) // What were these people thinking? :(
{
dbCrypt((char*)pSprite, sizeof(spritetype), (gMapRev*sizeof(spritetype)) | 0x7474614d);
}
pSprite->x = LittleLong(pSprite->x);
pSprite->y = LittleLong(pSprite->y);
pSprite->z = LittleLong(pSprite->z);
pSprite->cstat = LittleShort(pSprite->cstat);
pSprite->picnum = LittleShort(pSprite->picnum);
pSprite->sectnum = LittleShort(pSprite->sectnum);
pSprite->statnum = LittleShort(pSprite->statnum);
pSprite->ang = LittleShort(pSprite->ang);
pSprite->owner = LittleShort(pSprite->owner);
pSprite->index = LittleShort(pSprite->index);
pSprite->yvel = LittleShort(pSprite->yvel);
pSprite->inittype = LittleShort(pSprite->inittype);
pSprite->type = LittleShort(pSprite->type);
pSprite->flags = LittleShort(pSprite->hitag);
pSprite->extra = LittleShort(pSprite->extra);
pSprite->x = LittleLong(load.x);
pSprite->y = LittleLong(load.y);
pSprite->z = LittleLong(load.z);
pSprite->cstat = LittleShort(load.cstat);
pSprite->picnum = LittleShort(load.picnum);
pSprite->sectnum = LittleShort(load.sectnum);
pSprite->statnum = LittleShort(load.statnum);
pSprite->ang = LittleShort(load.ang);
pSprite->owner = LittleShort(load.owner);
pSprite->index = LittleShort(load.index);
pSprite->yvel = LittleShort(load.yvel);
pSprite->inittype = LittleShort(load.inittype);
pSprite->type = LittleShort(load.type);
pSprite->flags = LittleShort(load.hitag);
pSprite->extra = LittleShort(load.extra);
pSprite->detail = pSprite->blend;
pSprite->blend = 0;
InsertSpriteSect(i, sprite[i].sectnum);
InsertSpriteStat(i, sprite[i].statnum);
Numsprites++;
sprite[i].index = i;
qsprite_filler[i] = pSprite->blend;
pSprite->blend = 0;
if (sprite[i].extra > 0)
{
char pBuffer[nXSpriteSize];

View file

@ -286,7 +286,7 @@ extern XWALL xwall[kMaxXWalls];
extern SPRITEHIT gSpriteHit[kMaxXSprites];
extern char qsprite_filler[kMaxSprites], qsector_filler[kMaxSectors];
extern char qsector_filler[kMaxSectors];
extern int xvel[kMaxSprites], yvel[kMaxSprites], zvel[kMaxSprites];

View file

@ -181,7 +181,7 @@ spritetype * CFX::fxSpawn(FX_ID nFx, int nSector, int x, int y, int z, unsigned
pSprite->cstat |= pFX->at16;
pSprite->shade = pFX->at18;
pSprite->pal = pFX->at19;
qsprite_filler[pSprite->index] = pFX->at1;
sprite[pSprite->index].detail = pFX->at1;
if (pFX->at14 > 0)
pSprite->xrepeat = pFX->at14;
if (pFX->at15 > 0)

View file

@ -584,7 +584,6 @@ void MyLoadSave::Load(void)
int nNumSprites;
Read(&nNumSprites, sizeof(nNumSprites));
Read(qsector_filler, sizeof(qsector_filler[0])*numsectors);
Read(qsprite_filler, sizeof(qsprite_filler[0])*kMaxSprites);
Read(&pSky->horizfrac, sizeof(pSky->horizfrac));
Read(&pSky->yoffs, sizeof(pSky->yoffs));
Read(&pSky->yscale, sizeof(pSky->yscale));
@ -672,7 +671,6 @@ void MyLoadSave::Save(void)
Write(&gGameOptions, sizeof(gGameOptions));
Write(&nNumSprites, sizeof(nNumSprites));
Write(qsector_filler, sizeof(qsector_filler[0])*numsectors);
Write(qsprite_filler, sizeof(qsprite_filler[0])*kMaxSprites);
Write(&pSky->horizfrac, sizeof(pSky->horizfrac));
Write(&pSky->yoffs, sizeof(pSky->yoffs));
Write(&pSky->yscale, sizeof(pSky->yscale));

View file

@ -452,7 +452,8 @@ static void fakeMoveDude(spritetype *pSprite)
if (predict.at64)
predict.at58 += predict.at64 >> 8;
spritetype pSpriteBak = *pSprite;
static_assert(sizeof(tspritetype) == sizeof(spritetype));
tspritetype pSpriteBak; memcpy(&pSpriteBak, pSprite, sizeof(pSpriteBak)); // how dare you??? (Use a tspritetype here so that if the sprite storage gets refactored, this line gets flagged.)
spritetype *pTempSprite = pSprite;
pTempSprite->x = predict.at50;
pTempSprite->y = predict.at54;
@ -543,7 +544,7 @@ static void fakeMoveDude(spritetype *pSprite)
predict.at75.ceilhit = 0;
GetSpriteExtents(pTempSprite, &top, &bottom);
*pSprite = pSpriteBak;
memcpy(pSprite, &pSpriteBak, sizeof(pSpriteBak));
predict.at6a = ClipLow(floorZ-bottom, 0)>>8;
if (predict.at5c || predict.at60)
{

View file

@ -185,8 +185,7 @@ using usectortype = sectortypev7;
using walltype = walltypev7;
using uwalltype = walltypev7;
using spritetype = spritetypev7;
using uspritetype = spritetypev7;
using uspritetype = spritetype;
using uspriteptr_t = uspritetype const *;
using uwallptr_t = uwalltype const *;

View file

@ -159,51 +159,10 @@ enum
};
#endif
//44 bytes
typedef struct
{
union {
struct
{
StructTracker(Sprite, int32_t) x, y, z;
};
vec3_t pos;
};
StructTracker(Sprite, uint16_t) cstat;
StructTracker(Sprite, int16_t) picnum;
StructTracker(Sprite, int8_t) shade;
StructTracker(Sprite, uint8_t) pal, clipdist, blend;
StructTracker(Sprite, uint8_t) xrepeat, yrepeat;
StructTracker(Sprite, int8_t) xoffset, yoffset;
StructTracker(Sprite, int16_t) sectnum, statnum;
StructTracker(Sprite, int16_t) ang, owner;
// What a gross hack! This needs to be done differently. :(
union {
struct
{
union {
StructTracker(Sprite, int16_t) xvel, index;
};
StructTracker(Sprite, int16_t) yvel;
union {
StructTracker(Sprite, int16_t) zvel, inittype;
};
};
vec3_16_t vel;
};
union {
StructTracker(Sprite, int16_t) lotag, type;
};
union {
StructTracker(Sprite, int16_t) hitag, flags;
};
StructTracker(Sprite, int16_t) extra;
} StructName(spritetypev7);
#ifndef buildtypes_h__enums
//44 bytes
// TODO: Remove unused fields from the end of this struct. (TSPRITE_SIZE)
typedef struct
// This is the on-disk format. Only Blood still needs this for its retarded encryption that needs to read this in as a block.
struct spritetypev7
{
union {
struct
@ -240,7 +199,24 @@ typedef struct
int16_t hitag, flags;
};
int16_t extra;
} tspritetype;
};
struct spritetype : public spritetypev7
{
int16_t detail;
// make sure we do not accidentally copy this
spritetype() = default;
spritetype(const spritetype&) = delete;
spritetype& operator=(const spritetype&) = delete;
void clear()
{
memset(this, 0, sizeof(*this));
}
};
using tspritetype = spritetype;
#endif
//////////////////// END Version 7 map format ////////////////

View file

@ -228,7 +228,7 @@ static void ValidateSprite(spritetype& spr)
}
if (bugged)
{
spr = {};
spr.clear();
spr.statnum = MAXSTATUS;
spr.sectnum = MAXSECTORS;
}
@ -259,6 +259,7 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr)
spr.lotag = fr.ReadInt16();
spr.hitag = fr.ReadInt16();
spr.extra = fr.ReadInt16();
spr.deteil = 0;
ValidateSprite(spr);
}
@ -287,6 +288,7 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr)
spr.hitag = fr.ReadInt16();
spr.extra = fr.ReadInt16();
spr.blend = 0;
spr.deteil = 0;
ValidateSprite(spr);
}
@ -321,6 +323,7 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr)
spr.clipdist = 32;
spr.xoffset = 0;
spr.yoffset = 0;
spr.deteil = 0;
ValidateSprite(spr);
}