From e4e5bd096694f4340121d273134a2a3294716136 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Nov 2021 01:02:42 +0100 Subject: [PATCH] - CFX::fxSpawnActor --- source/games/blood/src/fx.cpp | 10 +++++----- source/games/blood/src/fx.h | 6 +----- source/games/blood/src/gib.cpp | 6 +++--- source/games/blood/src/nnexts.cpp | 4 ++-- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/source/games/blood/src/fx.cpp b/source/games/blood/src/fx.cpp index 9408c058d..e4174c98a 100644 --- a/source/games/blood/src/fx.cpp +++ b/source/games/blood/src/fx.cpp @@ -124,12 +124,12 @@ void CFX::remove(DBloodActor* actor) actPostSprite(actor, kStatFree); } -DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsigned int a6) +DBloodActor* CFX::fxSpawnActor(FX_ID nFx, sectortype* pSector, int x, int y, int z, unsigned int a6) { - if (nSector < 0 || nSector >= numsectors) + if (pSector == nullptr) return nullptr; - int nSector2 = nSector; - if (!FindSector(x, y, z, &nSector2)) + auto pSector2 = pSector; + if (!FindSector(x, y, z, &pSector2)) return nullptr; if (adult_lockout && gGameOptions.nGameType <= 0) { @@ -161,7 +161,7 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, int nSector, int x, int y, int z, unsi return nullptr; destroy(iactor); } - auto actor = actSpawnSprite(§or[nSector], x, y, z, 1, 0); + auto actor = actSpawnSprite(pSector, x, y, z, 1, 0); spritetype* pSprite = &actor->s(); pSprite->type = nFx; pSprite->picnum = pFX->picnum; diff --git a/source/games/blood/src/fx.h b/source/games/blood/src/fx.h index f9b2f2f58..ed1ef8a3d 100644 --- a/source/games/blood/src/fx.h +++ b/source/games/blood/src/fx.h @@ -93,11 +93,7 @@ class CFX { public: void destroy(DBloodActor*); void remove(DBloodActor*); - DBloodActor* fxSpawnActor(FX_ID, int, int, int, int, unsigned int); - DBloodActor* fxSpawnActor(FX_ID a, sectortype* b, int c, int d, int e, unsigned int f) - { - return fxSpawnActor(a, sectnum(b), c, d, e, f); - } + DBloodActor* fxSpawnActor(FX_ID a, sectortype* b, int c, int d, int e, unsigned int f); void fxProcess(void); }; diff --git a/source/games/blood/src/gib.cpp b/source/games/blood/src/gib.cpp index 974a47a0c..c544557f8 100644 --- a/source/games/blood/src/gib.cpp +++ b/source/games/blood/src/gib.cpp @@ -266,14 +266,14 @@ int ChanceToCount(int a1, int a2) void GibFX(DBloodActor* actor, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *pVel) { spritetype* pSprite = &actor->s(); - int nSector = pSprite->sectnum; + auto pSector = pSprite->sector(); if (adult_lockout && gGameOptions.nGameType == 0 && pGFX->fxId == FX_13) return; CGibPosition gPos(pSprite->x, pSprite->y, pSprite->z); if (pPos) gPos = *pPos; int32_t ceilZ, floorZ; - getzsofslope(nSector, gPos.x, gPos.y, &ceilZ, &floorZ); + getzsofslopeptr(pSector, gPos.x, gPos.y, &ceilZ, &floorZ); int nCount = ChanceToCount(pGFX->chance, pGFX->at9); int dz1 = floorZ-gPos.z; int dz2 = gPos.z-ceilZ; @@ -288,7 +288,7 @@ void GibFX(DBloodActor* actor, GIBFX *pGFX, CGibPosition *pPos, CGibVelocity *pV gPos.y = pSprite->y+MulScale(pSprite->clipdist<<2, Sin(nAngle), 30); gPos.z = bottom-Random(bottom-top); } - auto pFX = gFX.fxSpawnActor(pGFX->fxId, nSector, gPos.x, gPos.y, gPos.z, 0); + auto pFX = gFX.fxSpawnActor(pGFX->fxId, pSector, gPos.x, gPos.y, gPos.z, 0); if (pFX) { if (pGFX->at1 < 0) diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 5522a0ee2..86b86386c 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1833,7 +1833,7 @@ void debrisMove(int listIndex) switch (tileGetSurfType(floorColl)) { case kSurfLava: - if ((pFX = gFX.fxSpawnActor(FX_10, pSprite->sectnum, pSprite->x, pSprite->y, floorZ, 0)) == NULL) break; + if ((pFX = gFX.fxSpawnActor(FX_10, pSprite->sector(), pSprite->x, pSprite->y, floorZ, 0)) == NULL) break; for (i = 0; i < 7; i++) { if ((pFX2 = gFX.fxSpawnActor(FX_14, pFX->s().sector(), pFX->s().x, pFX->s().y, pFX->s().z, 0)) == NULL) continue; @@ -6282,7 +6282,7 @@ void useRandomItemGen(DBloodActor* actor) spritetype* pItem = &iactor->s(); if ((unsigned int)pItem->type == pXSource->dropMsg && pItem->x == pSource->x && pItem->y == pSource->y && pItem->z == pSource->z) { - gFX.fxSpawnActor((FX_ID)29, pSource->sectnum, pSource->x, pSource->y, pSource->z, 0); + gFX.fxSpawnActor((FX_ID)29, pSource->sector(), pSource->x, pSource->y, pSource->z, 0); pItem->type = kSpriteDecoration; actPostSprite(iactor, kStatFree); break;