- floatified DoVatorMove and got rid of int_oz.

This commit is contained in:
Christoph Oelckers 2022-08-21 09:40:31 +02:00
parent af7e63137f
commit 30e6db9e3b
2 changed files with 26 additions and 28 deletions

View file

@ -930,7 +930,6 @@ struct USER
memset(&WallP, 0, sizeof(USER) - myoffsetof(USER, WallP));
}
int int_oz() const { return oz * zworldtoint; }
int int_loz() const { return loz * zworldtoint; }
int int_hiz() const { return hiz * zworldtoint; }
int int_z_tgt() const { return z_tgt * zworldtoint; }

View file

@ -322,39 +322,38 @@ void MoveSpritesWithSector(sectortype* sect, int z_amt, bool type)
}
}
int DoVatorMove(DSWActor* actor, int *lptr)
int DoVatorMove(DSWActor* actor, double *lptr)
{
int zval;
int move_amt;
zval = *lptr;
double zval = *lptr;
// if LESS THAN goal
if (zval < actor->user.int_z_tgt())
if (zval < actor->user.z_tgt)
{
// move it DOWN
zval += (synctics * actor->user.jump_speed);
zval += (synctics * actor->user.jump_speed) * zinttoworld;
actor->user.jump_speed += actor->user.vel_rate * synctics;
// if the other way make it equal
if (zval > actor->user.int_z_tgt())
zval = actor->user.int_z_tgt();
if (zval > actor->user.z_tgt)
zval = actor->user.z_tgt;
}
// if GREATER THAN goal
if (zval > actor->user.int_z_tgt())
if (zval > actor->user.z_tgt)
{
// move it UP
zval -= (synctics * actor->user.jump_speed);
zval -= (synctics * actor->user.jump_speed) * zinttoworld;
actor->user.jump_speed += actor->user.vel_rate * synctics;
if (zval < actor->user.int_z_tgt())
zval = actor->user.int_z_tgt();
if (zval < actor->user.z_tgt)
zval = actor->user.z_tgt;
}
move_amt = zval - *lptr;
move_amt = int((zval - *lptr) * zworldtoint);
*lptr = zval;
return move_amt;
@ -364,7 +363,7 @@ int DoVatorMove(DSWActor* actor, int *lptr)
int DoVator(DSWActor* actor)
{
sectortype* sectp = actor->sector();
int zval;
double zval;
int amt;
// actor->user.sz - where the sector z started
@ -375,21 +374,21 @@ int DoVator(DSWActor* actor)
if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP))
{
zval = sectp->int_ceilingz();
zval = sectp->ceilingz;
amt = DoVatorMove(actor, &zval);
sectp->set_int_ceilingz(zval);
sectp->setceilingz(zval);
MoveSpritesWithSector(actor->sector(), amt, true); // ceiling
}
else
{
zval = sectp->int_floorz();
zval = sectp->floorz;
amt = DoVatorMove(actor, &zval);
sectp->set_int_floorz(zval);
sectp->setfloorz(zval);
MoveSpritesWithSector(actor->sector(), amt, false); // floor
}
// EQUAL this entry has finished
if (zval == actor->user.int_z_tgt())
if (zval == actor->user.z_tgt)
{
// in the ON position
if (actor->user.z_tgt == actor->spr.pos.Z)
@ -438,7 +437,7 @@ int DoVator(DSWActor* actor)
}
// setup to go back to the original z
if (zval != actor->user.int_oz())
if (zval != actor->user.oz)
{
if (actor->user.WaitTics)
actor->user.Tics = actor->user.WaitTics;
@ -523,32 +522,32 @@ int DoVator(DSWActor* actor)
int DoVatorAuto(DSWActor* actor)
{
sectortype* sectp = actor->sector();
int zval;
double zval;
int amt;
if (actor->spr.cstat & (CSTAT_SPRITE_YFLIP))
{
zval = sectp->int_ceilingz();
zval = sectp->ceilingz;
amt = DoVatorMove(actor, &zval);
sectp->set_int_ceilingz(zval);
sectp->setceilingz(zval);
MoveSpritesWithSector(actor->sector(), amt, true); // ceiling
}
else
{
zval = sectp->int_floorz();
zval = sectp->floorz;
amt = DoVatorMove(actor, &zval);
sectp->set_int_floorz(zval);
sectp->setfloorz(zval);
MoveSpritesWithSector(actor->sector(), amt, false); // floor
}
// EQUAL this entry has finished
if (zval == actor->user.int_z_tgt())
if (zval == actor->user.z_tgt)
{
// in the UP position
if (actor->user.z_tgt == actor->spr.pos.Z)
{
// change target
actor->user.z_tgt = actor->user.int_upos().Z * zinttoworld;
actor->user.z_tgt = actor->user.pos.Z;
actor->user.vel_rate = -actor->user.vel_rate;
actor->user.Tics = actor->user.WaitTics;
@ -557,7 +556,7 @@ int DoVatorAuto(DSWActor* actor)
}
else
// in the DOWN position
if (actor->user.int_z_tgt() == actor->user.int_upos().Z)
if (actor->user.z_tgt == actor->user.pos.Z)
{
// change target
actor->user.jump_speed = actor->user.vel_tgt;