From 13186cec6dae4742d5b37f5c9047a62f25dce76a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 18 Dec 2021 20:07:47 +0100 Subject: [PATCH] - the rest of Blood's flags. --- source/core/maptypes.h | 5 ++++- source/games/blood/src/_polymost.cpp | 10 +++++----- source/games/blood/src/gameutil.cpp | 4 ++-- source/games/blood/src/nnexts.cpp | 25 +++++++++++++++---------- source/games/blood/src/player.cpp | 2 +- source/games/blood/src/view.cpp | 4 ++-- 6 files changed, 29 insertions(+), 21 deletions(-) diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 15f4298d3..906dddc1e 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -148,8 +148,11 @@ enum ESpriteBits // names mostly from SW. CSTAT_SPRITE_BREAKABLE = CSTAT_SPRITE_BLOCK_HITSCAN|CSTAT_SPRITE_BLOCK_MISSILE, // Blood flags - CSTAT_SPRITE_BLOOD_BIT2 = 1024, + CSTAT_SPRITE_BLOOD_BIT2 = 1024, // Both of these get set but not checked directly, so no idea what they mean... CSTAT_SPRITE_BLOOD_BIT1 = 4096, + CSTAT_SPRITE_MOVE_FORWARD = 8192, + CSTAT_SPRITE_MOVE_REVERSE = 16384, + CSTAT_SPRITE_MOVE_MASK = CSTAT_SPRITE_MOVE_FORWARD | CSTAT_SPRITE_MOVE_REVERSE, }; typedef TFlags ESpriteFlags; diff --git a/source/games/blood/src/_polymost.cpp b/source/games/blood/src/_polymost.cpp index 80577df0e..e8faaa20c 100644 --- a/source/games/blood/src/_polymost.cpp +++ b/source/games/blood/src/_polymost.cpp @@ -135,7 +135,7 @@ RORHACK: ror_status[i] = testgotpic(4080 + i); fixed_t deliriumPitchI = interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate); DrawMirrors(cX, cY, cZ, cA.asq16(), cH.asq16() + deliriumPitchI, int(gInterpolate), gViewIndex); - int bakCstat = gView->pSprite->cstat; + auto bakCstat = gView->pSprite->cstat; if (gViewPos == 0) { gView->pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; @@ -257,10 +257,10 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int { r_rorphase = 1; int nSector = mirror[i].link; - int bakCstat = 0; + ESpriteFlags bakCstat = 0; if (viewPlayer >= 0) { - bakCstat = gPlayer[viewPlayer].pSprite->cstat; + bakCstat = ESpriteFlags::FromInt(gPlayer[viewPlayer].pSprite->cstat); if (gViewPos == 0) { gPlayer[viewPlayer].pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; @@ -289,10 +289,10 @@ void DrawMirrors(int x, int y, int z, fixed_t a, fixed_t horiz, int smooth, int { r_rorphase = 1; int nSector = mirror[i].link; - int bakCstat = 0; + ESpriteFlags bakCstat = 0; if (viewPlayer >= 0) { - bakCstat = gPlayer[viewPlayer].pSprite->cstat; + bakCstat = ESpriteFlags::FromInt(gPlayer[viewPlayer].pSprite->cstat); if (gViewPos == 0) { gPlayer[viewPlayer].pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index 3b9c6922c..c48245dc9 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -413,14 +413,14 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in spritetype *pOther = &gHitInfo.actor()->s(); if ((pOther->flags & 8) && !(ac & 1)) return 3; - if ((pOther->cstat & 0x30) != 0) + if ((pOther->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != 0) return 3; int nPicnum = pOther->picnum; if (tileWidth(nPicnum) == 0 || tileHeight(nPicnum) == 0) return 3; int height = (tileHeight(nPicnum)*pOther->yrepeat)<<2; int otherZ = pOther->z; - if (pOther->cstat & 0x80) + if (pOther->cstat & CSTAT_SPRITE_YCENTER) otherZ += height / 2; int nOffset = tileTopOffset(nPicnum); if (nOffset) diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 94075de0f..50ca8b80e 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -706,13 +706,14 @@ void nnExtInitModernStuff(TArray& actors) pXSprite->targetX = pXSprite->targetY = pXSprite->targetZ = pXSprite->sysData2 = -1; actor->SetTarget(nullptr); ChangeActorStat(actor, kStatModernCondition); - int oldStat = pSprite->cstat; pSprite->cstat = 0x30; + auto oldStat = pSprite->cstat; + pSprite->cstat = CSTAT_SPRITE_ALIGNMENT_SLOPE; if (oldStat & CSTAT_SPRITE_BLOCK) pSprite->cstat |= CSTAT_SPRITE_BLOCK; - if (oldStat & 0x2000) pSprite->cstat |= 0x2000; - else if (oldStat & 0x4000) pSprite->cstat |= 0x4000; + if (oldStat & CSTAT_SPRITE_MOVE_FORWARD) pSprite->cstat |= CSTAT_SPRITE_MOVE_FORWARD; + else if (oldStat & CSTAT_SPRITE_MOVE_REVERSE) pSprite->cstat |= CSTAT_SPRITE_MOVE_REVERSE; pSprite->cstat |= CSTAT_SPRITE_INVISIBLE; break; @@ -1869,7 +1870,7 @@ void debrisMove(int listIndex) else if (floorColl.type == kHitSprite) { - if ((floorColl.actor()->s().cstat & 0x30) == 0) + if ((floorColl.actor()->s().cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == 0) { actor->xvel += MulScale(4, pSprite->x - floorColl.actor()->s().x, 2); actor->yvel += MulScale(4, pSprite->y - floorColl.actor()->s().y, 2); @@ -2805,16 +2806,19 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe // data4 = sprite cstat if (valueIsBetween(pXSource->data4, -1, 65535)) { - old = pSprite->cstat; + auto old = pSprite->cstat; // set new cstat if ((pSource->flags & kModernTypeFlag1)) pSprite->cstat |= pXSource->data4; // relative else pSprite->cstat = pXSource->data4 & 0xffff; // absolute // and handle exceptions - if ((old & 0x1000) && !(pSprite->cstat & 0x1000)) pSprite->cstat |= 0x1000; //kSpritePushable - if ((old & CSTAT_SPRITE_YCENTER) && !(pSprite->cstat & CSTAT_SPRITE_YCENTER)) pSprite->cstat |= CSTAT_SPRITE_YCENTER; + if ((old & CSTAT_SPRITE_BLOOD_BIT1)) pSprite->cstat |= CSTAT_SPRITE_BLOOD_BIT1; //kSpritePushable + if ((old & CSTAT_SPRITE_YCENTER)) pSprite->cstat |= CSTAT_SPRITE_YCENTER; + pSprite->cstat |= (old & CSTAT_SPRITE_MOVE_MASK); +#if 0 + // looks very broken. if (old & 0x6000) { if (!(pSprite->cstat & 0x6000)) @@ -2824,6 +2828,7 @@ void usePropertiesChanger(DBloodActor* sourceactor, int objType, sectortype* pSe else if ((old & 0x2000) && !(pSprite->cstat & 0x2000)) pSprite->cstat |= 0x2000; // kSpriteMoveForward, kSpriteMoveFloor else if ((old & 0x4000) && !(pSprite->cstat & 0x4000)) pSprite->cstat |= 0x4000; // kSpriteMoveReverse, kSpriteMoveCeiling } +#endif } } break; @@ -3241,8 +3246,8 @@ void useSectorWindGen(DBloodActor* sourceactor, sectortype* pSector) pSource->ang = nnExtRandom(-kAng360, kAng360) & 2047; } } - else if (pSource->cstat & 0x2000) pSource->ang += pXSource->data4; - else if (pSource->cstat & 0x4000) pSource->ang -= pXSource->data4; + else if (pSource->cstat & CSTAT_SPRITE_MOVE_FORWARD) pSource->ang += pXSource->data4; + else if (pSource->cstat & CSTAT_SPRITE_MOVE_REVERSE) pSource->ang -= pXSource->data4; else if (pXSource->sysData1 == 0) { if ((ang += pXSource->data4) >= kAng180) pXSource->sysData1 = 1; @@ -3323,7 +3328,7 @@ void useSpriteDamager(DBloodActor* sourceactor, int objType, sectortype* targSec GetActorExtents(sourceactor, &top, &bottom); floor = (bottom >= pSector->floorz); ceil = (top <= pSector->ceilingz); - wall = (pSource->cstat & 0x10); + wall = (pSource->cstat & CSTAT_SPRITE_ALIGNMENT_WALL); enter = (!floor && !ceil && !wall); BloodSectIterator it(targSect); while (auto iactor = it.Next()) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 584971184..b5750080e 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -684,7 +684,7 @@ void playerStart(int nPlayer, int bNewLevel) pXSprite->burnTime = 0; actor->SetBurnSource(nullptr); pPlayer->pXSprite->health = pDudeInfo->startHealth<<4; - pPlayer->pSprite->cstat &= (unsigned short)~32768; + pPlayer->pSprite->cstat &= ~CSTAT_SPRITE_INVISIBLE; pPlayer->bloodlust = 0; pPlayer->horizon.horiz = pPlayer->horizon.horizoff = q16horiz(0); pPlayer->slope = 0; diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 87801b22e..4d8cba2ff 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -170,7 +170,7 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, sectortyp int vY = MulScale(-Sin(nAng), 1280, 30); int vZ = FixedToInt(MulScale(zm, 1280, 3))-(16<<8); int bakCstat = pSprite->cstat; - pSprite->cstat &= ~256; + pSprite->cstat &= ~CSTAT_SPRITE_BLOCK_HITSCAN; assert(validSectorIndex(*vsectnum)); FindSector(*pX, *pY, *pZ, vsectnum); int nHSector; @@ -669,7 +669,7 @@ void viewDrawScreen(bool sceneonly) if (testnewrenderer) { fixedhoriz deliriumPitchI = q16horiz(interpolatedvalue(IntToFixed(deliriumPitchO), IntToFixed(deliriumPitch), gInterpolate)); - int bakCstat = gView->pSprite->cstat; + auto bakCstat = gView->pSprite->cstat; gView->pSprite->cstat |= (gViewPos == 0) ? CSTAT_SPRITE_INVISIBLE : CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP; render_drawrooms(gView->pSprite, { cX, cY, cZ }, sectnum(pSector), cA, cH + deliriumPitchI, rotscrnang, gInterpolate); gView->pSprite->cstat = bakCstat;