- preparations for xvel wrapping.

Mainly providing alternative names for the spritetype members and redirecting all relevant access to those.
This commit is contained in:
Christoph Oelckers 2022-09-01 16:33:54 +02:00
parent a006482c07
commit aa22e48036
6 changed files with 63 additions and 24 deletions

View file

@ -497,8 +497,8 @@ DEFINE_FIELD_NAMED(DCoreActor, spr.picnum, picnum)
DEFINE_FIELD_NAMED(DCoreActor, spr.statnum, statnum)
//DEFINE_FIELD_NAMED(DCoreActor, spr.angle, angle)
DEFINE_FIELD_NAMED(DCoreActor, spr.pos, pos)
DEFINE_FIELD_NAMED(DCoreActor, spr.xvel, xvel)
DEFINE_FIELD_NAMED(DCoreActor, spr.yvel, yvel)
DEFINE_FIELD_NAMED(DCoreActor, spr.xint, xvel)
DEFINE_FIELD_NAMED(DCoreActor, spr.yint, yvel)
DEFINE_FIELD_NAMED(DCoreActor, spr.inittype, zvel)
DEFINE_FIELD_NAMED(DCoreActor, spr.inittype, inittype)
DEFINE_FIELD_NAMED(DCoreActor, spr.hitag, hitag)

View file

@ -141,6 +141,43 @@ public:
{
spr.inittype = int(spr.inittype * v);
}
void clear_xyvel()
{
spr.xint = spr.yint = 0;
}
// Note: Both Duke and SW use Q12.4 for this, Exhumed doesn't seem to treat horizontal velocity with a fixed factor.
int int_xvel() const
{
return spr.xint;
}
double float_xvel() const
{
return spr.xint * inttoworld;
}
void clear_xvel()
{
spr.xint = 0;
}
void set_int_xvel(int v)
{
spr.xint = v;
}
void add_int_xvel(int v)
{
spr.xint += v;
}
void mul_int_xvel(double v)
{
spr.xint = int(spr.xint * v);
}
// Same as above but with inverted y and z axes to match the renderer's coordinate system.
double interpolatedx(double const smoothratio, int const scale = 16)

View file

@ -613,9 +613,9 @@ tspritetype* renderAddTsprite(tspriteArray& tsprites, DCoreActor* actor)
tspr->sectp = actor->spr.sectp;
tspr->statnum = actor->spr.statnum;
tspr->angle = actor->spr.angle;
tspr->xvel = actor->spr.xvel;
tspr->yvel = actor->spr.yvel;
tspr->inittype = actor->spr.inittype;
tspr->xint = actor->spr.xint;
tspr->yint = actor->spr.yint;
tspr->inittype = actor->spr.inittype; // not used by tsprites.
tspr->lotag = actor->spr.lotag;
tspr->hitag = actor->spr.hitag;
tspr->extra = actor->spr.extra;

View file

@ -316,8 +316,8 @@ static void ReadSpriteV7(FileReader& fr, spritetype& spr, int& secno)
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.intowner = fr.ReadInt16();
spr.xvel = fr.ReadInt16();
spr.yvel = fr.ReadInt16();
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
spr.inittype = fr.ReadInt16();
spr.lotag = fr.ReadInt16();
spr.hitag = fr.ReadInt16();
@ -342,8 +342,8 @@ static void ReadSpriteV6(FileReader& fr, spritetype& spr, int& secno)
spr.picnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.xvel = fr.ReadInt16();
spr.yvel = fr.ReadInt16();
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
spr.inittype = fr.ReadInt16();
spr.intowner = fr.ReadInt16();
secno = fr.ReadInt16();
@ -370,8 +370,8 @@ static void ReadSpriteV5(FileReader& fr, spritetype& spr, int& secno)
spr.picnum = fr.ReadInt16();
spr.intangle = fr.ReadInt16();
spr.angle = DAngle::fromBuild(spr.intangle);
spr.xvel = fr.ReadInt16();
spr.yvel = fr.ReadInt16();
spr.xint = fr.ReadInt16();
spr.yint = fr.ReadInt16();
spr.inittype = fr.ReadInt16();
spr.intowner = fr.ReadInt16();
secno = fr.ReadInt16();

View file

@ -464,8 +464,8 @@ struct spritetypebase
int16_t picnum;
int16_t statnum;
int16_t intangle; // needs to be kept for SW's SP_TAG4
int16_t xvel;
int16_t yvel;
union { int16_t xvel, xint; }; // alternative names are for refactoring and later use where repurposed.
union { int16_t yvel, yint; };
int16_t inittype; // was zvel. All accesses for that have been wrapped. inittype, type and flags are for Blood.
union { int16_t lotag, type; };
union { int16_t hitag, flags; };

View file

@ -363,12 +363,10 @@ void StartRegenerate(DExhumedActor* pActor)
auto pos = Regenerates.Find(pActor);
if (pos >= Regenerates.Size())
{
#if 0
// ?? CHECKME (looks like broken multiplayer stuff - fields get never set properly.)
pActor->spr. xvel = pActor->spr.xrepeat;
pActor->spr. zvel = pActor->spr.shade;
pActor->spr. yvel = pActor->spr.pal;
#endif
// ?? CHECKME
pActor->spr.xint = pActor->spr.xrepeat;
pActor->spr.inittype = pActor->spr.shade;
pActor->spr.yint = pActor->spr.pal;
}
else
{
@ -410,7 +408,7 @@ void DoRegenerates()
}
else
{
if (pActor->spr.xrepeat < pActor->spr.xvel)
if (pActor->spr.xrepeat < pActor->spr.xint)
{
pActor->spr.xrepeat += 2;
pActor->spr.yrepeat += 2;
@ -418,12 +416,16 @@ void DoRegenerates()
}
}
pActor->clear_zvel();
pActor->spr.yrepeat = (uint8_t)pActor->spr.xvel;
pActor->spr.xrepeat = (uint8_t)pActor->spr.xvel;
pActor->spr.pal = (uint8_t)pActor->spr.yvel;
pActor->spr.yrepeat = (uint8_t)pActor->spr.xint;
pActor->spr.xrepeat = (uint8_t)pActor->spr.xint;
pActor->spr.pal = (uint8_t)pActor->spr.yint;
pActor->spr.yint = 0;
pActor->spr.xint = 0;
pActor->spr.yvel = 0;
pActor->spr.xvel = 0;
pActor->clear_zvel();
if (pActor->spr.statnum == kStatExplodeTrigger) {
pActor->spr.cstat = CSTAT_SPRITE_BLOCK_ALL;