- Fixed: LocalViewPitch could overflow and wrap around when a netgame stalls.

SVN r459 (trunk)
This commit is contained in:
Randy Heit 2007-01-22 23:50:09 +00:00
parent 0b5e4b1f1f
commit f1c41539de
4 changed files with 55 additions and 5 deletions

View File

@ -1,4 +1,5 @@
January 22, 2007 January 22, 2007
- Fixed: LocalViewPitch could overflow and wrap around when a netgame stalls.
- Changed the vertheight and rounding-error-checking code in - Changed the vertheight and rounding-error-checking code in
DCanvas::DrawTexture() to calculate off the actual bottom of the image DCanvas::DrawTexture() to calculate off the actual bottom of the image
instead of the height, improving precision. Now the scaled status bar is instead of the height, improving precision. Now the scaled status bar is

View File

@ -704,7 +704,8 @@ void GetPackets (void)
netnode = doomcom.remotenode; netnode = doomcom.remotenode;
netconsole = playerfornode[netnode] & ~PL_DRONE; netconsole = playerfornode[netnode] & ~PL_DRONE;
// [RH] Get "ping" times // [RH] Get "ping" times - totally useless, since it's bound to the frequency
// packets go out at.
lastrecvtime[netconsole] = currrecvtime[netconsole]; lastrecvtime[netconsole] = currrecvtime[netconsole];
currrecvtime[netconsole] = I_MSTime (); currrecvtime[netconsole] = I_MSTime ();

View File

@ -646,13 +646,34 @@ void G_AddViewPitch (int look)
{ {
return; return;
} }
look <<= 16;
if (dmflags & DF_NO_FREELOOK) if (dmflags & DF_NO_FREELOOK)
{ {
LocalViewPitch = 0; LocalViewPitch = 0;
} }
else else if (look > 0)
{ {
LocalViewPitch += look << 16; // Avoid overflowing
if (LocalViewPitch + look <= LocalViewPitch)
{
LocalViewPitch = 0x78000000;
}
else
{
LocalViewPitch = MIN(LocalViewPitch + look, 0x78000000);
}
}
else if (look < 0)
{
// Avoid overflowing
if (LocalViewPitch + look >= LocalViewPitch)
{
LocalViewPitch = -0x78000000;
}
else
{
LocalViewPitch = MAX(LocalViewPitch + look, -0x78000000);
}
} }
if (look != 0) if (look != 0)
{ {

View File

@ -877,7 +877,34 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi
!LocalKeyboardTurner) !LocalKeyboardTurner)
{ {
viewangle = iview->nviewangle + (LocalViewAngle & 0xFFFF0000); viewangle = iview->nviewangle + (LocalViewAngle & 0xFFFF0000);
viewpitch = clamp<int> (iview->nviewpitch - (LocalViewPitch & 0xFFFF0000), -ANGLE_1*MAX_UP_ANGLE, +ANGLE_1*MAX_DN_ANGLE);
fixed_t delta = -(signed)(LocalViewPitch & 0xFFFF0000);
viewpitch = iview->nviewpitch;
if (delta > 0)
{
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch + delta <= viewpitch)
{
viewpitch = +ANGLE_1*MAX_DN_ANGLE;
}
else
{
viewpitch = MIN(viewpitch + delta, +ANGLE_1*MAX_DN_ANGLE);
}
}
else if (delta < 0)
{
// Avoid overflowing viewpitch (can happen when a netgame is stalled)
if (viewpitch + delta >= viewpitch)
{
viewpitch = -ANGLE_1*MAX_UP_ANGLE;
}
else
{
viewpitch = MAX(viewpitch + delta, -ANGLE_1*MAX_UP_ANGLE);
}
}
} }
else else
{ {