- properly tune sethorizon() so that 'frominput' bool can be removed. Returning to centre function is essentially consistent between input states now.

This commit is contained in:
Mitchell Richters 2020-08-05 17:59:01 +10:00
parent 0ee3ab4df8
commit 736811e864
3 changed files with 6 additions and 12 deletions

View file

@ -230,7 +230,7 @@ void PlayerColorChanged(void);
void nonsharedkeys(void); void nonsharedkeys(void);
void apply_seasick(player_struct* p, double scalefactor); void apply_seasick(player_struct* p, double scalefactor);
void calcviewpitch(player_struct* p, double factor); void calcviewpitch(player_struct* p, double factor);
void sethorizon(int snum, int sb_snum, double factor, bool frominput, fixed_t adjustment); void sethorizon(int snum, int sb_snum, double factor, fixed_t adjustment);
bool movementBlocked(int snum); bool movementBlocked(int snum);
void GetInput(); void GetInput();
void startmainmenu(); void startmainmenu();

View file

@ -1260,7 +1260,7 @@ void GetInput()
// Do these in the same order as the old code. // Do these in the same order as the old code.
calcviewpitch(p, scaleAdjust); calcviewpitch(p, scaleAdjust);
applylook(myconnectindex, scaleAdjust, input.q16avel); applylook(myconnectindex, scaleAdjust, input.q16avel);
sethorizon(myconnectindex, loc.bits, scaleAdjust, true, input.q16horz); sethorizon(myconnectindex, loc.bits, scaleAdjust, input.q16horz);
} }
} }

View file

@ -991,7 +991,7 @@ void checklook(int snum, int sb_snum)
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void sethorizon(int snum, int sb_snum, double factor, bool frominput, fixed_t adjustment) void sethorizon(int snum, int sb_snum, double factor, fixed_t adjustment)
{ {
auto p = &ps[snum]; auto p = &ps[snum];
@ -1000,20 +1000,14 @@ void sethorizon(int snum, int sb_snum, double factor, bool frominput, fixed_t ad
if (p->return_to_center > 0 && (sb_snum & (SKB_LOOK_UP | SKB_LOOK_DOWN)) == 0) // only snap back if no relevant button is pressed. if (p->return_to_center > 0 && (sb_snum & (SKB_LOOK_UP | SKB_LOOK_DOWN)) == 0) // only snap back if no relevant button is pressed.
{ {
p->return_to_center -= factor * 1.; p->return_to_center += -factor * (p->return_to_center / 2);
horizAngle += factor * -(frominput? 1.1 : 0.55) * horizAngle; // in P_GetInput this used different factors than in the original code. Hm... horizAngle += -factor * (horizAngle / 2);
if (horizAngle > -1. && horizAngle < 1.) if (horizAngle > -0.5 && horizAngle < 0.5)
{ {
horizAngle = 0.; horizAngle = 0.;
p->return_to_center = 0.; p->return_to_center = 0.;
} }
if (p->aim_mode == 0)
{
// threshold was 5
if (p->q16horizoff > F16(-1) && p->q16horizoff < F16(1)) p->sethorizoff(0);
}
} }
// Convert back to Build's horizon. // Convert back to Build's horizon.