From cd2a20f1f47143b7eed2c8bd5fe21662666db8d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20M=C3=BCller?= Date: Fri, 26 Jul 2024 18:13:35 +0200 Subject: [PATCH] Use `OnReset` function to reset damage indicators The additional indirection with the `CEffects::ResetDamageIndicator` and `CDamageInd::Reset` functions to reset damage indicators is confusing and unnecessary. Always reset the damage indicators when disconnecting (in `OnReset`) instead of when entering the next game. --- src/game/client/components/damageind.cpp | 2 +- src/game/client/components/damageind.h | 2 +- src/game/client/components/effects.cpp | 5 ----- src/game/client/components/effects.h | 1 - src/game/client/gameclient.cpp | 1 - 5 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/game/client/components/damageind.cpp b/src/game/client/components/damageind.cpp index 96a1358b2..f42c2e7c6 100644 --- a/src/game/client/components/damageind.cpp +++ b/src/game/client/components/damageind.cpp @@ -105,7 +105,7 @@ void CDamageInd::OnInit() Graphics()->QuadContainerUpload(m_DmgIndQuadContainerIndex); } -void CDamageInd::Reset() +void CDamageInd::OnReset() { for(int i = 0; i < m_NumItems;) { diff --git a/src/game/client/components/damageind.h b/src/game/client/components/damageind.h index 4944010ef..cb5bb7d4b 100644 --- a/src/game/client/components/damageind.h +++ b/src/game/client/components/damageind.h @@ -37,7 +37,7 @@ public: virtual int Sizeof() const override { return sizeof(*this); } void Create(vec2 Pos, vec2 Dir, float Alpha); - void Reset(); + virtual void OnReset() override; virtual void OnRender() override; virtual void OnInit() override; }; diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp index f6389e924..1d6000baf 100644 --- a/src/game/client/components/effects.cpp +++ b/src/game/client/components/effects.cpp @@ -53,11 +53,6 @@ void CEffects::DamageIndicator(vec2 Pos, vec2 Dir, float Alpha) m_pClient->m_DamageInd.Create(Pos, Dir, Alpha); } -void CEffects::ResetDamageIndicator() -{ - m_pClient->m_DamageInd.Reset(); -} - void CEffects::PowerupShine(vec2 Pos, vec2 Size, float Alpha) { if(!m_Add50hz) diff --git a/src/game/client/components/effects.h b/src/game/client/components/effects.h index c88b691ef..f86c27cce 100644 --- a/src/game/client/components/effects.h +++ b/src/game/client/components/effects.h @@ -26,7 +26,6 @@ public: void HammerHit(vec2 Pos, float Alpha = 1.0f); void AirJump(vec2 Pos, float Alpha = 1.0f); void DamageIndicator(vec2 Pos, vec2 Dir, float Alpha = 1.0f); - void ResetDamageIndicator(); void PlayerSpawn(vec2 Pos, float Alpha = 1.0f); void PlayerDeath(vec2 Pos, int ClientId, float Alpha = 1.0f); void PowerupShine(vec2 Pos, vec2 Size, float Alpha = 1.0f); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index af6ea217d..9dfdf5e5f 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -1010,7 +1010,6 @@ void CGameClient::OnShutdown() void CGameClient::OnEnterGame() { - m_Effects.ResetDamageIndicator(); } void CGameClient::OnGameOver()