diff --git a/source/core/maptypes.h b/source/core/maptypes.h index 797a952bc..a1fe18acb 100644 --- a/source/core/maptypes.h +++ b/source/core/maptypes.h @@ -329,7 +329,7 @@ struct sectortype int flags; int depth_fixed; short stag; // ST? tag number - for certain things it helps to know it - short ang; + DAngle angle; short height; short speed; short damage; diff --git a/source/core/savegamehelp.cpp b/source/core/savegamehelp.cpp index a6b8d6eff..a29cac09d 100644 --- a/source/core/savegamehelp.cpp +++ b/source/core/savegamehelp.cpp @@ -590,7 +590,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, sectortype &c, sectort arc("flags", c.flags, def->flags) ("depth_fixed", c.depth_fixed, def->depth_fixed) ("stag", c.stag, def->stag) - ("ang", c.ang, def->ang) + ("ang", c.angle, def->angle) ("height", c.height, def->height) ("speed", c.speed, def->speed) ("damage", c.damage, def->damage) diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index a2b29d845..f05a7503b 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -287,21 +287,20 @@ void DoDebrisCurrent(DSWActor* actor) auto sectp = actor->sector(); //actor->spr.clipdist = (256+128)>>2; + double spd = sectp->speed / 64.0; - nx = MulScale((sectp->speed >> 2), bcos(sectp->ang), 14); - ny = MulScale((sectp->speed >> 2), bsin(sectp->ang), 14); + auto vect = sectp->angle.ToVector() * spd; - Collision ret = move_sprite(actor, nx, ny, 0, actor->user.int_ceiling_dist(), actor->user.int_floor_dist(), 0, ACTORMOVETICS); + Collision ret = move_sprite(actor, DVector3(vect, 0), actor->user.ceiling_dist, actor->user.floor_dist, 0, ACTORMOVETICS); // attempt to move away from wall if (ret.type != kHitNone) { - int rang = RANDOM_P2(2048); + DAngle rang = RANDOM_ANGLE(); - nx = MulScale((sectp->speed >> 2), bcos(sectp->ang + rang), 14); - nx = MulScale((sectp->speed >> 2), bsin(sectp->ang + rang), 14); + vect = (sectp->angle + rang).ToVector() * spd; - move_sprite(actor, nx, ny, 0, actor->user.int_ceiling_dist(), actor->user.int_floor_dist(), 0, ACTORMOVETICS); + move_sprite(actor, DVector3(vect, 0), actor->user.ceiling_dist, actor->user.floor_dist, 0, ACTORMOVETICS); } actor->spr.pos.Z = actor->user.loz; diff --git a/source/games/sw/src/copysect.cpp b/source/games/sw/src/copysect.cpp index a4a2e3ad9..123955010 100644 --- a/source/games/sw/src/copysect.cpp +++ b/source/games/sw/src/copysect.cpp @@ -197,7 +197,7 @@ void CopySectorMatch(int match) dsectp->flags = ssectp->flags; dsectp->depth_fixed = ssectp->depth_fixed; dsectp->stag = ssectp->stag; - dsectp->ang = ssectp->ang; + dsectp->angle = ssectp->angle; dsectp->height = ssectp->height; dsectp->speed = ssectp->speed; dsectp->damage = ssectp->damage; diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 371b14cd6..f3684b9f8 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -4492,8 +4492,9 @@ void DoPlayerCurrent(PLAYER* pp) if (!sectu) return; - xvect = sectu->speed * synctics * bcos(sectu->ang) >> 4; - yvect = sectu->speed * synctics * bsin(sectu->ang) >> 4; + auto vect = sectu->angle.ToVector() * 1024; // 16384 >> 4 - Beware of clipmove's odd format for vect! + xvect = sectu->speed * synctics * vect.X; + yvect = sectu->speed * synctics * vect.Y; push_ret = pushmove(pp->pos, &pp->cursector, ((int)pp->actor->spr.clipdist<<2), pp->p_ceiling_dist, pp->p_floor_dist, CLIPMASK_PLAYER); if (push_ret < 0) diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 839e132e6..2eb94e104 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1736,7 +1736,7 @@ void SpriteSetup(void) { sectp->u_defined = true; sectp->speed = actor->spr.lotag; - sectp->ang = actor->int_ang(); + sectp->angle = actor->spr.angle; KillActor(actor); } else if (bit & (SECTFX_NO_RIDE))