1

Renamed some variables

This commit is contained in:
Eddoursul 2024-07-04 18:08:44 +02:00
parent c53f9ba39b
commit c495c5e5a3

View File

@ -40,34 +40,34 @@ auto EventListener::ProcessEvent(
return RE::BSEventNotifyControl::kContinue;
}
const auto baseRef = a_event->objectActivated.get();
const auto baseObj = baseRef ? baseRef->GetBaseObject() : nullptr;
const auto initRef = a_event->objectActivated.get();
const auto initBase = initRef ? initRef->GetBaseObject() : nullptr;
if (!baseObj) {
if (!initBase) {
return RE::BSEventNotifyControl::kContinue;
}
if (!IsValidType(baseObj->GetFormType())) {
if (!IsValidType(initBase->GetFormType())) {
return RE::BSEventNotifyControl::kContinue;
}
RE::TESBoundObject* produceItem = nullptr;
bool bIsCoinPouch = IsCoinPouch(baseObj);
bool bIsGold = (bIsCoinPouch || baseObj->IsGold()) && std::any_cast<bool>(g_settings["bPickupGold"]);
bool bIsLockpick = baseObj->IsLockpick() && std::any_cast<bool>(g_settings["bPickupLockpicks"]);
bool bIsSoulGem = baseObj->IsSoulGem() && std::any_cast<bool>(g_settings["bPickupSoulGems"]);
bool bIsCoinPouch = IsCoinPouch(initBase);
bool bIsGold = (bIsCoinPouch || initBase->IsGold()) && std::any_cast<bool>(g_settings["bPickupGold"]);
bool bIsLockpick = initBase->IsLockpick() && std::any_cast<bool>(g_settings["bPickupLockpicks"]);
bool bIsSoulGem = initBase->IsSoulGem() && std::any_cast<bool>(g_settings["bPickupSoulGems"]);
RE::BGSKeywordForm* keywordForm = (baseObj->Is(RE::FormType::Misc) && std::any_cast<bool>(g_settings["bPickupMaterials"])) ? baseObj->As<RE::BGSKeywordForm>() : nullptr;
RE::BGSKeywordForm* keywordForm = (initBase->Is(RE::FormType::Misc) && std::any_cast<bool>(g_settings["bPickupMaterials"])) ? initBase->As<RE::BGSKeywordForm>() : nullptr;
bool bIsGem = keywordForm && keywordForm->HasKeyword(keywordGem);
bool bIsHide = keywordForm && keywordForm->HasKeyword(keywordHide);
bool bIsIngot = keywordForm && keywordForm->HasKeyword(keywordIngot);
bool bIsAmmo = (baseObj->IsAmmo() || baseObj->Is(RE::FormType::Projectile)) && baseObj->GetPlayable() && std::any_cast<bool>(g_settings["bPickupArrows"]);
bool bIsAmmo = (initBase->IsAmmo() || initBase->Is(RE::FormType::Projectile)) && initBase->GetPlayable() && std::any_cast<bool>(g_settings["bPickupArrows"]);
bool bIsFlora = !bIsCoinPouch && baseObj->Is(RE::FormType::Flora) && std::any_cast<bool>(g_settings["bPickupFlora"]) && (produceItem = baseObj->As<RE::TESFlora>()->produceItem);
bool bIsTree = baseObj->Is(RE::FormType::Tree) && std::any_cast<bool>(g_settings["bPickupFlora"]) && (produceItem = baseObj->As<RE::TESObjectTREE>()->produceItem);
bool bIsIngredient = baseObj->Is(RE::FormType::Ingredient) && std::any_cast<bool>(g_settings["bPickupIngredients"]);
bool bIsFlora = !bIsCoinPouch && initBase->Is(RE::FormType::Flora) && std::any_cast<bool>(g_settings["bPickupFlora"]) && (produceItem = initBase->As<RE::TESFlora>()->produceItem);
bool bIsTree = initBase->Is(RE::FormType::Tree) && std::any_cast<bool>(g_settings["bPickupFlora"]) && (produceItem = initBase->As<RE::TESObjectTREE>()->produceItem);
bool bIsIngredient = initBase->Is(RE::FormType::Ingredient) && std::any_cast<bool>(g_settings["bPickupIngredients"]);
if (!bIsGold && !bIsLockpick && !bIsSoulGem && !bIsGem && !bIsHide && !bIsIngot && !bIsAmmo && !bIsFlora && !bIsTree && !bIsIngredient) {
return RE::BSEventNotifyControl::kContinue;
@ -79,20 +79,20 @@ auto EventListener::ProcessEvent(
const auto TES = RE::TES::GetSingleton();
if (!TES || baseRef->IsMarkedForDeletion()) {
if (!TES || initRef->IsMarkedForDeletion()) {
return RE::BSEventNotifyControl::kContinue;
}
std::unordered_set<RE::TESObjectREFR*> refQueue;
TES->ForEachReferenceInRange(baseRef, static_cast<float>(std::any_cast<int>(g_settings["iRadius"])), [&](RE::TESObjectREFR* a_ref) {
TES->ForEachReferenceInRange(initRef, static_cast<float>(std::any_cast<int>(g_settings["iRadius"])), [&](RE::TESObjectREFR* a_ref) {
if (!a_ref) {
return RE::BSContainer::ForEachResult::kContinue;
}
const auto a_refBase = a_ref->GetBaseObject();
const auto refBase = a_ref->GetBaseObject();
if (!a_refBase || !IsValidType(a_refBase->GetFormType()) || a_ref == baseRef) {
if (!refBase || !IsValidType(refBase->GetFormType()) || a_ref == initRef) {
return RE::BSContainer::ForEachResult::kContinue;
}
@ -102,43 +102,43 @@ auto EventListener::ProcessEvent(
bool bAdd = false;
if (baseObj == a_refBase) {
if (initBase == refBase) {
bAdd = true;
} else if (bIsGold) {
if (a_refBase->IsGold() || IsCoinPouch(a_refBase)) {
if (refBase->IsGold() || IsCoinPouch(refBase)) {
bAdd = true;
}
} else if (bIsSoulGem) {
if (a_refBase->IsSoulGem()) {
if (refBase->IsSoulGem()) {
bAdd = true;
}
} else if (bIsAmmo) {
if ((a_refBase->IsAmmo() || a_refBase->Is(RE::FormType::Projectile)) && a_refBase->GetPlayable()) {
if ((refBase->IsAmmo() || refBase->Is(RE::FormType::Projectile)) && refBase->GetPlayable()) {
bAdd = true;
}
} else if (bIsGem) {
bAdd = a_refBase->Is(RE::FormType::Misc) && a_refBase->As<RE::BGSKeywordForm>()->HasKeyword(keywordGem);
bAdd = refBase->Is(RE::FormType::Misc) && refBase->As<RE::BGSKeywordForm>()->HasKeyword(keywordGem);
} else if (bIsHide) {
bAdd = a_refBase->Is(RE::FormType::Misc) && a_refBase->As<RE::BGSKeywordForm>()->HasKeyword(keywordHide);
bAdd = refBase->Is(RE::FormType::Misc) && refBase->As<RE::BGSKeywordForm>()->HasKeyword(keywordHide);
} else if (bIsIngot) {
bAdd = a_refBase->Is(RE::FormType::Misc) && a_refBase->As<RE::BGSKeywordForm>()->HasKeyword(keywordIngot);
bAdd = refBase->Is(RE::FormType::Misc) && refBase->As<RE::BGSKeywordForm>()->HasKeyword(keywordIngot);
} else if (bIsFlora || bIsTree || bIsIngredient) {
if (a_refBase == produceItem) {
if (refBase == produceItem) {
bAdd = true;
} else {
const auto floraBase = a_refBase->As<RE::TESFlora>();
if (floraBase && (floraBase->produceItem == produceItem || floraBase->produceItem == baseObj)) {
const auto floraBase = refBase->As<RE::TESFlora>();
if (floraBase && (floraBase->produceItem == produceItem || floraBase->produceItem == initBase)) {
bAdd = true;
} else {
const auto treeBase = a_refBase->As<RE::TESObjectTREE>();
if (treeBase && (treeBase->produceItem == produceItem || treeBase->produceItem == baseObj)) {
const auto treeBase = refBase->As<RE::TESObjectTREE>();
if (treeBase && (treeBase->produceItem == produceItem || treeBase->produceItem == initBase)) {
bAdd = true;
}
}