- clamp the calculated horizAngle to -180/180 to stop overflowing if player moves the mouse stupidly quick while cl_syncinput 1 is set.

This commit is contained in:
Mitchell Richters 2020-08-05 19:56:49 +10:00
parent 03bccb3a06
commit 2919cdcb44

View file

@ -972,7 +972,7 @@ void sethorizon(int snum, int sb_snum, double factor, fixed_t adjustment)
auto p = &ps[snum]; auto p = &ps[snum];
// Calculate adjustment as true pitch (Fixed point math really sucks...) // Calculate adjustment as true pitch (Fixed point math really sucks...)
double horizAngle = atan2(p->q16horiz - F16(100), F16(128)) * (512. / pi::pi()) + (factor * p->pitchAdjust) + (adjustment / 65536.); double horizAngle = clamp2(atan2(p->q16horiz - F16(100), F16(128)) * (512. / pi::pi()) + (factor * p->pitchAdjust) + (adjustment / 65536.), -180, 180);
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.
{ {