diff --git a/SKSE/Plugins/EnderalSEEasyCrafting.dll b/SKSE/Plugins/EnderalSEEasyCrafting.dll index c5b7d2f..9e7a2c2 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 c85d834..2ce150b 100644 --- a/src/src/Util.h +++ b/src/src/Util.h @@ -43,12 +43,12 @@ inline void LoadINI(std::map* settings, const char* iniPath) } if (bUpdateINI) { - logger::info("New settings detected, adding to ArtifactTracker.ini"); + logger::info("New settings detected, adding to EnderalSEEasyCrafting.ini"); ini.SaveFile(iniPath); } } catch (const std::exception& e) { - logger::error(e.what()); + //logger::error(e.what()); } } @@ -105,10 +105,10 @@ inline void FetchSuppliesByType(RE::FormType formType) } } -inline void FetchByWorkbenchKeyword(RE::BGSKeyword* keyword) +inline void FetchByWorkbench(RE::TESFurniture* workbench) { - if (!keyword) { - logger::warn("Invalid keyword argument in FetchByWorkbenchKeyword"); + if (!workbench) { + logger::warn("Invalid workbench argument in FetchByWorkbench"); return; } @@ -117,10 +117,11 @@ inline void FetchByWorkbenchKeyword(RE::BGSKeyword* keyword) const auto chest = GetChest(); 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 == keyword && recipe->requiredItems.numContainerObjects > 0) { + if (recipe->benchKeyword && keywords->HasKeyword(recipe->benchKeyword) && recipe->requiredItems.numContainerObjects > 0) { for (int i = 0; i < recipe->requiredItems.numContainerObjects; i++) { const auto component = recipe->requiredItems.GetContainerObjectAt(i).value(); const auto formID = (component && component->obj) ? component->obj->formID : NULL; @@ -274,13 +275,12 @@ inline void FetchSupplies(RE::TESFurniture* a_furn) std::thread([a_furn]() { std::this_thread::sleep_for(std::chrono::milliseconds(1)); SKSE::GetTaskInterface()->AddTask([a_furn]() { - bool bNotify = GetSettings().at("ShowFetchingNotification"); switch (a_furn->workBenchData.benchType.underlying()) { case (int)RE::TESFurniture::WorkBenchData::BenchType::kAlchemy: case (int)RE::TESFurniture::WorkBenchData::BenchType::kAlchemyExperiment: - NotifyFetching("Fetching alchemy ingredients..."); + NotifyFetching("Fetching ingredients..."); FetchSuppliesByType(RE::FormType::Ingredient); break; @@ -291,37 +291,8 @@ inline void FetchSupplies(RE::TESFurniture* a_furn) break; default: - if (a_furn->As()->HasKeywordString("CraftingCookpot")) { - NotifyFetching("Fetching cooking ingredients..."); - FetchByWorkbenchKeyword(RE::TESForm::LookupByID(0xA5CB3)); // CraftingCookpot - - } else if (a_furn->As()->HasKeywordString("CraftingSmelter")) { - NotifyFetching("Fetching smelting supplies..."); - FetchByWorkbenchKeyword(RE::TESForm::LookupByID(0xA5CCE)); // CraftingSmelter - - } else if (a_furn->As()->HasKeywordString("CraftingTanningRack")) { - NotifyFetching("Fetching tanning supplies..."); - FetchByWorkbenchKeyword(RE::TESForm::LookupByID(0x7866A)); // CraftingTanningRack - - } else if (a_furn->As()->HasKeywordString("CraftingSmithingSharpeningWheel")) { - NotifyFetching("Fetching crafting supplies..."); - FetchByWorkbenchKeyword(RE::TESForm::LookupByID(0x88108)); // CraftingSmithingSharpeningWheel - - } else if (a_furn->As()->HasKeywordString("CraftingSmithingForge")) { - NotifyFetching("Fetching crafting supplies..."); - FetchByWorkbenchKeyword(RE::TESForm::LookupByID(0x88105)); // CraftingSmithingForge - - } else if (a_furn->As()->HasKeywordString("CraftingSmithingArmorTable")) { - NotifyFetching("Fetching crafting supplies..."); - FetchByWorkbenchKeyword(RE::TESForm::LookupByID(0xADB78)); // CraftingSmithingArmorTable - - } else { - NotifyFetching("Fetching crafting supplies..."); - FetchSuppliesByType(RE::FormType::Misc); - FetchSuppliesByType(RE::FormType::Ingredient); - FetchSuppliesByType(RE::FormType::SoulGem); - FetchSuppliesByType(RE::FormType::AlchemyItem); - } + NotifyFetching("Fetching supplies..."); + FetchByWorkbench(a_furn); } }); }).detach();