From 452e8e9b63071e93bee6d2cc8c894cd48cb1f9ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 14 Jul 2023 20:24:28 +0200 Subject: [PATCH] Delay "Ingame moved" warning in editor Delay showing the warning for ingame movement until the player has stopped moving while the editor is open, so the warning doesn't show immediately when the player performs an action (like jumping) and opens the editor shortly after. Closes 6852. --- src/game/client/gameclient.cpp | 25 ++++++++++++++++++++----- src/game/client/gameclient.h | 1 + 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 8c409424210..585426524d5 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1777,11 +1777,7 @@ void CGameClient::OnNewSnapshot() pComponent->OnNewSnapshot(); // notify editor when local character moved - if(m_Snap.m_pLocalCharacter && m_Snap.m_pLocalPrevCharacter && - (m_Snap.m_pLocalCharacter->m_X != m_Snap.m_pLocalPrevCharacter->m_X || m_Snap.m_pLocalCharacter->m_Y != m_Snap.m_pLocalPrevCharacter->m_Y)) - { - Editor()->OnIngameMoved(); - } + UpdateEditorIngameMoved(); // detect air jump for other players for(int i = 0; i < MAX_CLIENTS; i++) @@ -1811,6 +1807,25 @@ void CGameClient::OnNewSnapshot() UpdatePrediction(); } +void CGameClient::UpdateEditorIngameMoved() +{ + const bool LocalCharacterMoved = m_Snap.m_pLocalCharacter && m_Snap.m_pLocalPrevCharacter && + (m_Snap.m_pLocalCharacter->m_X != m_Snap.m_pLocalPrevCharacter->m_X || m_Snap.m_pLocalCharacter->m_Y != m_Snap.m_pLocalPrevCharacter->m_Y); + static int s_EditorMovementDelay = 5; + if(!g_Config.m_ClEditor) + { + s_EditorMovementDelay = 5; + } + else if(s_EditorMovementDelay > 0 && !LocalCharacterMoved) + { + --s_EditorMovementDelay; + } + if(s_EditorMovementDelay == 0 && LocalCharacterMoved) + { + Editor()->OnIngameMoved(); + } +} + void CGameClient::OnPredict() { // store the previous values so we can detect prediction errors diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index e44631ef2ee..7c35491988e 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -182,6 +182,7 @@ class CGameClient : public IGameClient void ProcessEvents(); void UpdatePositions(); + void UpdateEditorIngameMoved(); int m_PredictedTick; int m_aLastNewPredictedTick[NUM_DUMMIES];