Don't send zoom level while zooming (fixes #2470)

This commit is contained in:
def 2020-07-08 08:29:04 +02:00
parent 606e284bef
commit 2e8faac549
2 changed files with 8 additions and 4 deletions

View file

@ -20,7 +20,6 @@ class CCamera : public CComponent
vec2 m_PrevCenter;
bool m_Zooming;
float m_ZoomSmoothingTarget;
CCubicBezier m_ZoomSmoothing;
float m_ZoomSmoothingStart;
float m_ZoomSmoothingEnd;
@ -33,6 +32,7 @@ public:
vec2 m_Center;
bool m_ZoomSet;
float m_Zoom;
float m_ZoomSmoothingTarget;
CCamera();
virtual void OnRender();

View file

@ -1552,13 +1552,17 @@ void CGameClient::OnNewSnapshot()
static float LastZoom = .0;
static float LastScreenAspect = .0;
if(m_pCamera->m_Zoom != LastZoom || Graphics()->ScreenAspect() != LastScreenAspect)
float ZoomToSend = m_pCamera->m_ZoomSmoothingTarget == .0 ? m_pCamera->m_Zoom // Initial
: m_pCamera->m_ZoomSmoothingTarget > m_pCamera->m_Zoom ? m_pCamera->m_ZoomSmoothingTarget // Zooming out
: m_pCamera->m_ZoomSmoothingTarget < m_pCamera->m_Zoom ? LastZoom // Zooming in
: m_pCamera->m_Zoom; // Not zooming
if(ZoomToSend != LastZoom || Graphics()->ScreenAspect() != LastScreenAspect)
{
LastZoom = m_pCamera->m_Zoom;
LastZoom = ZoomToSend;
LastScreenAspect = Graphics()->ScreenAspect();
CNetMsg_Cl_ShowDistance Msg;
float x, y;
RenderTools()->CalcScreenParams(Graphics()->ScreenAspect(), m_pCamera->m_Zoom, &x, &y);
RenderTools()->CalcScreenParams(Graphics()->ScreenAspect(), ZoomToSend, &x, &y);
Msg.m_X = x;
Msg.m_Y = y;
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);