From 1eba26f518d89e26ed39cdc73fe76b7f2ce92fa2 Mon Sep 17 00:00:00 2001 From: mastercoms Date: Wed, 19 Feb 2025 04:38:04 -0500 Subject: [PATCH] fix: block HUD scope animation exploit --- src/game/client/tf/tf_hud_scope.cpp | 1 + src/public/vgui_controls/Panel.h | 2 ++ src/vgui2/vgui_controls/AnimationController.cpp | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/game/client/tf/tf_hud_scope.cpp b/src/game/client/tf/tf_hud_scope.cpp index 686c68ff7..e071292df 100644 --- a/src/game/client/tf/tf_hud_scope.cpp +++ b/src/game/client/tf/tf_hud_scope.cpp @@ -242,6 +242,7 @@ protected: virtual void ApplySchemeSettings(vgui::IScheme *scheme); virtual void Paint( void ); virtual bool ShouldDraw( void ); + virtual bool CanAnimate() const override { return false; }; private: int m_iScopeTexture[4]; diff --git a/src/public/vgui_controls/Panel.h b/src/public/vgui_controls/Panel.h index 810d49e09..99c75aac4 100644 --- a/src/public/vgui_controls/Panel.h +++ b/src/public/vgui_controls/Panel.h @@ -347,6 +347,8 @@ public: bool IsRightAligned(); // returns true if the settings are aligned to the right of the screen bool IsBottomAligned(); // returns true if the settings are aligned to the bottom of the screen + virtual bool CanAnimate() const { return true; } // If the panel can animate + // scheme access functions virtual HScheme GetScheme(); virtual void SetScheme(const char *tag); diff --git a/src/vgui2/vgui_controls/AnimationController.cpp b/src/vgui2/vgui_controls/AnimationController.cpp index 48f8c4e10..9942a1e42 100644 --- a/src/vgui2/vgui_controls/AnimationController.cpp +++ b/src/vgui2/vgui_controls/AnimationController.cpp @@ -1344,6 +1344,10 @@ void AnimationController::StartCmd_Animate(UtlSymId_t seqName, AnimCmdAnimate_t if (!panel) return; + // Block some panels (like HudScope). Unfortunately players are abusing animations with broad/null parents. + if ( !panel->CanAnimate() ) + return; + StartCmd_Animate(panel, seqName, cmd, bCanBeCancelled); }