wrapped all remaining access to type.

This commit is contained in:
Christoph Oelckers 2023-09-30 13:26:00 +02:00
parent 0dd22f3071
commit f71000fe6f
9 changed files with 30 additions and 55 deletions

View file

@ -479,8 +479,8 @@ struct spritetypebase
int16_t intangle; // needs to be kept for SW's SP_TAG4
int16_t xint; // formerly known as xvel and yvel
int16_t yint;
int16_t inittype; // was zvel. All accesses for that have been wrapped. inittype, type and flags are for Blood.
union { int16_t lotag, type; };
int16_t inittype; // was zvel. All accesses for that have been wrapped. inittype and flags are for Blood.
int16_t lotag;
union { int16_t hitag, flags; };
int16_t extra;
int16_t detail;

View file

@ -827,7 +827,6 @@ DEFINE_FIELD_NAMED(DCoreActor, spr.yint, yint)
DEFINE_FIELD_NAMED(DCoreActor, spr.inittype, inittype)
DEFINE_FIELD_NAMED(DCoreActor, spr.hitag, hitag)
DEFINE_FIELD_NAMED(DCoreActor, spr.lotag, lotag)
DEFINE_FIELD_NAMED(DCoreActor, spr.type, type)
DEFINE_FIELD_NAMED(DCoreActor, spr.flags, flags) // need to be careful with this!
DEFINE_FIELD_NAMED(DCoreActor, spr.extra, extra)
DEFINE_FIELD_NAMED(DCoreActor, spr.detail, detail)

View file

