From bcdec941da786c2f3ba6e986630a765972f91546 Mon Sep 17 00:00:00 2001 From: def Date: Sat, 29 Dec 2018 00:04:40 +0100 Subject: [PATCH] Update view target when spectating with chat open Thanks to ReiTW for reporting and illustrating the bug: https://www.youtube.com/watch?v=LKicYqtqJbQ --- src/game/client/components/controls.cpp | 5 +++++ src/game/server/player.cpp | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index bcda6bbb6..1c89cadbb 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -252,6 +252,11 @@ int CControls::SnapInput(int *pData) mem_copy(pData, &m_InputData[g_Config.m_ClDummy], sizeof(m_InputData[0])); + // set the target anyway though so that we can keep seeing our surroundings, + // even if chat or menu are activated + m_InputData[g_Config.m_ClDummy].m_TargetX = (int)m_MousePos[g_Config.m_ClDummy].x; + m_InputData[g_Config.m_ClDummy].m_TargetY = (int)m_MousePos[g_Config.m_ClDummy].y; + // send once a second just to be sure if(time_get() > LastSendTime + time_freq()) Send = true; diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp index d880eab94..8c087e4b3 100644 --- a/src/game/server/player.cpp +++ b/src/game/server/player.cpp @@ -427,11 +427,14 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) return; // we must return if kicked, as player struct is already deleted AfkVoteTimer(NewInput); + if(((!m_pCharacter && m_Team == TEAM_SPECTATORS) || m_Paused) && m_SpectatorID == SPEC_FREEVIEW) + m_ViewPos = vec2(NewInput->m_TargetX, NewInput->m_TargetY); + if(NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING) { // skip the input if chat is active if(m_PlayerFlags&PLAYERFLAG_CHATTING) - return; + return; // reset input if(m_pCharacter) @@ -454,9 +457,6 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput) if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1)) m_Spawning = true; - if(((!m_pCharacter && m_Team == TEAM_SPECTATORS) || m_Paused) && m_SpectatorID == SPEC_FREEVIEW) - m_ViewPos = vec2(NewInput->m_TargetX, NewInput->m_TargetY); - // check for activity if(NewInput->m_Direction || m_LatestActivity.m_TargetX != NewInput->m_TargetX || m_LatestActivity.m_TargetY != NewInput->m_TargetY || NewInput->m_Jump ||