- Fixed overflow checking in some viewpitch code

This commit is contained in:
Edoardo Prezioso 2014-01-17 19:27:12 +01:00
parent 2501dc6df6
commit 884928687d
2 changed files with 4 additions and 4 deletions

View file

@ -775,7 +775,7 @@ void G_AddViewPitch (int look)
else if (look > 0)
{
// Avoid overflowing
if (LocalViewPitch + look <= LocalViewPitch)
if (LocalViewPitch > INT_MAX - look)
{
LocalViewPitch = 0x78000000;
}
@ -787,7 +787,7 @@ void G_AddViewPitch (int look)
else if (look < 0)
{
// Avoid overflowing
if (LocalViewPitch + look >= LocalViewPitch)
if (LocalViewPitch < INT_MIN - look)
{
LocalViewPitch = -0x78000000;
}

View file

@ -602,7 +602,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
if (delta > 0)
{
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch + delta <= viewpitch)
if (viewpitch > INT_MAX - delta)
{
viewpitch = player->MaxPitch;
}
@ -614,7 +614,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
else if (delta < 0)
{
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch + delta >= viewpitch)
if (viewpitch < INT_MIN - delta)
{
viewpitch = player->MinPitch;
}