From 5d78b228b74cae13c73fd8903f9de57e50fda236 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Nov 2021 02:11:00 +0100 Subject: [PATCH] - the final bits and pieces in Blood --- source/games/blood/src/gameutil.cpp | 6 ++---- source/games/blood/src/nnexts.cpp | 5 +---- source/games/blood/src/player.cpp | 19 +++++++++---------- source/games/blood/src/prediction.cpp | 2 +- source/games/blood/src/seq.cpp | 2 +- source/games/blood/src/sfx.cpp | 4 ++-- source/games/blood/src/sound.h | 6 +----- source/games/blood/src/triggers.cpp | 12 +++++------- source/games/blood/src/view.cpp | 2 +- source/games/blood/src/warp.cpp | 12 ++++++------ source/games/blood/src/weapon.cpp | 1 - 11 files changed, 29 insertions(+), 42 deletions(-) diff --git a/source/games/blood/src/gameutil.cpp b/source/games/blood/src/gameutil.cpp index e1417eb6a..cbbfc6d53 100644 --- a/source/games/blood/src/gameutil.cpp +++ b/source/games/blood/src/gameutil.cpp @@ -357,8 +357,7 @@ int HitScan(DBloodActor *actor, int z, int dx, int dy, int dz, unsigned int nMas vec3_t pos = { x, y, z }; hitdata_t hitData; hitData.pos.z = gHitInfo.hitz; - int nSector = pSprite->sectnum; - hitscan(&pos, nSector, dx, dy, dz << 4, &hitData, nMask); + hitscan(&pos, pSprite->sectnum, dx, dy, dz << 4, &hitData, nMask); gHitInfo.set(&hitData); hitscangoal.x = hitscangoal.y = 0x1ffffff; pSprite->cstat = bakCstat; @@ -406,8 +405,7 @@ int VectorScan(DBloodActor *actor, int nOffset, int nZOffset, int dx, int dy, in vec3_t pos = { x1, y1, z1 }; hitdata_t hitData; hitData.pos.z = gHitInfo.hitz; - int nSector = pSprite->sectnum; - hitscan(&pos, nSector, dx, dy, dz << 4, &hitData, CLIPMASK1); + hitscan(&pos, pSprite->sectnum, dx, dy, dz << 4, &hitData, CLIPMASK1); gHitInfo.set(&hitData); hitscangoal.x = hitscangoal.y = 0x1ffffff; pSprite->cstat = bakCstat; diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index d8ee35141..cd26155c3 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -6143,10 +6143,7 @@ int useCondition(DBloodActor* sourceactor, const EVENT& event) bool srcIsCondition = false; - int objType = event.isActor() ? SS_SPRITE : event.isSector() ? SS_SECTOR : SS_WALL; - int objIndex = event.isActor() ? -1 : event.isSector() ? sectnum(event.getSector()) : wallnum(event.getWall()); - auto pActor = event.isActor() ? event.getActor() : nullptr; - + auto const pActor = event.isActor() ? event.getActor() : nullptr; if (event.isActor() && pActor == nullptr) return -1; if (event.isActor() && pActor != sourceactor) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index d415d3409..50752b922 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -1672,18 +1672,18 @@ void playerProcess(PLAYER *pPlayer) int dw = pSprite->clipdist<<2; if (!gNoClip) { - int nSector = pSprite->sectnum; - if (pushmove(&pSprite->pos, &nSector, dw, dzt, dzb, CLIPMASK0) == -1) + auto pSector = pSprite->sector(); + if (pushmove(&pSprite->pos, &pSector, dw, dzt, dzb, CLIPMASK0) == -1) actDamageSprite(actor, actor, kDamageFall, 500<<4); - if (pSprite->sectnum != nSector) + if (pSprite->sector() != pSector) { - if (nSector == -1) + if (pSector == nullptr) { - nSector = pSprite->sectnum; + pSector = pSprite->sector(); actDamageSprite(actor, actor, kDamageFall, 500<<4); } - assert(validSectorIndex(nSector)); - ChangeActorSect(actor, nSector); + else + ChangeActorSect(actor, pSector); } } ProcessInput(pPlayer); @@ -1751,11 +1751,10 @@ void playerProcess(PLAYER *pPlayer) if (pPlayer->posture == 1) { pPlayer->isUnderwater = 1; - int nSector = pSprite->sectnum; - auto link = getLowerLink(nSector); + auto link = pSprite->sector()->lowerLink; if (link && (link->s().type == kMarkerLowGoo || link->s().type == kMarkerLowWater)) { - if (getceilzofslope(nSector, pSprite->x, pSprite->y) > pPlayer->zView) + if (getceilzofslopeptr(pSprite->sector(), pSprite->x, pSprite->y) > pPlayer->zView) pPlayer->isUnderwater = 0; } } diff --git a/source/games/blood/src/prediction.cpp b/source/games/blood/src/prediction.cpp index fb77e1c89..fdc5e5109 100644 --- a/source/games/blood/src/prediction.cpp +++ b/source/games/blood/src/prediction.cpp @@ -452,7 +452,7 @@ static void fakeMoveDude(spritetype *pSprite) pTempSprite->x = predict.x; pTempSprite->y = predict.y; pTempSprite->z = predict.z; - pTempSprite->sectnum = predict.sectnum; + pTempSprite-> sectnum = predict. sectnum; int ceilZ, floorZ; Collision ceilColl, floorColl; GetZRange(pTempSprite, &ceilZ, &ceilColl, &floorZ, &floorColl, wd, CLIPMASK0); diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index 6d4bd666a..13a8b9985 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -352,7 +352,7 @@ void SEQINST::Update() spritetype* pSprite = &actor->s(); if (!VanillaMode() && pSequence->frames[frameIndex].surfaceSound && actor->zvel == 0 && actor->xvel != 0) { - if (getUpperLink(pSprite->sectnum)) break; // don't play surface sound for stacked sectors + if (pSprite->sector()->upperLink) break; // don't play surface sound for stacked sectors int surf = tileGetSurfType(pSprite->sector()->floorpicnum); if (!surf) break; static int surfSfxMove[15][4] = { diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index bcdd35f59..381f3a626 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -148,7 +148,7 @@ FSoundID getSfx(FSoundID soundId, float &attenuation, int &pitch, int &relvol) return soundId; } -void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector) +void sfxPlay3DSound(int x, int y, int z, int soundId, sectortype* pSector) { if (!SoundEnabled() || soundId < 0) return; auto sid = soundEngine->FindSoundByResID(soundId); @@ -166,7 +166,7 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector) if (sfx && sfx->LoopStart >= 0) flags |= CHANF_LOOP; auto chan = soundEngine->StartSound(SOURCE_Unattached, nullptr, &svec, -1, flags, sid, (0.8f / 80.f) * relvol, attenuation, nullptr, pitch / 65536.f); - if (chan) chan->UserData = nSector; + if (chan) chan->UserData = sectnum(pSector); } void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int playchannel, int playflags, int pitch, int volume) diff --git a/source/games/blood/src/sound.h b/source/games/blood/src/sound.h index 1b51b934b..d00bc97be 100644 --- a/source/games/blood/src/sound.h +++ b/source/games/blood/src/sound.h @@ -50,11 +50,7 @@ void sndProcess(void); void sndTerm(void); void sndInit(void); -void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector); -void sfxPlay3DSound(int x, int y, int z, int soundId, sectortype* pSector) -{ - sfxPlay3DSound(x, y, z, soundId, sectnum(pSector)); -} +void sfxPlay3DSound(int x, int y, int z, int soundId, sectortype* pSector); void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0); void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0); void sfxKill3DSound(spritetype *pSprite, int a2 = -1, int a3 = -1); diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index f302a4e5d..8748d03db 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -226,7 +226,7 @@ void LifeLeechOperate(DBloodActor* actor, EVENT event) int y = pTarget->y; int z = pTarget->z; int nDist = approxDist(x - pSprite->x, y - pSprite->y); - if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sectnum, x, y, z, pTarget->sectnum)) + if (nDist != 0 && cansee(pSprite->x, pSprite->y, top, pSprite->sector(), x, y, z, pTarget->sector())) { int t = DivScale(nDist, 0x1aaaaa, 12); x += (target->xvel*t)>>12; @@ -1364,9 +1364,9 @@ void OperateDoor(sectortype* pSector, EVENT event, BUSYID busyWave) } } -bool SectorContainsDudes(int nSector) +bool SectorContainsDudes(sectortype * pSector) { - BloodSectIterator it(nSector); + BloodSectIterator it(pSector); while (auto actor = it.Next()) { spritetype* pSprite = &actor->s(); @@ -1398,7 +1398,7 @@ void OperateTeleport(sectortype* pSector) spritetype *pDest = &nDest->s(); assert(pDest->statnum == kStatMarker); assert(pDest->type == kMarkerWarpDest); - assert(validSectorIndex(pDest->sectnum)); + assert(pDest->insector()); BloodSectIterator it(pSector); while (auto actor = it.Next()) { @@ -1411,7 +1411,7 @@ void OperateTeleport(sectortype* pSector) pPlayer = &gPlayer[pSprite->type-kDudePlayer1]; else pPlayer = NULL; - if (bPlayer || !SectorContainsDudes(pDest->sectnum)) + if (bPlayer || !SectorContainsDudes(pDest->sector())) { if (!(gGameOptions.uNetGameFlags & 2)) { @@ -1496,8 +1496,6 @@ void OperateSector(sectortype* pSector, EVENT event) return; #endif - int nSector = sectnum(pSector); - switch (event.cmd) { case kCmdLock: pXSector->locked = 1; diff --git a/source/games/blood/src/view.cpp b/source/games/blood/src/view.cpp index 333bfc7fd..cdcd6a76c 100644 --- a/source/games/blood/src/view.cpp +++ b/source/games/blood/src/view.cpp @@ -506,7 +506,7 @@ void renderCrystalBall() int vd8 = pOther->pSprite->x; int vd4 = pOther->pSprite->y; int vd0 = pOther->zView; - int vcc = pOther->pSprite->sectnum; + int vcc = pOther->pSprite-> sectnum; int v50 = pOther->pSprite->ang; int v54 = 0; if (pOther->flickerEffect) diff --git a/source/games/blood/src/warp.cpp b/source/games/blood/src/warp.cpp index 76a73a48e..49442aeda 100644 --- a/source/games/blood/src/warp.cpp +++ b/source/games/blood/src/warp.cpp @@ -188,9 +188,9 @@ void warpInit(void) int CheckLink(DBloodActor *actor) { auto pSprite = &actor->s(); - int nSector = pSprite->sectnum; - auto aUpper = getUpperLink(nSector); - auto aLower = getLowerLink(nSector); + auto pSector = pSprite->sector(); + auto aUpper = pSector->upperLink; + auto aLower = pSector->lowerLink; if (aUpper) { spritetype* pUpper = &aUpper->s(); @@ -204,7 +204,7 @@ int CheckLink(DBloodActor *actor) aLower = aUpper->GetOwner(); assert(aLower); spritetype *pLower = &aLower->s(); - assert(validSectorIndex(pLower->sectnum)); + assert(pLower->insector()); ChangeActorSect(actor, pLower->sector()); pSprite->x += pLower->x-pUpper->x; pSprite->y += pLower->y-pUpper->y; @@ -231,7 +231,7 @@ int CheckLink(DBloodActor *actor) aUpper = aLower->GetOwner(); assert(aUpper); spritetype *pUpper = &aUpper->s(); - assert(validSectorIndex(pUpper->sectnum)); + assert(pUpper->insector()); ChangeActorSect(actor, pUpper->sector()); pSprite->x += pUpper->x-pLower->x; pSprite->y += pUpper->y-pLower->y; @@ -265,7 +265,7 @@ int CheckLink(int *x, int *y, int *z, sectortype** pSector) lower = upper->GetOwner(); assert(lower); spritetype *pLower = &lower->s(); - assert(validSectorIndex(pLower->sectnum)); + assert(pLower->insector()); *pSector = pLower->sector(); *x += pLower->x-pUpper->x; *y += pLower->y-pUpper->y; diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index a2b29b704..64841a503 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -2662,7 +2662,6 @@ void teslaHit(DBloodActor *missileactor, int a2) int y = pMissile->y; int z = pMissile->z; int nDist = 300; - int nSector = pMissile->sectnum; auto pSector = pMissile->sector(); auto owneractor = missileactor->GetOwner(); const bool newSectCheckMethod = !cl_bloodvanillaexplosions && !VanillaMode(); // use new sector checking logic