Skip to content

Commit

Permalink
Delay "Ingame moved" warning in editor
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Robyt3 committed Jul 14, 2023
1 parent 65a64b6 commit 5acbe86
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/game/client/gameclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
Expand Down Expand Up @@ -1811,6 +1807,24 @@ 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
Expand Down
1 change: 1 addition & 0 deletions src/game/client/gameclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ class CGameClient : public IGameClient

void ProcessEvents();
void UpdatePositions();
void UpdateEditorIngameMoved();

int m_PredictedTick;
int m_aLastNewPredictedTick[NUM_DUMMIES];
Expand Down

0 comments on commit 5acbe86

Please sign in to comment.