@ -47,33 +47,6 @@ BEGIN_BLD_NS
static DAngle gCameraAng;
DAngle random_angles[16][3];
// to allow quick replacement later
bool IsPlayerSprite(tspritetype const* const pSprite)
{
return pSprite->type >= kDudePlayer1 && pSprite->type <= kDudePlayer8;
}
bool IsDudeSprite(tspritetype const* const pSprite)
{
return pSprite->type >= kDudeBase && pSprite->type < kDudeMax;
}
bool IsItemSprite(tspritetype const* const pSprite)
{
return pSprite->type >= kItemBase && pSprite->type < kItemMax;
}
bool IsWeaponSprite(tspritetype const* const pSprite)
{
return pSprite->type >= kItemWeaponBase && pSprite->type < kItemWeaponMax;
}
bool IsAmmoSprite(tspritetype const* const pSprite)
{
return pSprite->type >= kItemAmmoBase && pSprite->type < kItemAmmoMax;
}
//---------------------------------------------------------------------------
//
//
@ -87,7 +60,6 @@ tspritetype* viewInsertTSprite(tspriteArray& tsprites, sectortype* pSector, int
pTSprite->cstat = CSTAT_SPRITE_YCENTER;
pTSprite->scale = DVector2(1, 1);
pTSprite->ownerActor = nullptr;
pTSprite->type = -int(tsprites.Size() - 1);
pTSprite->statnum = nStatnum;
pTSprite->sectp = pSector;
@ -328,7 +300,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
double top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
pNSprite->pos.Z = top;
if (IsDudeSprite(pTSprite))
if (owneractor->IsDudeActor())
pNSprite->setspritetexture(aTexIds[kTexBIGSMOKEEFFECT]);
else
pNSprite->setspritetexture(aTexIds[kTexSMALLSMOKEEFFECT]);
@ -346,7 +318,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
double top, bottom;
GetSpriteExtents(pTSprite, &top, &bottom);
pNSprite->pos.Z = bottom;
if (pTSprite->type >= kDudeBase && pTSprite->type < kDudeMax)
if (owneractor->IsDudeActor())
pNSprite->setspritetexture(aTexIds[kTexBIGSMOKEEFFECT]);
else
pNSprite->setspritetexture(aTexIds[kTexSMALLSMOKEEFFECT]);
@ -414,7 +386,7 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
pNSprite->scale.X = pTSprite->scale.X;
pNSprite->scale.Y = pTSprite->scale.Y * 0.25;
pNSprite->setspritetexture(pTSprite->spritetexture());
if (!VanillaMode() && (pTSprite->type == kThingDroppedLifeLeech)) // fix shadow for thrown lifeleech
if (!VanillaMode() && (owneractor->GetType() == kThingDroppedLifeLeech)) // fix shadow for thrown lifeleech
pNSprite->setspritetexture(aTexIds[kTexICONLEECH]);
pNSprite->pal = 5;
auto tex = TexMan.GetGameTexture(pNSprite->spritetexture());
@ -489,8 +461,8 @@ static tspritetype* viewAddEffect(tspriteArray& tsprites, int nTSprite, VIEW_EFF
}
case kViewEffectShowWeapon:
{
assert(pTSprite->type >= kDudePlayer1 && pTSprite->type <= kDudePlayer8);
PLAYER* pPlayer = &gPlayer[pTSprite->type - kDudePlayer1];
assert(owneractor->IsPlayerActor());
PLAYER* pPlayer = getPlayer(owneractor);
WEAPONICON weaponIcon = gWeaponIcon[pPlayer->curWeapon];
auto nTex = weaponIcon.textureID();
if (!nTex.isValid()) break;
@ -560,6 +532,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
// shift before interpolating to increase precision.
DAngle myclock = DAngle::fromBuild((PlayClock << 3) + (4 << 3) * interpfrac);
gCameraAng = cA;
// Because this goes backward it will only iterate over the originally added tsprites, not over the ones added here.
for (int nTSprite = int(tsprites.Size()) - 1; nTSprite >= 0; nTSprite--)
{
tspritetype* pTSprite = tsprites.get(nTSprite);
@ -587,7 +560,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
{
case 0:
if (!owneractor->hasX()) break;
switch (pTSprite->type)
switch (owneractor->GetType())
{
#ifdef NOONE_EXTENSIONS
case kModernCondition:
@ -728,7 +701,8 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
switch (pTSprite->statnum) {
case kStatDecoration: {
switch (pTSprite->type) {
switch (owneractor->GetType())
{
case kDecorationCandle:
if (!owneractor->hasX() || owneractor->xspr.state == 1) {
pTSprite->shade = -128;
@ -754,7 +728,8 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
break;
case kStatItem: {
switch (pTSprite->type) {
switch (owneractor->GetType())
{
case kItemFlagABase:
if (owneractor->hasX() && owneractor->xspr.state > 0 && gGameOptions.nGameType == 3) {
auto pNTSprite = viewAddEffect(tsprites, nTSprite, kViewEffectBigFlag);
@ -776,7 +751,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
pTSprite->cstat |= CSTAT_SPRITE_BLOOD_BIT2;
break;
default:
if (pTSprite->type >= kItemKeySkull && pTSprite->type < kItemKeyMax)
if (owneractor->GetType() >= kItemKeySkull && owneractor->GetType() < kItemKeyMax)
pTSprite->shade = -128;
viewApplyDefaultPal(pTSprite, pSector);
@ -785,7 +760,8 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
break;
case kStatProjectile: {
switch (pTSprite->type) {
switch (owneractor->GetType())
{
case kMissileTeslaAlt:
pTSprite->scale.Y = (2);
pTSprite->cstat |= CSTAT_SPRITE_ALIGNMENT_FLOOR;
@ -807,7 +783,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
viewAddEffect(tsprites, nTSprite, kViewEffectFlareHalo);
if (pTSprite->type != kMissileFlareRegular) break;
if (owneractor->GetType() != kMissileFlareRegular) break;
sectortype* pSector1 = pTSprite->sectp;
double zDiff = pTSprite->pos.Z - pSector1->ceilingz;
@ -827,7 +803,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
}
case kStatDude:
{
if (pTSprite->type == kDudeHand && owneractor->hasX() && owneractor->xspr.aiState == &hand13A3B4)
if (owneractor->GetType() == kDudeHand && owneractor->hasX() && owneractor->xspr.aiState == &hand13A3B4)
{
auto target = owneractor->GetTarget();
if (target && target->IsPlayerActor())
@ -840,8 +816,8 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
if (pXSector && pXSector->color) copyfloorpal(pTSprite, pSector);
if (powerupCheck(pPlayer, kPwUpBeastVision) > 0) pTSprite->shade = -128;
if (IsPlayerSprite(pTSprite)) {
PLAYER* thisPlayer = &gPlayer[pTSprite->type - kDudePlayer1];
if (owneractor->IsPlayerActor()) {
PLAYER* thisPlayer = getPlayer(owneractor);
if (powerupCheck(thisPlayer, kPwUpShadowCloak) && !powerupCheck(pPlayer, kPwUpBeastVision)) {
pTSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT;
pTSprite->pal = 5;
@ -905,7 +881,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
break;
}
case kStatTraps: {
if (pTSprite->type == kTrapSawCircular) {
if (owneractor->GetType() == kTrapSawCircular) {
if (owneractor->xspr.state) {
if (owneractor->xspr.data1) {
pTSprite->setspritetexture(aTexIds[kTexCIRCLESAW1]);
@ -922,7 +898,7 @@ void viewProcessSprites(tspriteArray& tsprites, const DVector3& cPos, DAngle cA,
case kStatThing: {
viewApplyDefaultPal(pTSprite, pSector);
if (pTSprite->type < kThingBase || pTSprite->type >= kThingMax || owneractor->hit.florhit.type == kHitNone)
if (owneractor->GetType() < kThingBase || owneractor->GetType() >= kThingMax || owneractor->hit.florhit.type == kHitNone)
{
if ((pTSprite->flags & kPhysMove) && getflorzofslopeptr(pTSprite->sectp, pTSprite->pos) >= cPos.Z)
viewAddEffect(tsprites, nTSprite, kViewEffectShadow);

View file

@ -155,12 +155,12 @@ public:
// this is only temporary
void ChangeType(int newtype)
{
spr.type = newtype;
spr.lotag = newtype;
}
int GetType() const
{
return spr.type;
return spr.lotag;
}
};

View file

@ -565,7 +565,7 @@ void sleeveStopBouncing(DBloodActor* actor)
break;
}
actor->ChangeType(FX_51);
actor->ChangeType(fxType(FX_51));
actor->spr.scale = DVector2(0.15625, 0.15625);
}

View file

@ -491,7 +491,7 @@ void dbLoadMap(const char* pPath, DVector3& pos, short* pAngle, sectortype** cur
pSprite->xint = LittleShort(load.index);
pSprite->yint = LittleShort(load.yvel);
pSprite->inittype = LittleShort(load.inittype);
pSprite->type = LittleShort(load.type);
pSprite->lotag = LittleShort(load.lotag);
pSprite->flags = LittleShort(load.hitag);
pSprite->extra = LittleShort(load.extra);
pSprite->pal = load.pal;

View file

@ -17,7 +17,7 @@ struct spritetypedisk
int16_t sectnum, statnum;
int16_t ang, owner;
int16_t index, yvel, inittype;
int16_t type;
int16_t lotag;
int16_t hitag;
int16_t extra;
};

View file

@ -2765,7 +2765,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe
targetactor->xspr.physAttr = flags;
targetactor->vel.Zero();
if (targetactor->spr.lotag >= kThingBase && targetactor->spr.lotag < kThingMax)
if (targetactor->IsThingActor())
ChangeActorStat(targetactor, kStatThing); // if it was a thing - restore statnum
}
break;

View file

@ -31,8 +31,8 @@ class CoreActor native
native int16 intangle;
native int16 xint;
native int16 yint;
native int16 inittype; // inittype, type and flags are for Blood.
native int16 lotag, type;
native int16 inittype; // inittype and flags are for Blood.
native int16 lotag;
native int16 hitag, flags;
native int16 extra;
native int16 detail;