From bf3d1b4da0c850dead01d8e706cdbea178e5eab2 Mon Sep 17 00:00:00 2001 From: otsffs <141402668+otsffs@users.noreply.github.com> Date: Sun, 16 Jun 2024 14:05:38 +0800 Subject: [PATCH 1/2] fix bound weapon --- Code/client/Games/Skyrim/Forms/MagicItem.cpp | 11 +++++++++++ Code/client/Games/Skyrim/Forms/MagicItem.h | 1 + Code/client/Services/Generic/MagicService.cpp | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Code/client/Games/Skyrim/Forms/MagicItem.cpp b/Code/client/Games/Skyrim/Forms/MagicItem.cpp index 4dcf67669..60ab285fa 100644 --- a/Code/client/Games/Skyrim/Forms/MagicItem.cpp +++ b/Code/client/Games/Skyrim/Forms/MagicItem.cpp @@ -31,6 +31,17 @@ bool MagicItem::IsBuffSpell() const noexcept } } +bool MagicItem::IsBoundWeaponSpell() noexcept +{ + for (EffectItem* pEffect : listOfEffects) + { + if (pEffect->pEffectSetting->eArchetype == EffectArchetypes::ArchetypeID::kBoundWeapon) + return true; + } + + return false; +} + EffectItem* MagicItem::GetEffect(const uint32_t aEffectId) noexcept { for (EffectItem* pEffect : listOfEffects) diff --git a/Code/client/Games/Skyrim/Forms/MagicItem.h b/Code/client/Games/Skyrim/Forms/MagicItem.h index ae86b2947..8428bd739 100644 --- a/Code/client/Games/Skyrim/Forms/MagicItem.h +++ b/Code/client/Games/Skyrim/Forms/MagicItem.h @@ -13,6 +13,7 @@ struct MagicItem : TESBoundObject bool IsInvisibilitySpell() const noexcept; bool IsHealingSpell() const noexcept; bool IsBuffSpell() const noexcept; + bool IsBoundWeaponSpell() noexcept; EffectItem* GetEffect(const uint32_t aEffectId) noexcept; diff --git a/Code/client/Services/Generic/MagicService.cpp b/Code/client/Services/Generic/MagicService.cpp index 3f1f500a0..d8f3e62a4 100644 --- a/Code/client/Services/Generic/MagicService.cpp +++ b/Code/client/Services/Generic/MagicService.cpp @@ -298,7 +298,7 @@ void MagicService::OnAddTargetEvent(const AddTargetEvent& acEvent) noexcept // These effects are applied through spell cast sync if (SpellItem* pSpellItem = Cast(TESForm::GetById(acEvent.SpellID))) { - if ((pSpellItem->eCastingType == MagicSystem::CastingType::CONCENTRATION && !pSpellItem->IsHealingSpell()) || pSpellItem->IsWardSpell() || pSpellItem->IsInvisibilitySpell()) + if ((pSpellItem->eCastingType == MagicSystem::CastingType::CONCENTRATION && !pSpellItem->IsHealingSpell()) || pSpellItem->IsWardSpell() || pSpellItem->IsInvisibilitySpell() || pSpellItem->IsBoundWeaponSpell()) { return; } From 7c348b71dd63c5ab9f5d44974465b6a4a0419068 Mon Sep 17 00:00:00 2001 From: otsffs <141402668+otsffs@users.noreply.github.com> Date: Sun, 16 Jun 2024 23:55:24 +0800 Subject: [PATCH 2/2] Add nullptr checks --- Code/client/Games/Skyrim/Forms/MagicItem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Code/client/Games/Skyrim/Forms/MagicItem.cpp b/Code/client/Games/Skyrim/Forms/MagicItem.cpp index 60ab285fa..a91e33121 100644 --- a/Code/client/Games/Skyrim/Forms/MagicItem.cpp +++ b/Code/client/Games/Skyrim/Forms/MagicItem.cpp @@ -35,7 +35,7 @@ bool MagicItem::IsBoundWeaponSpell() noexcept { for (EffectItem* pEffect : listOfEffects) { - if (pEffect->pEffectSetting->eArchetype == EffectArchetypes::ArchetypeID::kBoundWeapon) + if (pEffect->pEffectSetting && pEffect->pEffectSetting->eArchetype == EffectArchetypes::ArchetypeID::kBoundWeapon) return true; }