From 8ce9b6151dcb84283c3b2c6c7b70f588596424ed Mon Sep 17 00:00:00 2001 From: Neloreck Date: Sun, 12 Jan 2025 18:42:02 +0200 Subject: [PATCH 1/3] Optional GL animation usage. --- src/xrGame/HudItem.cpp | 19 +++++++++++++++---- src/xrGame/HudItem.h | 2 ++ src/xrGame/WeaponMagazinedWGrenade.cpp | 10 +++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/xrGame/HudItem.cpp b/src/xrGame/HudItem.cpp index 57af3628972..a029213f88a 100644 --- a/src/xrGame/HudItem.cpp +++ b/src/xrGame/HudItem.cpp @@ -378,8 +378,13 @@ bool CHudItem::TryPlayAnimIdle() return false; } -//AVO: check if animation exists bool CHudItem::isHUDAnimationExist(pcstr anim_name) const +{ + return isHUDAnimationExist(anim_name, false); +} + +//AVO: check if animation exists +bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool is_silent) const { if (const auto* data = HudItemData()) // First person { @@ -399,16 +404,22 @@ bool CHudItem::isHUDAnimationExist(pcstr anim_name) const else return false; // No hud section, no warning #ifdef DEBUG - Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str()); + if (!is_silent) + Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str()); #endif return false; } pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const { - if (isHUDAnimationExist(anim_name)) + return WhichHUDAnimationExist(anim_name, anim_name2, false); +} + +pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool is_silent) const +{ + if (isHUDAnimationExist(anim_name, is_silent)) return anim_name; - if (isHUDAnimationExist(anim_name2)) + if (isHUDAnimationExist(anim_name2, is_silent)) return anim_name2; return nullptr; } diff --git a/src/xrGame/HudItem.h b/src/xrGame/HudItem.h index 0ce80570238..9b03376f959 100644 --- a/src/xrGame/HudItem.h +++ b/src/xrGame/HudItem.h @@ -185,5 +185,7 @@ class CHudItem : public CHUDState virtual CHudItem* cast_hud_item() { return this; } void PlayAnimIdleMovingCrouch(); //AVO: new crouch idle animation bool isHUDAnimationExist(pcstr anim_name) const; + bool isHUDAnimationExist(pcstr anim_name, bool is_silent) const; pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const; + pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool is_silent) const; }; diff --git a/src/xrGame/WeaponMagazinedWGrenade.cpp b/src/xrGame/WeaponMagazinedWGrenade.cpp index 8382acb95e5..73960f96db9 100644 --- a/src/xrGame/WeaponMagazinedWGrenade.cpp +++ b/src/xrGame/WeaponMagazinedWGrenade.cpp @@ -736,10 +736,14 @@ void CWeaponMagazinedWGrenade::PlayAnimShoot() void CWeaponMagazinedWGrenade::PlayAnimModeSwitch() { - if (m_bGrenadeMode) - PlayHUDMotion("anm_switch_g", "anim_switch_grenade_on", /*FALSE*/ TRUE, this, eSwitch); //AVO: fix fast anim switch + // Respect SOC/CS/COP animations naming with two possible animation assignments and do not spam in logs on checks. + // Possible place to inject anm_switch_g_empty / anm_switch_empty logics later with CoC/anomaly-like implementation. + cpcstr animation = m_bGrenadeMode ? WhichHUDAnimationExist("anm_switch_g", "anim_switch_grenade_on", true) : WhichHUDAnimationExist("anm_switch", "anim_switch_grenade_off", true); + + if (animation) + PlayHUDMotion(animation, TRUE, this, eSwitch); else - PlayHUDMotion("anm_switch", "anim_switch_grenade_off", /*FALSE*/ TRUE, this, eSwitch); //AVO: fix fast anim switch + SwitchState(eSwitch); } void CWeaponMagazinedWGrenade::PlayAnimBore() From ea9bd24933e0a48442d94f135d2e2c76defad9d4 Mon Sep 17 00:00:00 2001 From: Neloreck Date: Tue, 14 Jan 2025 20:21:09 +0200 Subject: [PATCH 2/3] Remove not needed overload signatures. --- src/xrGame/HudItem.cpp | 10 ---------- src/xrGame/HudItem.h | 6 ++---- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/xrGame/HudItem.cpp b/src/xrGame/HudItem.cpp index a029213f88a..0597999c4b0 100644 --- a/src/xrGame/HudItem.cpp +++ b/src/xrGame/HudItem.cpp @@ -378,11 +378,6 @@ bool CHudItem::TryPlayAnimIdle() return false; } -bool CHudItem::isHUDAnimationExist(pcstr anim_name) const -{ - return isHUDAnimationExist(anim_name, false); -} - //AVO: check if animation exists bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool is_silent) const { @@ -410,11 +405,6 @@ bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool is_silent) const return false; } -pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const -{ - return WhichHUDAnimationExist(anim_name, anim_name2, false); -} - pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool is_silent) const { if (isHUDAnimationExist(anim_name, is_silent)) diff --git a/src/xrGame/HudItem.h b/src/xrGame/HudItem.h index 9b03376f959..8418f899c98 100644 --- a/src/xrGame/HudItem.h +++ b/src/xrGame/HudItem.h @@ -184,8 +184,6 @@ class CHudItem : public CHUDState virtual CHudItem* cast_hud_item() { return this; } void PlayAnimIdleMovingCrouch(); //AVO: new crouch idle animation - bool isHUDAnimationExist(pcstr anim_name) const; - bool isHUDAnimationExist(pcstr anim_name, bool is_silent) const; - pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const; - pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool is_silent) const; + bool isHUDAnimationExist(pcstr anim_name, bool silent = false) const; + pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool silent = false) const; }; From 03990f166c03a15cf9ea6b350ce8fb2c071f792e Mon Sep 17 00:00:00 2001 From: Neloreck Date: Tue, 14 Jan 2025 20:22:12 +0200 Subject: [PATCH 3/3] Update parameter name to omit `is_` part. --- src/xrGame/HudItem.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/xrGame/HudItem.cpp b/src/xrGame/HudItem.cpp index 0597999c4b0..e3b85fa8d71 100644 --- a/src/xrGame/HudItem.cpp +++ b/src/xrGame/HudItem.cpp @@ -379,7 +379,7 @@ bool CHudItem::TryPlayAnimIdle() } //AVO: check if animation exists -bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool is_silent) const +bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool silent) const { if (const auto* data = HudItemData()) // First person { @@ -399,17 +399,17 @@ bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool is_silent) const else return false; // No hud section, no warning #ifdef DEBUG - if (!is_silent) + if (!silent) Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str()); #endif return false; } -pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool is_silent) const +pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool silent) const { - if (isHUDAnimationExist(anim_name, is_silent)) + if (isHUDAnimationExist(anim_name, silent)) return anim_name; - if (isHUDAnimationExist(anim_name2, is_silent)) + if (isHUDAnimationExist(anim_name2, silent)) return anim_name2; return nullptr; }