- made spritetype::sectnum a pointer.

This commit is contained in:
Christoph Oelckers 2021-12-06 17:40:33 +01:00
parent 6a43a270fa
commit 6d432fca0a
4 changed files with 12 additions and 11 deletions

View file

@ -611,29 +611,29 @@ inline bool testgotpic(int32_t tilenume, bool reset = false)
inline sectortype* spritetypebase::sector() const
{
return !validSectorIndex(sectnum)? nullptr : &::sector[sectnum];
return sectp;
}
inline int spritetypebase::sectno() const
{
return sectnum;
return sectp? ::sector.IndexOf(sectp) : -1;
}
inline void spritetypebase::setsector(sectortype* sect)
{
// place for asserts.
sectnum = sect? ::sector.IndexOf(sect) : -1;
sectp = sect;
}
inline void spritetypebase::setsector(int sec)
{
// place for asserts.
sectnum = validSectorIndex(sec)? sec : -1;
sectp = validSectorIndex(sec)? &::sector[sec] : nullptr;
}
inline bool spritetypebase::insector() const
{
return validSectorIndex(sectnum);
return sectp != nullptr;
}

View file

@ -339,13 +339,14 @@ struct spritetypebase
};
vec3_t opos;
};
sectortype* sectp;
uint16_t cstat;
int16_t picnum;
int8_t shade;
uint8_t pal, clipdist, blend;
uint8_t xrepeat, yrepeat;
int8_t xoffset, yoffset;
int16_t sectnum, statnum;
int16_t statnum;
int16_t oang, ang;
int16_t xvel;
int16_t yvel;
@ -424,12 +425,12 @@ struct spritetype : public spritetypebase
void clear()
{
int sect = sectnum;
auto sect = sectp;
int stat = statnum;
int save = time; // this may not be cleared ever!!!
memset(this, 0, sizeof(*this));
time = save;
sectnum = sect;
sectp = sect;
statnum = stat;
}
@ -490,7 +491,7 @@ struct tspritetype : public spritetypebase
yrepeat = spr->yrepeat;
xoffset = spr->xoffset;
yoffset = spr->yoffset;
sectnum = spr->sectnum;
sectp = spr->sectp;
statnum = spr->statnum;
ang = spr->ang;
oang = spr->oang;

View file

@ -462,7 +462,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, spritetype &c, spritet
("xoffset", c.xoffset, def->xoffset)
("yoffset", c.yoffset, def->yoffset)
("statnum", c.statnum)
("sectnum", c.sectnum)
("sectnum", c.sectp)
("ang", c.ang, def->ang)
("owner", c.owner, def->owner)
("xvel", c.xvel, def->xvel)

View file

@ -582,7 +582,7 @@ int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx)
tsp->yrepeat = pTSprite->yrepeat;
tsp->ang = pTSprite->ang;
tsp->ownerActor = pTSprite->ownerActor;
tsp->sectnum = pTSprite->sectnum;
tsp->sectp = pTSprite->sectp;
tsp->cstat = pTSprite->cstat |= 0x80;
tsp->cstat2 = pTSprite->cstat2;
tsp->statnum = esi;