- PlayerAngle: Adjust how settarget() methods store angle for unsynchronised angle adjustments and adjust processhelpers() method accordingly.

* Repairs angle issues raised in https://forum.zdoom.org/viewtopic.php?f=340&p=1185365.
This commit is contained in:
Mitchell Richters 2021-03-31 19:43:41 +11:00
parent a12f277846
commit 39fe9efaff

View file

@ -97,9 +97,9 @@ struct PlayerHorizon
struct PlayerAngle struct PlayerAngle
{ {
binangle ang, oang; binangle ang, oang, target;
lookangle look_ang, olook_ang, rotscrnang, orotscrnang, spin; lookangle look_ang, olook_ang, rotscrnang, orotscrnang, spin;
double adjustment, target; double adjustment;
void backup() void backup()
{ {
@ -172,12 +172,12 @@ struct PlayerAngle
{ {
if (!SyncInput() && !backup) if (!SyncInput() && !backup)
{ {
target = (ang + getincanglebam(ang, buildang(value))).asbam(); target = buildang(value & 2047);
if (target == 0) target += 1; if (target.asbam() == 0) target = bamang(1);
} }
else else
{ {
ang = buildang(value); ang = buildang(value & 2047);
if (backup) oang = ang; if (backup) oang = ang;
} }
} }
@ -186,12 +186,12 @@ struct PlayerAngle
{ {
if (!SyncInput() && !backup) if (!SyncInput() && !backup)
{ {
target = (ang + getincanglebam(ang, buildfang(value))).asbam(); target = buildfang(fmod(value, 2048));
if (target == 0) target += 1; if (target.asbam() == 0) target = bamang(1);
} }
else else
{ {
ang = buildfang(value); ang = buildfang(fmod(value, 2048));
if (backup) oang = ang; if (backup) oang = ang;
} }
} }
@ -200,8 +200,8 @@ struct PlayerAngle
{ {
if (!SyncInput() && !backup) if (!SyncInput() && !backup)
{ {
target = (ang + getincanglebam(ang, value)).asbam(); target = value;
if (target == 0) target += 1; if (target.asbam() == 0) target = bamang(1);
} }
else else
{ {
@ -212,14 +212,14 @@ struct PlayerAngle
void processhelpers(double const scaleAdjust) void processhelpers(double const scaleAdjust)
{ {
if (target) if (target.asbam())
{ {
ang += bamang(xs_CRoundToUInt(scaleAdjust * (target - ang.asbam()))); ang += bamang(xs_CRoundToUInt(scaleAdjust * getincanglebam(ang, target).asbam()));
if (abs(ang.asbam() - target) < BAMUNIT) if (getincanglebam(ang, target).asbam() < BAMUNIT)
{ {
ang = bamang(target); ang = target;
target = 0; target = bamang(0);
} }
} }
else if (adjustment) else if (adjustment)