From 33b9788711794dcca639f516fb5f6082de03ef01 Mon Sep 17 00:00:00 2001 From: mlthelama <47679057+mlthelama@users.noreply.github.com> Date: Fri, 14 Apr 2023 11:49:49 +0200 Subject: [PATCH 1/2] `fix` * fixed: another fix equipping/unequipping with 2 handed spells, equipping spells with a task now (to avoid an infinite loop) (I might rework the handing in the future to match the general equip handling) --- src/equip/item.cpp | 2 -- src/equip/magic.cpp | 8 +++++++- src/equip/magic.h | 2 +- src/processing/setting_execute.cpp | 4 +++- src/util/helper.cpp | 13 ++++++------- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/equip/item.cpp b/src/equip/item.cpp index 4228f5f..5aae9b3 100644 --- a/src/equip/item.cpp +++ b/src/equip/item.cpp @@ -129,7 +129,6 @@ namespace equip { } logger::trace("try to equip weapon/shield/light {}"sv, a_form->GetName()); - RE::ActorEquipManager::GetSingleton()->EquipObject(a_player, obj, extra, 1, a_slot); logger::trace("equipped weapon/shield/light {}, left {}. return."sv, a_form->GetName(), left); } @@ -202,7 +201,6 @@ namespace equip { } logger::trace("calling drink/eat potion/food {}, count left {}"sv, obj->GetName(), left); - RE::ActorEquipManager::GetSingleton()->EquipObject(a_player, obj); logger::trace("drank/ate potion/food {}. return."sv, obj->GetName()); } diff --git a/src/equip/magic.cpp b/src/equip/magic.cpp index d2134a9..a5b4ec2 100644 --- a/src/equip/magic.cpp +++ b/src/equip/magic.cpp @@ -121,7 +121,13 @@ namespace equip { return; } - RE::ActorEquipManager::GetSingleton()->EquipSpell(a_player, spell, a_slot); + logger::trace("calling equip spell {}, left {}"sv, spell->GetName(), left); + auto* task = SKSE::GetTaskInterface(); + if (task) { + task->AddTask([a_player, spell, a_slot]() { + RE::ActorEquipManager::GetSingleton()->EquipSpell(a_player, spell, a_slot); + }); + } } logger::trace("worked spell {}, action {}. return."sv, a_form->GetName(), static_cast(a_action)); diff --git a/src/equip/magic.h b/src/equip/magic.h index ce53f79..d244383 100644 --- a/src/equip/magic.h +++ b/src/equip/magic.h @@ -5,7 +5,7 @@ namespace equip { class magic { public: using action_type = handle::slot_setting::action_type; - + static void cast_magic(RE::TESForm* a_form, action_type a_action, const RE::BGSEquipSlot* a_slot, diff --git a/src/processing/setting_execute.cpp b/src/processing/setting_execute.cpp index 75c68f9..3c0438e 100644 --- a/src/processing/setting_execute.cpp +++ b/src/processing/setting_execute.cpp @@ -108,7 +108,9 @@ namespace processing { if (!a_setting) { return; } - logger::trace("checking and calling re equip for setting {}"sv, static_cast(a_setting->position)); + logger::trace("checking and calling re equip for setting {}, is setting empty {}"sv, + static_cast(a_setting->position), + a_setting->slot_settings.empty()); auto* left_slot = equip::equip_slot::get_left_hand_slot(); auto* equip_manager = RE::ActorEquipManager::GetSingleton(); auto* player = RE::PlayerCharacter::GetSingleton(); diff --git a/src/util/helper.cpp b/src/util/helper.cpp index d11f565..ff805f2 100644 --- a/src/util/helper.cpp +++ b/src/util/helper.cpp @@ -96,21 +96,20 @@ namespace util { return false; } - //check if two-handed + auto two_handed = false; if (a_form->Is(RE::FormType::Spell)) { if (const auto* spell = a_form->As(); spell->IsTwoHanded()) { - return true; + two_handed = true; } - } - - if (a_form->IsWeapon()) { + } else if (a_form->IsWeapon()) { if (const auto* weapon = a_form->As(); weapon->IsTwoHandedAxe() || weapon->IsTwoHandedSword() || weapon->IsBow() || weapon->IsCrossbow()) { - return true; + two_handed = true; } } - return false; + //logger::trace("form {}, two handed {}"sv, a_form->GetName(), two_handed); + return two_handed; } handle::slot_setting::slot_type helper::get_type(RE::TESForm*& a_form) { From 3dfef696ed3c09df28bcf3e0c9a157d493e2b5a6 Mon Sep 17 00:00:00 2001 From: mlthelama <47679057+mlthelama@users.noreply.github.com> Date: Fri, 14 Apr 2023 11:53:54 +0200 Subject: [PATCH 2/2] `version up` --- CMakeLists.txt | 2 +- vcpkg.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 197e83e..0bafa5d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.20) set(NAME "LamasTinyHUD") -set(VERSION 1.4.3.0) +set(VERSION 1.4.4.0) # ---- Options ---- diff --git a/vcpkg.json b/vcpkg.json index 8e6b8cc..cb56ab6 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "lamastinyhud", - "version-string": "1.4.3", + "version-string": "1.4.4", "description": "hud element for skyrim", "homepage": "https://github.com/mlthelama/LamasTinyHUD", "license": "GPL-2.0-or-later",