From 1627fad31d790987a0f7f3754e2586d66100cbd8 Mon Sep 17 00:00:00 2001 From: shadow578 <52449218+shadow578@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:36:03 +0200 Subject: [PATCH 1/3] update SDK dependency to 4.1.1 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 502b984..cea75a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(ChaosMod CXX) # Find latest version at https://github.com/OrfeasZ/ZHMModSDK/releases # Set ZHMMODSDK_DIR variable to a local directory to use a local copy of the ZHMModSDK. -set(ZHMMODSDK_VER "v4.0.2") +set(ZHMMODSDK_VER "v4.1.1") include(cmake/setup-zhmmodsdk.cmake) # Set C++ standard to C++23. From c68d211526be9e12fc8eee2b7d3949fca0fc2ef1 Mon Sep 17 00:00:00 2001 From: shadow578 <52449218+shadow578@users.noreply.github.com> Date: Sun, 27 Sep 2026 14:50:25 +0200 Subject: [PATCH 2/3] update hook signature for ZInputAction_Analog --- src/Effects/Player/ZDisableInputsEffect.cpp | 10 +++------- src/Effects/Player/ZDisableInputsEffect.h | 2 +- .../Player/ZForceForwardMovementEffect.cpp | 11 +++-------- src/Effects/Player/ZForceForwardMovementEffect.h | 2 +- src/Effects/Player/ZInvertControlsEffect.cpp | 14 ++++---------- src/Effects/Player/ZInvertControlsEffect.h | 2 +- .../Player/ZPlayerTeleportMovementEffect.cpp | 16 ++++------------ .../Player/ZPlayerTeleportMovementEffect.h | 2 +- 8 files changed, 18 insertions(+), 41 deletions(-) diff --git a/src/Effects/Player/ZDisableInputsEffect.cpp b/src/Effects/Player/ZDisableInputsEffect.cpp index d554df5..fa40765 100644 --- a/src/Effects/Player/ZDisableInputsEffect.cpp +++ b/src/Effects/Player/ZDisableInputsEffect.cpp @@ -68,18 +68,14 @@ DEFINE_PLUGIN_DETOUR(ZDisableInputsEffect, bool, OnInputActionDigital, ZInputAct return HookResult(HookAction::Continue()); } -DEFINE_PLUGIN_DETOUR(ZDisableInputsEffect, double, OnInputActionAnalog, ZInputAction* th, int a2) +DEFINE_PLUGIN_DETOUR(ZDisableInputsEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2) { if (m_bEnable) { - // note: hook uses float32, but typed as float64. - // so we need to unpack and repack to/from float32. - auto s_fValue = 0.0f; - auto s_fValueReturn = *Utils::CastRaw(&s_fValue); - return {HookAction::Return(), s_fValueReturn}; + return {HookAction::Return(), 0.0f}; } - return HookResult(HookAction::Continue()); + return HookResult(HookAction::Continue()); } REGISTER_CHAOS_EFFECT(ZDisableInputsEffect) diff --git a/src/Effects/Player/ZDisableInputsEffect.h b/src/Effects/Player/ZDisableInputsEffect.h index 1785977..88b86c8 100644 --- a/src/Effects/Player/ZDisableInputsEffect.h +++ b/src/Effects/Player/ZDisableInputsEffect.h @@ -28,5 +28,5 @@ class ZDisableInputsEffect : public IChaosEffect bool m_bEnable = false; DECLARE_PLUGIN_DETOUR(ZDisableInputsEffect, bool, OnInputActionDigital, ZInputAction* th, int a2); - DECLARE_PLUGIN_DETOUR(ZDisableInputsEffect, double, OnInputActionAnalog, ZInputAction* th, int a2); + DECLARE_PLUGIN_DETOUR(ZDisableInputsEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2); }; diff --git a/src/Effects/Player/ZForceForwardMovementEffect.cpp b/src/Effects/Player/ZForceForwardMovementEffect.cpp index 14f33d4..d5decd1 100644 --- a/src/Effects/Player/ZForceForwardMovementEffect.cpp +++ b/src/Effects/Player/ZForceForwardMovementEffect.cpp @@ -51,23 +51,18 @@ void ZForceForwardMovementEffect::Stop() m_bEnable = false; } -DEFINE_PLUGIN_DETOUR(ZForceForwardMovementEffect, double, OnInputActionAnalog, ZInputAction* th, int a2) +DEFINE_PLUGIN_DETOUR(ZForceForwardMovementEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2) { if (m_bEnable) { const std::string s_sName = th->m_szName; if (s_sName == InputActionNames::Keyboard::c_sVertical || s_sName == InputActionNames::Controller::c_sLeftStickVertical) { - // note: hook uses float32, but typed as float64. - // so we need to unpack and repack to/from float32. - auto s_fValue = 1.0f; - - auto s_fValueReturn = *Utils::CastRaw(&s_fValue); - return {HookAction::Return(), s_fValueReturn}; + return {HookAction::Return(), 1.0f}; } } - return HookResult(HookAction::Continue()); + return HookResult(HookAction::Continue()); } REGISTER_CHAOS_EFFECT(ZForceForwardMovementEffect) diff --git a/src/Effects/Player/ZForceForwardMovementEffect.h b/src/Effects/Player/ZForceForwardMovementEffect.h index aab94fe..626c755 100644 --- a/src/Effects/Player/ZForceForwardMovementEffect.h +++ b/src/Effects/Player/ZForceForwardMovementEffect.h @@ -27,5 +27,5 @@ class ZForceForwardMovementEffect : public IChaosEffect private: bool m_bEnable = false; - DECLARE_PLUGIN_DETOUR(ZForceForwardMovementEffect, double, OnInputActionAnalog, ZInputAction* th, int a2); + DECLARE_PLUGIN_DETOUR(ZForceForwardMovementEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2); }; diff --git a/src/Effects/Player/ZInvertControlsEffect.cpp b/src/Effects/Player/ZInvertControlsEffect.cpp index e558602..d758aac 100644 --- a/src/Effects/Player/ZInvertControlsEffect.cpp +++ b/src/Effects/Player/ZInvertControlsEffect.cpp @@ -51,27 +51,21 @@ void ZInvertControlsEffect::Stop() m_bEnable = false; } -DEFINE_PLUGIN_DETOUR(ZInvertControlsEffect, double, OnInputActionAnalog, ZInputAction* th, int a2) +DEFINE_PLUGIN_DETOUR(ZInvertControlsEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2) { if (m_bEnable) { const std::string s_sName = th->m_szName; if (s_sName == InputActionNames::Keyboard::c_sVertical || s_sName == InputActionNames::Keyboard::c_sHorizontal || s_sName == InputActionNames::Keyboard::c_sLookVertical || s_sName == InputActionNames::Keyboard::c_sLookHorizontal || s_sName == InputActionNames::Controller::c_sLeftStickVertical || s_sName == InputActionNames::Controller::c_sLeftStickHorizontal || s_sName == InputActionNames::Controller::c_sRightStickVertical || s_sName == InputActionNames::Controller::c_sRightStickHorizontal) { - auto s_fValueRaw = p_Hook->CallOriginal(th, a2); - - // note: hook uses float32, but typed as float64. - // so we need to unpack and repack to/from float32. - auto s_fValue = *Utils::CastRaw(&s_fValueRaw); + auto s_fValue = p_Hook->CallOriginal(th, a2); s_fValue *= -1.0f; - - auto s_fValueReturn = *Utils::CastRaw(&s_fValue); - return {HookAction::Return(), s_fValueReturn}; + return {HookAction::Return(), s_fValue}; } } - return HookResult(HookAction::Continue()); + return HookResult(HookAction::Continue()); } REGISTER_CHAOS_EFFECT(ZInvertControlsEffect) diff --git a/src/Effects/Player/ZInvertControlsEffect.h b/src/Effects/Player/ZInvertControlsEffect.h index 3cb91aa..234f12e 100644 --- a/src/Effects/Player/ZInvertControlsEffect.h +++ b/src/Effects/Player/ZInvertControlsEffect.h @@ -22,5 +22,5 @@ class ZInvertControlsEffect : public IChaosEffect private: bool m_bEnable = false; - DECLARE_PLUGIN_DETOUR(ZInvertControlsEffect, double, OnInputActionAnalog, ZInputAction* th, int a2); + DECLARE_PLUGIN_DETOUR(ZInvertControlsEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2); }; diff --git a/src/Effects/Player/ZPlayerTeleportMovementEffect.cpp b/src/Effects/Player/ZPlayerTeleportMovementEffect.cpp index a049178..89e27db 100644 --- a/src/Effects/Player/ZPlayerTeleportMovementEffect.cpp +++ b/src/Effects/Player/ZPlayerTeleportMovementEffect.cpp @@ -184,7 +184,7 @@ ZPlayerTeleportMovementEffect::ETeleportResult ZPlayerTeleportMovementEffect::Pe return ETeleportResult::SUCCESS; } -DEFINE_PLUGIN_DETOUR(ZPlayerTeleportMovementEffect, double, OnInputActionAnalog, ZInputAction* th, int a2) +DEFINE_PLUGIN_DETOUR(ZPlayerTeleportMovementEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2) { if (m_eState != EState::DISABLED) { @@ -194,11 +194,7 @@ DEFINE_PLUGIN_DETOUR(ZPlayerTeleportMovementEffect, double, OnInputActionAnalog, const bool s_bIsHorizontalMovement = s_sName == InputActionNames::Keyboard::c_sHorizontal || s_sName == InputActionNames::Controller::c_sLeftStickHorizontal; if (s_bIsVerticalMovement || s_bIsHorizontalMovement) { - auto s_fValueRaw = p_Hook->CallOriginal(th, a2); - - // note: hook uses float32, but typed as float64. - // so we need to unpack and repack to/from float32. - auto s_fValue = *Utils::CastRaw(&s_fValueRaw); + auto s_fValue = p_Hook->CallOriginal(th, a2); // for positive vertical movement (= walk forward), trigger teleport // only if above threshold to prevent accidental activation (only relevant for controllers!) @@ -207,15 +203,11 @@ DEFINE_PLUGIN_DETOUR(ZPlayerTeleportMovementEffect, double, OnInputActionAnalog, m_eState = EState::TELEPORT_NEXT_FRAME; } - // disable all movement via inputs while active - s_fValue = 0.0f; - - auto s_fValueReturn = *Utils::CastRaw(&s_fValue); - return {HookAction::Return(), s_fValueReturn}; + return {HookAction::Return(), 0.0f}; } } - return HookResult(HookAction::Continue()); + return HookResult(HookAction::Continue()); } std::string_view ZPlayerTeleportMovementEffect::StateToName(const EState p_eState) diff --git a/src/Effects/Player/ZPlayerTeleportMovementEffect.h b/src/Effects/Player/ZPlayerTeleportMovementEffect.h index c6f0751..e50a8bb 100644 --- a/src/Effects/Player/ZPlayerTeleportMovementEffect.h +++ b/src/Effects/Player/ZPlayerTeleportMovementEffect.h @@ -54,5 +54,5 @@ class ZPlayerTeleportMovementEffect : public IChaosEffect EState m_eState = EState::DISABLED; float32 m_fCooldownRemaining = 0.0f; - DECLARE_PLUGIN_DETOUR(ZPlayerTeleportMovementEffect, double, OnInputActionAnalog, ZInputAction* th, int a2); + DECLARE_PLUGIN_DETOUR(ZPlayerTeleportMovementEffect, float32, OnInputActionAnalog, ZInputAction* th, int a2); }; From c7b8253aaece08b48119ad568879f1247f2fb0e9 Mon Sep 17 00:00:00 2001 From: shadow578 <52449218+shadow578@users.noreply.github.com> Date: Sun, 27 Sep 2026 15:30:13 +0200 Subject: [PATCH 3/3] fix: Utils::GetEntityBlueprintFactoryFor crashes with index out-of-bounds caused crash for actor dance effect in mendoza --- src/Helpers/EntityUtils.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Helpers/EntityUtils.cpp b/src/Helpers/EntityUtils.cpp index f9cfce0..f756944 100644 --- a/src/Helpers/EntityUtils.cpp +++ b/src/Helpers/EntityUtils.cpp @@ -271,9 +271,25 @@ ZEntityBlueprintFactoryBase* Utils::GetEntityBlueprintFactoryFor(ZEntityRef p_rE { const auto* s_pAspectBPFactory = reinterpret_cast(s_pBPFactory); - const auto s_AspectSubIndex = s_pAspectBPFactory->m_aSubEntitiesLookUp[s_nSubIndex]; + int s_AspectSubIndex = -1; + if (s_pAspectBPFactory->m_aSubEntitiesLookUp.m_pBegin && s_pAspectBPFactory->m_aSubEntitiesLookUp.m_pEnd) + { + for (auto it = s_pAspectBPFactory->m_aSubEntitiesLookUp.m_pBegin; it != s_pAspectBPFactory->m_aSubEntitiesLookUp.m_pEnd; ++it) + { + if (it->m_nAspectIdx == s_nSubIndex) + { + s_AspectSubIndex = it->m_nSubentityIdx; + break; + } + } + } + + if (s_AspectSubIndex == -1) + { + return nullptr; + } - s_pBPFactory = reinterpret_cast(s_pAspectBPFactory->m_aBlueprintFactories[s_AspectSubIndex.m_nSubentityIdx]); + s_pBPFactory = reinterpret_cast(s_pAspectBPFactory->m_aBlueprintFactories[s_AspectSubIndex]); } // may have re-resolved the bp pointer (aspect entity), so check again to be sure.