From f0b7fe4addfa1a705b4c7935ea1d831763d6471b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 30 Dec 2021 16:36:04 +0100 Subject: [PATCH] - use setsector from DCoreActor. Also did a bit of cleanup --- source/core/actorlist.cpp | 8 ++++---- source/core/coreactor.h | 6 ++++++ source/core/maphack.cpp | 2 +- source/core/maploader.cpp | 2 +- source/core/maptypes.h | 14 -------------- source/games/blood/src/_polymost.cpp | 2 +- source/games/blood/src/animatesprite.cpp | 4 ++-- source/games/duke/src/actors.cpp | 2 +- source/games/duke/src/player_d.cpp | 4 ++-- source/games/exhumed/src/set.cpp | 2 +- source/games/sw/src/draw.cpp | 8 ++++---- source/games/sw/src/quake.cpp | 1 - source/games/sw/src/zombie.cpp | 1 - 13 files changed, 23 insertions(+), 33 deletions(-) diff --git a/source/core/actorlist.cpp b/source/core/actorlist.cpp index 693b2a5ea..2db2e60da 100644 --- a/source/core/actorlist.cpp +++ b/source/core/actorlist.cpp @@ -236,7 +236,7 @@ static void AddSectTail(DCoreActor *actor, sectortype* sect) else sect->firstEntry = actor; sect->lastEntry = actor; assert(ValidateSectList(sect)); - actor->spr.setsector(sect); + actor->setsector(sect); actor->link_sector = sect; GC::WriteBarrier(actor); GC::WriteBarrier(tail); @@ -260,7 +260,7 @@ static void AddSectHead(DCoreActor *actor, sectortype* sect) else sect->lastEntry = actor; sect->firstEntry = actor; assert(ValidateSectList(sect)); - actor->spr.setsector(sect); + actor->setsector(sect); actor->link_sector = sect; GC::WriteBarrier(actor); GC::WriteBarrier(head); @@ -297,7 +297,7 @@ static void RemoveActorSect(DCoreActor* actor) assert(ValidateSectList(actor->link_sector, actor)); actor->nextSect = actor->prevSect = nullptr; - actor->spr.setsector(nullptr); + actor->setsector(nullptr); actor->link_sector = nullptr; GC::WriteBarrier(prev); GC::WriteBarrier(next); @@ -316,7 +316,7 @@ static void InsertActorSect(DCoreActor* actor, sectortype* sector, bool tail) if (!sector) { actor->link_sector = nullptr; - actor->spr.setsector(nullptr); + actor->setsector(nullptr); return; } if (isSafe() || tail) AddSectTail(actor, sector); diff --git a/source/core/coreactor.h b/source/core/coreactor.h index 2fa6f1c8f..45038b3f2 100644 --- a/source/core/coreactor.h +++ b/source/core/coreactor.h @@ -52,6 +52,12 @@ public: return spr.sectp != nullptr; } + void setsector(sectortype* sect) + { + // place for asserts. + spr.sectp = sect; + } + }; // holds pointers to the game-side actors. diff --git a/source/core/maphack.cpp b/source/core/maphack.cpp index b6e1b66fa..c78a85afd 100644 --- a/source/core/maphack.cpp +++ b/source/core/maphack.cpp @@ -148,7 +148,7 @@ static int32_t LoadMapHack(const char *filename, SpawnSpriteDef& sprites) { if (currentsprite != -1 && validateSprite()) { - sprites.sprites[currentsprite].setsector(sc.Number); + sprites.sprites[currentsprite].sectp = §or[sc.Number]; } } } diff --git a/source/core/maploader.cpp b/source/core/maploader.cpp index 6b7ff51e0..323f1fdd5 100644 --- a/source/core/maploader.cpp +++ b/source/core/maploader.cpp @@ -284,7 +284,7 @@ void validateSprite(spritetype& spr, int sectnum, int index) spr.statnum = MAXSTATUS; sectnum = -1; } - spr.setsector(sectnum); + spr.sectp = §or[sectnum]; } static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno) diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 329ed36b4..1d7c7be13 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -529,8 +529,6 @@ struct spritetypebase sectortype* sector() const; int sectno() const; - void setsector(sectortype*); - void setsector(int); }; @@ -636,18 +634,6 @@ inline int spritetypebase::sectno() const return sectp? ::sector.IndexOf(sectp) : -1; } -inline void spritetypebase::setsector(sectortype* sect) -{ - // place for asserts. - sectp = sect; -} - -inline void spritetypebase::setsector(int sec) -{ - // place for asserts. - sectp = validSectorIndex(sec)? &::sector[sec] : nullptr; -} - inline sectortype* walltype::nextSector() const { return !validSectorIndex(nextsector)? nullptr : &::sector[nextsector]; diff --git a/source/games/blood/src/_polymost.cpp b/source/games/blood/src/_polymost.cpp index 940877387..46ddc2b06 100644 --- a/source/games/blood/src/_polymost.cpp +++ b/source/games/blood/src/_polymost.cpp @@ -34,7 +34,7 @@ void collectTSpritesForPortal(int x, int y, int i, int interpolation) tspritetype* pTSprite = &pm_tsprite[pm_spritesortcnt++]; *pTSprite = {}; pTSprite->type = actor->spr.type; - pTSprite->setsector(nSector2); + pTSprite->sectp = §or[nSector2]; pTSprite->pos.X = actor->spr.pos.X + dx; pTSprite->pos.Y = actor->spr.pos.Y + dy; pTSprite->pos.Z = actor->spr.pos.Z + dz; diff --git a/source/games/blood/src/animatesprite.cpp b/source/games/blood/src/animatesprite.cpp index 325652eda..8c650e2c3 100644 --- a/source/games/blood/src/animatesprite.cpp +++ b/source/games/blood/src/animatesprite.cpp @@ -99,7 +99,7 @@ tspritetype* viewInsertTSprite(tspritetype* tsprite, int& spritesortcnt, sectort pTSprite->ownerActor = nullptr; pTSprite->type = -spritesortcnt; pTSprite->statnum = nStatnum; - pTSprite->setsector(pSector); + pTSprite->sectp = pSector; spritesortcnt++; if (parentTSprite) { @@ -301,7 +301,7 @@ static tspritetype* viewAddEffect(tspritetype* tsprite, int& spritesortcnt, int pNSprite->pos.Z = pTSprite->pos.Z; assert(pSector); FindSector(pNSprite->pos.X, pNSprite->pos.Y, pNSprite->pos.Z, &pSector); - pNSprite->setsector(pSector); + pNSprite->sectp = pSector; pNSprite->ownerActor = pTSprite->ownerActor; pNSprite->picnum = pTSprite->picnum; pNSprite->cstat |= CSTAT_SPRITE_TRANSLUCENT; diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 1d1a2514e..3d918f393 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -1474,7 +1474,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) (MulScale(actor->spr.xvel, bcos(actor->spr.ang), 14) * TICSPERFRAME) << 11, (MulScale(actor->spr.xvel, bsin(actor->spr.ang), 14) * TICSPERFRAME) << 11, 24L, (4 << 8), (4 << 8), CLIPMASK1, coll); - actor->spr.setsector(sect); + actor->setsector(sect); if (j == kHitWall) { diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index fa7d30579..193154044 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -201,7 +201,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int spawned->spr.pos.X = sx + bsin(sa + 630) / 448; spawned->spr.pos.Y = sy + bsin(sa + 112) / 448; spawned->spr.pos.Z = sz - 256; - spawned->spr.setsector(actor->spr.sector()); + spawned->setsector(actor->spr.sector()); spawned->spr.cstat = CSTAT_SPRITE_YCENTER; spawned->spr.ang = sa; spawned->spr.xrepeat = 2; @@ -1065,7 +1065,7 @@ void shoot_d(DDukeActor* actor, int atwith) auto k = spawn(actor, atwith); if (k) { - k->spr.setsector(sect); + k->setsector(sect); k->spr.pos.X = sx; k->spr.pos.Y = sy; k->spr.pos.Z = sz; diff --git a/source/games/exhumed/src/set.cpp b/source/games/exhumed/src/set.cpp index 5e0c65bb7..6a3d5b7a2 100644 --- a/source/games/exhumed/src/set.cpp +++ b/source/games/exhumed/src/set.cpp @@ -274,7 +274,7 @@ void AISet::Tick(RunListEvent* ev) auto sect = pActor->spr.sector(); pushmove(&pActor->spr.pos, §, pActor->spr.clipdist << 2, 5120, -5120, CLIPMASK0); - pActor->spr.setsector(sect); + pActor->setsector(sect); if (pActor->spr.zvel > 4000) { diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 08fc10abf..cbf91d3a8 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -280,11 +280,11 @@ void DoShadows(tspritetype* tsprite, int& spritesortcnt, tspritetype* tsp, int v return; } - tsp->setsector(sect); + tsp->sectp = sect; *tSpr = *tsp; // shadow is ALWAYS draw last - status is priority tSpr->statnum = MAXSTATUS; - tSpr->setsector(sect); + tSpr->sectp = sect; if ((tsp->yrepeat >> 2) > 4) { @@ -478,7 +478,7 @@ void WarpCopySprite(tspritetype* tsprite, int& spritesortcnt) newTSpr->pos.X = itActor1->spr.pos.X - xoff; newTSpr->pos.Y = itActor1->spr.pos.Y - yoff; newTSpr->pos.Z = itActor1->spr.pos.Z - zoff; - newTSpr->setsector(itActor1->spr.sector()); + newTSpr->sectp = itActor1->spr.sector(); } it2.Reset(sect2); @@ -495,7 +495,7 @@ void WarpCopySprite(tspritetype* tsprite, int& spritesortcnt) auto off = itActor1->spr.pos - newTSpr->pos; newTSpr->pos = itActor->spr.pos - off; - newTSpr->setsector(itActor->spr.sector()); + newTSpr->sectp = itActor->spr.sector(); } } } diff --git a/source/games/sw/src/quake.cpp b/source/games/sw/src/quake.cpp index a6c20763a..ed2cd43f0 100644 --- a/source/games/sw/src/quake.cpp +++ b/source/games/sw/src/quake.cpp @@ -57,7 +57,6 @@ void CopyQuakeSpotToOn(DSWActor* actor) auto actorNew = insertActor(actor->spr.sector(), STAT_QUAKE_SPOT); actorNew->spr = actor->spr; - actorNew->spr.setsector(actor->spr.sector()); actorNew->spr.cstat = 0; actorNew->spr.extra = 0; diff --git a/source/games/sw/src/zombie.cpp b/source/games/sw/src/zombie.cpp index 676a0e408..1e431735f 100644 --- a/source/games/sw/src/zombie.cpp +++ b/source/games/sw/src/zombie.cpp @@ -777,7 +777,6 @@ void SpawnZombie(PLAYERp pp, DSWActor* weaponActor) return; auto actorNew = SpawnActor(STAT_ENEMY, ZOMBIE_RUN_R0, s_ZombieRun[0], pp->cursector, pp->pos.X, pp->pos.Y, pp->pos.Z, pp->angle.ang.asbuild(), 0); - actorNew->spr.setsector(pp->cursector); SetOwner(actorNew, ownerActor); actorNew->spr.pal = actorNew->user.spal = ownerActor->user.spal; actorNew->spr.ang = RANDOM_P2(2048);