- Add bool lock to PlayerAngle::settarget() when setting target from the ticker without having to call setters and resetters.

This commit is contained in:
Mitchell Richters 2022-05-30 21:24:02 +10:00
parent 18541d1ab4
commit 1ac58dc41c
2 changed files with 6 additions and 9 deletions

View file

@ -173,8 +173,6 @@ struct PlayerAngle
bool targetset() { return target.asbam(); } bool targetset() { return target.asbam(); }
// Input locking helpers. // Input locking helpers.
void lockinput() { inputdisabled = true; }
void unlockinput() { inputdisabled = false; }
bool movementlocked() { return targetset() || inputdisabled; } bool movementlocked() { return targetset() || inputdisabled; }
// Draw code helpers. // Draw code helpers.
@ -209,8 +207,10 @@ struct PlayerAngle
} }
} }
void settarget(binangle const value) void settarget(binangle const value, bool const lock = false)
{ {
inputdisabled = lock;
if (!SyncInput()) if (!SyncInput())
{ {
target = value; target = value;

View file

@ -3119,8 +3119,7 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor)
{ {
if (pPlayer) if (pPlayer)
{ {
pPlayer->angle.settarget(buildang(sourceactor->spr.ang)); pPlayer->angle.settarget(buildang(sourceactor->spr.ang), true);
pPlayer->angle.lockinput();
} }
else if (isDude) sourceactor->xspr.goalAng = actor->spr.ang = sourceactor->spr.ang; else if (isDude) sourceactor->xspr.goalAng = actor->spr.ang = sourceactor->spr.ang;
else actor->spr.ang = sourceactor->spr.ang; else actor->spr.ang = sourceactor->spr.ang;
@ -5841,13 +5840,11 @@ bool modernTypeOperateSprite(DBloodActor* actor, EVENT& event)
if (actor->xspr.data4 != 0) break; if (actor->xspr.data4 != 0) break;
else if (actor->spr.flags & kModernTypeFlag1) else if (actor->spr.flags & kModernTypeFlag1)
{ {
pPlayer->angle.settarget(buildang(actor->spr.ang)); pPlayer->angle.settarget(buildang(actor->spr.ang), true);
pPlayer->angle.lockinput();
} }
else if (valueIsBetween(actor->xspr.data2, -kAng360, kAng360)) else if (valueIsBetween(actor->xspr.data2, -kAng360, kAng360))
{ {
pPlayer->angle.settarget(buildang(actor->xspr.data2)); pPlayer->angle.settarget(buildang(actor->xspr.data2), true);
pPlayer->angle.lockinput();
} }
break; break;
case 10: // 74 (de)activate powerup case 10: // 74 (de)activate powerup