diff --git a/SKSE/Plugins/EnderalSEEasyCrafting.dll b/SKSE/Plugins/EnderalSEEasyCrafting.dll index 9e7a2c2..43f1cff 100644 Binary files a/SKSE/Plugins/EnderalSEEasyCrafting.dll and b/SKSE/Plugins/EnderalSEEasyCrafting.dll differ diff --git a/src/src/Util.h b/src/src/Util.h index 2ce150b..d647cc5 100644 --- a/src/src/Util.h +++ b/src/src/Util.h @@ -4,6 +4,7 @@ static std::unordered_map supplyCount = {}; static bool bSuppliesFetched = false; +static constexpr RE::ITEM_REMOVE_REASON iRemoveReason = RE::ITEM_REMOVE_REASON::kStoreInContainer; inline void LoadINI(std::map* settings, const char* iniPath) { @@ -48,7 +49,7 @@ inline void LoadINI(std::map* settings, const char* iniPath) } } catch (const std::exception& e) { - //logger::error(e.what()); + logger::error(e.what()); } } @@ -73,7 +74,7 @@ inline RE::TESObjectREFR* GetChest() inline void NotifyFetching(const char* a_notification) { if (GetSettings().at("ShowFetchingNotification")) { - RE::DebugNotification(a_notification); + RE::DebugNotification(a_notification, nullptr, false); } } @@ -94,13 +95,11 @@ inline void FetchSuppliesByType(RE::FormType formType) return true; }); - RE::ITEM_REMOVE_REASON iReason = RE::ITEM_REMOVE_REASON::kStoreInContainer; - for (const auto& [item, data] : inv) { const auto& [count, entry] = data; if (count > 0) { supplyCount.insert({ item, count }); - chest->RemoveItem(item, count, iReason, nullptr, targetRef, 0, 0); + chest->RemoveItem(item, count, iRemoveReason, nullptr, targetRef, 0, 0); } } } @@ -118,7 +117,6 @@ inline void FetchByWorkbench(RE::TESFurniture* workbench) const auto playerRef = RE::PlayerCharacter::GetSingleton(); const auto inv = chest->GetInventory(); const auto keywords = workbench->As(); - RE::ITEM_REMOVE_REASON iReason = RE::ITEM_REMOVE_REASON::kStoreInContainer; for (const auto& recipe : RE::TESDataHandler::GetSingleton()->GetFormArray()) { if (recipe->benchKeyword && keywords->HasKeyword(recipe->benchKeyword) && recipe->requiredItems.numContainerObjects > 0) { @@ -130,7 +128,7 @@ inline void FetchByWorkbench(RE::TESFurniture* workbench) const auto it = inv.find(component->obj); if (it != inv.end()) { supplyCount.insert({ it->first, it->second.first }); - chest->RemoveItem(it->first, it->second.first, iReason, nullptr, playerRef, 0, 0); + chest->RemoveItem(it->first, it->second.first, iRemoveReason, nullptr, playerRef, 0, 0); } } } @@ -151,13 +149,11 @@ inline void FetchSuppliesByForm(RE::TESForm* a_form) return a_form == &a_xform; }); - RE::ITEM_REMOVE_REASON iReason = RE::ITEM_REMOVE_REASON::kStoreInContainer; - for (const auto& [item, data] : inv) { const auto& [count, entry] = data; if (count > 0) { supplyCount.insert({ item, count }); - chest->RemoveItem(item, count, iReason, nullptr, targetRef, 0, 0); + chest->RemoveItem(item, count, iRemoveReason, nullptr, targetRef, 0, 0); } } } @@ -176,10 +172,9 @@ inline void ReturnSupplies() const auto chest = GetChest(); const auto playerRef = RE::PlayerCharacter::GetSingleton(); - RE::ITEM_REMOVE_REASON iReason = RE::ITEM_REMOVE_REASON::kStoreInContainer; for (auto& item : supplyCount) { - playerRef->RemoveItem(item.first->As(), item.second, iReason, nullptr, chest, 0, 0); + playerRef->RemoveItem(item.first->As(), item.second, iRemoveReason, nullptr, chest, 0, 0); } supplyCount.clear(); @@ -218,12 +213,12 @@ inline void ReturnSupplies() for (const auto& [item, data] : inv) { const auto& [count, entry] = data; if (count > 0 && !entry->IsFavorited() && !entry->IsQuestObject()) { - playerRef->RemoveItem(item, count, iReason, nullptr, chest, 0, 0); + playerRef->RemoveItem(item, count, iRemoveReason, nullptr, chest, 0, 0); } } std::thread([]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + std::this_thread::sleep_for(std::chrono::milliseconds(3)); SKSE::GetTaskInterface()->AddTask([]() { const auto spell = RE::TESForm::LookupByID(0x824AF); if (spell) { @@ -273,7 +268,7 @@ inline void FetchSupplies(RE::TESFurniture* a_furn) } std::thread([a_furn]() { - std::this_thread::sleep_for(std::chrono::milliseconds(1)); + std::this_thread::sleep_for(std::chrono::milliseconds(3)); SKSE::GetTaskInterface()->AddTask([a_furn]() { switch (a_furn->workBenchData.benchType.underlying()) {