Minor tweaks

This commit is contained in:
Eddoursul 2022-08-21 18:20:02 +02:00
parent eedd2dff54
commit 2870d020ce
2 changed files with 10 additions and 15 deletions

View File

@ -4,6 +4,7 @@
static std::unordered_map<RE::TESForm*, std::uint32_t> supplyCount = {};
static bool bSuppliesFetched = false;
static constexpr RE::ITEM_REMOVE_REASON iRemoveReason = RE::ITEM_REMOVE_REASON::kStoreInContainer;
inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
{
@ -48,7 +49,7 @@ inline void LoadINI(std::map<std::string, bool>* 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::BGSKeywordForm>();
RE::ITEM_REMOVE_REASON iReason = RE::ITEM_REMOVE_REASON::kStoreInContainer;
for (const auto& recipe : RE::TESDataHandler::GetSingleton()->GetFormArray<RE::BGSConstructibleObject>()) {
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<RE::TESBoundObject>(), item.second, iReason, nullptr, chest, 0, 0);
playerRef->RemoveItem(item.first->As<RE::TESBoundObject>(), 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()) {