From b2fbfac4d151a1b6f6aa2fcf5c0df229830c80e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 28 Aug 2022 11:53:16 +0200 Subject: [PATCH 1/2] Suppress more events while skipping in demos: - chat messages - kill messages - sounds - stats - air jump effects --- src/game/client/components/chat.cpp | 3 +++ src/game/client/components/killmessages.cpp | 3 +++ src/game/client/components/sounds.cpp | 22 ++++++++++++--------- src/game/client/components/statboard.cpp | 3 +++ src/game/client/gameclient.cpp | 6 +++--- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index a9625598d..36607f960 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -564,6 +564,9 @@ void CChat::DisableMode() void CChat::OnMessage(int MsgType, void *pRawMsg) { + if(m_pClient->m_SuppressEvents) + return; + if(MsgType == NETMSGTYPE_SV_CHAT) { CNetMsg_Sv_Chat *pMsg = (CNetMsg_Sv_Chat *)pRawMsg; diff --git a/src/game/client/components/killmessages.cpp b/src/game/client/components/killmessages.cpp index f7df972fb..a24e60a45 100644 --- a/src/game/client/components/killmessages.cpp +++ b/src/game/client/components/killmessages.cpp @@ -100,6 +100,9 @@ void CKillMessages::CreateKillmessageNamesIfNotCreated(CKillMsg &Kill) void CKillMessages::OnMessage(int MsgType, void *pRawMsg) { + if(m_pClient->m_SuppressEvents) + return; + if(MsgType == NETMSGTYPE_SV_KILLMSG) { CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg; diff --git a/src/game/client/components/sounds.cpp b/src/game/client/components/sounds.cpp index a69c71259..46578cd55 100644 --- a/src/game/client/components/sounds.cpp +++ b/src/game/client/components/sounds.cpp @@ -176,15 +176,15 @@ void CSounds::ClearQueue() void CSounds::Enqueue(int Channel, int SetId) { - // add sound to the queue - if(m_QueuePos < QUEUE_SIZE) - { - if(Channel == CHN_MUSIC || !g_Config.m_ClEditor) - { - m_aQueue[m_QueuePos].m_Channel = Channel; - m_aQueue[m_QueuePos++].m_SetId = SetId; - } - } + if(m_pClient->m_SuppressEvents) + return; + if(m_QueuePos >= QUEUE_SIZE) + return; + if(Channel != CHN_MUSIC && g_Config.m_ClEditor) + return; + + m_aQueue[m_QueuePos].m_Channel = Channel; + m_aQueue[m_QueuePos++].m_SetId = SetId; } void CSounds::PlayAndRecord(int Channel, int SetId, float Vol, vec2 Pos) @@ -198,6 +198,8 @@ void CSounds::PlayAndRecord(int Channel, int SetId, float Vol, vec2 Pos) void CSounds::Play(int Channel, int SetId, float Vol) { + if(m_pClient->m_SuppressEvents) + return; if(Channel == CHN_MUSIC && !g_Config.m_SndMusic) return; @@ -214,6 +216,8 @@ void CSounds::Play(int Channel, int SetId, float Vol) void CSounds::PlayAt(int Channel, int SetId, float Vol, vec2 Pos) { + if(m_pClient->m_SuppressEvents) + return; if(Channel == CHN_MUSIC && !g_Config.m_SndMusic) return; diff --git a/src/game/client/components/statboard.cpp b/src/game/client/components/statboard.cpp index f802b9049..e7b320d0b 100644 --- a/src/game/client/components/statboard.cpp +++ b/src/game/client/components/statboard.cpp @@ -48,6 +48,9 @@ bool CStatboard::IsActive() void CStatboard::OnMessage(int MsgType, void *pRawMsg) { + if(m_pClient->m_SuppressEvents) + return; + if(MsgType == NETMSGTYPE_SV_KILLMSG) { CNetMsg_Sv_KillMsg *pMsg = (CNetMsg_Sv_KillMsg *)pRawMsg; diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index fa6874f9f..d79f63dd7 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1843,10 +1843,10 @@ void CGameClient::OnPredict() m_NewPredictedTick = true; vec2 Pos = pLocalChar->Core()->m_Pos; int Events = pLocalChar->Core()->m_TriggeredEvents; - if(g_Config.m_ClPredict) + if(g_Config.m_ClPredict && !m_SuppressEvents) if(Events & COREEVENT_AIR_JUMP) m_Effects.AirJump(Pos); - if(g_Config.m_SndGame) + if(g_Config.m_SndGame && !m_SuppressEvents) { if(Events & COREEVENT_GROUND_JUMP) m_Sounds.PlayAndRecord(CSounds::CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, Pos); @@ -1863,7 +1863,7 @@ void CGameClient::OnPredict() m_aLastNewPredictedTick[!Dummy] = Tick; vec2 Pos = pDummyChar->Core()->m_Pos; int Events = pDummyChar->Core()->m_TriggeredEvents; - if(g_Config.m_ClPredict) + if(g_Config.m_ClPredict && !m_SuppressEvents) if(Events & COREEVENT_AIR_JUMP) m_Effects.AirJump(Pos); } From c0472b3177540c9d3e3f944e535ac40930103f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Sun, 28 Aug 2022 15:39:30 +0200 Subject: [PATCH 2/2] Reset specific components before long skips in demo Only reset what has to be reset instead of using `CGameClient::OnReset`, which would reset a lot more and cause other issues (client freezing while skipping) that would first need to be solved. --- src/game/client/components/chat.h | 2 +- src/game/client/components/menus_demo.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index 0566337b2..16b72cd0f 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -133,7 +133,6 @@ class CChat : public CComponent bool LineShouldHighlight(const char *pLine, const char *pName); void StoreSave(const char *pText); - void Reset(); public: CChat(); @@ -162,6 +161,7 @@ public: void OnRender() override; void RefindSkins(); void OnPrepareLines(); + void Reset(); void OnRelease() override; void OnMessage(int MsgType, void *pRawMsg) override; bool OnInput(IInput::CEvent Event) override; diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 7068a6500..e973f1662 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -83,6 +83,12 @@ void CMenus::HandleDemoSeeking(float PositionToSeek, float TimeToSeek) { if((PositionToSeek >= 0.0f && PositionToSeek <= 1.0f) || TimeToSeek != 0.0f) { + m_pClient->m_Chat.Reset(); + m_pClient->m_KillMessages.OnReset(); + m_pClient->m_Particles.OnReset(); + m_pClient->m_Sounds.OnReset(); + m_pClient->m_Scoreboard.OnReset(); + m_pClient->m_Statboard.OnReset(); m_pClient->m_SuppressEvents = true; if(TimeToSeek != 0.0f) DemoPlayer()->SeekTime(TimeToSeek);