- gameinput.h: For PlayerAngle struct methods settarget(), properly set target as angle + delta between angle & target within method and not game-side.

This commit is contained in:
Mitchell Richters 2020-11-26 17:26:29 +11:00
parent e9e4590f6a
commit 80ff918b17
6 changed files with 25 additions and 16 deletions

View file

@ -247,6 +247,7 @@ class binangle
friend constexpr binangle bamang(uint32_t v); friend constexpr binangle bamang(uint32_t v);
friend constexpr binangle q16ang(uint32_t v); friend constexpr binangle q16ang(uint32_t v);
friend constexpr binangle buildang(uint32_t v); friend constexpr binangle buildang(uint32_t v);
friend binangle buildfang(double v);
friend binangle radang(double v); friend binangle radang(double v);
friend binangle degang(double v); friend binangle degang(double v);
@ -350,6 +351,7 @@ public:
inline constexpr binangle bamang(uint32_t v) { return binangle(v); } inline constexpr binangle bamang(uint32_t v) { return binangle(v); }
inline constexpr binangle q16ang(uint32_t v) { return binangle(v << 5); } inline constexpr binangle q16ang(uint32_t v) { return binangle(v << 5); }
inline constexpr binangle buildang(uint32_t v) { return binangle(v << BAMBITS); } inline constexpr binangle buildang(uint32_t v) { return binangle(v << BAMBITS); }
inline binangle buildfang(double v) { return binangle(xs_CRoundToUInt(v * BAMUNIT)); }
inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x80000000u / pi::pi()))); } inline binangle radang(double v) { return binangle(xs_CRoundToUInt(v * (0x80000000u / pi::pi()))); }
inline binangle degang(double v) { return binangle(FloatToAngle(v)); } inline binangle degang(double v) { return binangle(FloatToAngle(v)); }

View file

@ -49,6 +49,20 @@ int getincangle(int a, int na)
return na-a; return na-a;
} }
double getincanglef(double a, double na)
{
a = fmod(a, 2048.);
na = fmod(na, 2048.);
if(fabs(a-na) >= 1024)
{
if(na > 1024) na -= 2048;
if(a > 1024) a -= 2048;
}
return na-a;
}
fixed_t getincangleq16(fixed_t a, fixed_t na) fixed_t getincangleq16(fixed_t a, fixed_t na)
{ {
a &= 0x7FFFFFF; a &= 0x7FFFFFF;

View file

@ -6,6 +6,7 @@
#include "packet.h" #include "packet.h"
int getincangle(int a, int na); int getincangle(int a, int na);
double getincanglef(double a, double na);
fixed_t getincangleq16(fixed_t a, fixed_t na); fixed_t getincangleq16(fixed_t a, fixed_t na);
lookangle getincanglebam(binangle a, binangle na); lookangle getincanglebam(binangle a, binangle na);
@ -171,7 +172,7 @@ struct PlayerAngle
{ {
if (!cl_syncinput && !backup) if (!cl_syncinput && !backup)
{ {
target = value << BAMBITS; target = (ang + getincanglebam(ang, buildang(value))).asbam();
if (target == 0) target += 1; if (target == 0) target += 1;
} }
else else
@ -185,12 +186,12 @@ struct PlayerAngle
{ {
if (!cl_syncinput && !backup) if (!cl_syncinput && !backup)
{ {
target = value * BAMUNIT; target = (ang + getincanglebam(ang, buildfang(value))).asbam();
if (target == 0) target += 1; if (target == 0) target += 1;
} }
else else
{ {
ang = bamang(xs_CRoundToUInt(value * BAMUNIT)); ang = buildfang(value);
if (backup) oang = ang; if (backup) oang = ang;
} }
} }
@ -199,7 +200,7 @@ struct PlayerAngle
{ {
if (!cl_syncinput && !backup) if (!cl_syncinput && !backup)
{ {
target = value.asbam(); target = (ang + getincanglebam(ang, value)).asbam();
if (target == 0) target += 1; if (target == 0) target += 1;
} }
else else

View file

@ -730,8 +730,7 @@ void movecrane(DDukeActor *actor, int crane)
actor->SetActiveCrane(true); actor->SetActiveCrane(true);
ps[p].on_crane = actor; ps[p].on_crane = actor;
S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].GetActor()); S_PlayActorSound(isRR() ? 390 : DUKE_GRUNT, ps[p].GetActor());
auto ang = ps[p].angle.ang; ps[p].angle.settarget(spri->ang + 1024);
ps[p].angle.settarget(ang + getincanglebam(ang, buildang(spri->ang + 1024)));
} }
else else
{ {

View file

@ -885,7 +885,6 @@ struct PLAYERstruct
short pnum; // carry along the player number short pnum; // carry along the player number
short LadderSector; short LadderSector;
binangle LadderAngle;
int lx,ly; // ladder x and y int lx,ly; // ladder x and y
short JumpDuration; short JumpDuration;
short WadeDepth; short WadeDepth;

View file

@ -3651,8 +3651,7 @@ DoPlayerClimb(PLAYERp pp)
nx = MOVEx(100, lsp->ang); nx = MOVEx(100, lsp->ang);
ny = MOVEy(100, lsp->ang); ny = MOVEy(100, lsp->ang);
// set angle player is supposed to face. // set ladder sector
pp->LadderAngle = buildang(lsp->ang + 1024);
pp->LadderSector = wall[wal].nextsector; pp->LadderSector = wall[wal].nextsector;
// set players "view" distance from the ladder - needs to be farther than // set players "view" distance from the ladder - needs to be farther than
@ -3661,8 +3660,7 @@ DoPlayerClimb(PLAYERp pp)
pp->lx = lsp->x + nx * 5; pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5; pp->ly = lsp->y + ny * 5;
auto& PlayerAngle = pp->angle.ang; pp->angle.settarget(lsp->ang + 1024);
pp->angle.settarget(PlayerAngle + getincanglebam(PlayerAngle, pp->LadderAngle));
} }
} }
} }
@ -4058,9 +4056,6 @@ PlayerOnLadder(PLAYERp pp)
nx = MOVEx(100, lsp->ang); nx = MOVEx(100, lsp->ang);
ny = MOVEy(100, lsp->ang); ny = MOVEy(100, lsp->ang);
// set angle player is supposed to face.
pp->LadderAngle = buildang(lsp->ang + 1024);
#if DEBUG #if DEBUG
if (wall[wal].nextsector < 0) if (wall[wal].nextsector < 0)
{ {
@ -4078,8 +4073,7 @@ PlayerOnLadder(PLAYERp pp)
pp->lx = lsp->x + nx * 5; pp->lx = lsp->x + nx * 5;
pp->ly = lsp->y + ny * 5; pp->ly = lsp->y + ny * 5;
auto& PlayerAngle = pp->angle.ang; pp->angle.settarget(lsp->ang + 1024);
pp->angle.settarget(PlayerAngle + getincanglebam(PlayerAngle, pp->LadderAngle));
return true; return true;
} }