- use setsector from DCoreActor.

Also did a bit of cleanup
This commit is contained in:
Christoph Oelckers 2021-12-30 16:36:04 +01:00
parent af6ca40e3d
commit f0b7fe4add
13 changed files with 23 additions and 33 deletions

View file

@ -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);

View file

@ -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.

View file

@ -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 = &sector[sc.Number];
}
}
}

View file

@ -284,7 +284,7 @@ void validateSprite(spritetype& spr, int sectnum, int index)
spr.statnum = MAXSTATUS;
sectnum = -1;
}
spr.setsector(sectnum);
spr.sectp = &sector[sectnum];
}
static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)

View file

@ -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];

View file

@ -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 = &sector[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;

View file

@ -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;

View file

@ -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)
{

View file

@ -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;

View file

@ -274,7 +274,7 @@ void AISet::Tick(RunListEvent* ev)
auto sect = pActor->spr.sector();
pushmove(&pActor->spr.pos, &sect, pActor->spr.clipdist << 2, 5120, -5120, CLIPMASK0);
pActor->spr.setsector(sect);
pActor->setsector(sect);
if (pActor->spr.zvel > 4000)
{

View file

@ -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();
}
}
}

View file

@ -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;

View file

@ -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);