From 6a340927426c0ac049663821e59bb80bbff5c965 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 May 2017 13:12:39 +0200 Subject: [PATCH] - fixed automap positioning with linked portals and a camera actor that is transitioning a sector portal. --- src/am_map.cpp | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index b9b583ed3..d5c6a05f0 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1564,27 +1564,31 @@ CCMD(am_zoom) void AM_doFollowPlayer () { double sx, sy; - - if (players[consoleplayer].camera != NULL && - (f_oldloc.x != players[consoleplayer].camera->X() || - f_oldloc.y != players[consoleplayer].camera->Y())) + auto cam = players[consoleplayer].camera; + if (cam != nullptr) { - m_x = players[consoleplayer].camera->X() - m_w/2; - m_y = players[consoleplayer].camera->Y() - m_h/2; - m_x2 = m_x + m_w; - m_y2 = m_y + m_h; + double delta = cam->player ? cam->player->viewz - cam->Z() : cam->GetCameraHeight(); + DVector3 ampos = cam->GetPortalTransition(delta); - // do the parallax parchment scrolling. - sx = (players[consoleplayer].camera->X() - f_oldloc.x); - sy = (f_oldloc.y - players[consoleplayer].camera->Y()); - if (am_rotate == 1 || (am_rotate == 2 && viewactive)) + if (f_oldloc.x != ampos.X || f_oldloc.y != ampos.Y) { - AM_rotate (&sx, &sy, players[consoleplayer].camera->Angles.Yaw - 90); - } - AM_ScrollParchment (sx, sy); + m_x = ampos.X - m_w / 2; + m_y = ampos.Y - m_h / 2; + m_x2 = m_x + m_w; + m_y2 = m_y + m_h; - f_oldloc.x = players[consoleplayer].camera->X(); - f_oldloc.y = players[consoleplayer].camera->Y(); + // do the parallax parchment scrolling. + sx = (ampos.X - f_oldloc.x); + sy = (f_oldloc.y - ampos.Y); + if (am_rotate == 1 || (am_rotate == 2 && viewactive)) + { + AM_rotate(&sx, &sy, cam->Angles.Yaw - 90); + } + AM_ScrollParchment(sx, sy); + + f_oldloc.x = ampos.X; + f_oldloc.y = ampos.Y; + } } }