Minor refactoring, removed HasRefInCell
This commit is contained in:
parent
4341644277
commit
e54adbd097
Binary file not shown.
Binary file not shown.
@ -52,17 +52,18 @@ namespace Papyrus::ArtifactTracker
|
||||
|
||||
inline bool is_artifact(RE::TESForm* a_form)
|
||||
{
|
||||
if (!a_form->GetPlayable()) {
|
||||
return false;
|
||||
switch (a_form->GetFormType()) {
|
||||
case RE::FormType::Armor:
|
||||
return a_form->GetPlayable();
|
||||
case RE::FormType::Weapon:
|
||||
return a_form->GetPlayable() && a_form->formID != 0x000001F4;
|
||||
case RE::FormType::Book:
|
||||
return BookCheck::GetBookList().contains(a_form->formID);
|
||||
case RE::FormType::Misc:
|
||||
return MiscCheck::GetMiscList().contains(a_form->formID);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
const auto formType = a_form->GetFormType();
|
||||
|
||||
return (
|
||||
formType == RE::FormType::Armor
|
||||
|| (formType == RE::FormType::Weapon && a_form->formID != 0x000001F4)
|
||||
|| (formType == RE::FormType::Book && BookCheck::GetBookList().contains(a_form->formID))
|
||||
|| (formType == RE::FormType::Misc && MiscCheck::GetMiscList().contains(a_form->formID)));
|
||||
}
|
||||
|
||||
inline std::int32_t AddAllFormsToList(RE::StaticFunctionTag*,
|
||||
@ -72,34 +73,43 @@ namespace Papyrus::ArtifactTracker
|
||||
{
|
||||
const auto formType = static_cast<RE::FormType>(a_formType);
|
||||
|
||||
if (formType == RE::FormType::Book) {
|
||||
for (auto const& item : BookCheck::GetBookList()) {
|
||||
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) {
|
||||
a_targetList->AddForm(item.second);
|
||||
}
|
||||
}
|
||||
} else if (formType == RE::FormType::Misc) {
|
||||
for (auto const& item : MiscCheck::GetMiscList()) {
|
||||
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) {
|
||||
a_targetList->AddForm(item.second);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const auto dataHandler = RE::TESDataHandler::GetSingleton();
|
||||
switch (formType) {
|
||||
|
||||
if (!dataHandler) {
|
||||
return a_targetList->forms.size();
|
||||
}
|
||||
case RE::FormType::Book:
|
||||
for (auto const& item : BookCheck::GetBookList()) {
|
||||
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) {
|
||||
a_targetList->AddForm(item.second);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
for (const auto& form : dataHandler->GetFormArray(formType)) {
|
||||
if (!form || !form->GetPlayable()) {
|
||||
continue;
|
||||
case RE::FormType::Misc:
|
||||
for (auto const& item : MiscCheck::GetMiscList()) {
|
||||
if (!a_excludeForm || !is_excluded(item.second, a_excludeForm)) {
|
||||
a_targetList->AddForm(item.second);
|
||||
}
|
||||
}
|
||||
if (a_excludeForm && is_excluded(form, a_excludeForm)) {
|
||||
continue;
|
||||
break;
|
||||
|
||||
case RE::FormType::None:
|
||||
break;
|
||||
|
||||
default:
|
||||
const auto dataHandler = RE::TESDataHandler::GetSingleton();
|
||||
|
||||
if (!dataHandler) {
|
||||
return a_targetList->forms.size();
|
||||
}
|
||||
|
||||
for (const auto& form : dataHandler->GetFormArray(formType)) {
|
||||
if (!form || !form->GetPlayable()) {
|
||||
continue;
|
||||
}
|
||||
if (a_excludeForm && is_excluded(form, a_excludeForm)) {
|
||||
continue;
|
||||
}
|
||||
a_targetList->AddForm(form);
|
||||
}
|
||||
a_targetList->AddForm(form);
|
||||
}
|
||||
}
|
||||
|
||||
return a_targetList->forms.size();
|
||||
@ -111,11 +121,11 @@ namespace Papyrus::ArtifactTracker
|
||||
RE::TESForm* a_excludeForm = NULL)
|
||||
{
|
||||
if (!a_refOrList) {
|
||||
a_vm->TraceStack("a_refOrList in AddItemsOfTypeAndKeywordToList is None", a_stackID);
|
||||
a_vm->TraceStack("a_refOrList in AddArtifactsToList is None", a_stackID);
|
||||
return 0;
|
||||
}
|
||||
if (!a_targetList) {
|
||||
a_vm->TraceStack("a_targetList in AddItemsOfTypeAndKeywordToList is None", a_stackID);
|
||||
a_vm->TraceStack("a_targetList in AddArtifactsToList is None", a_stackID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -133,7 +143,7 @@ namespace Papyrus::ArtifactTracker
|
||||
const auto containerRef = a_refOrList->As<RE::TESObjectREFR>();
|
||||
|
||||
if (!containerRef) {
|
||||
a_vm->TraceStack("containerRef in AddItemsOfTypeAndKeywordToList is not a reference", a_stackID);
|
||||
a_vm->TraceStack("containerRef in AddArtifactsToList is not a reference", a_stackID);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -141,10 +151,9 @@ namespace Papyrus::ArtifactTracker
|
||||
return is_artifact(&a_exform) && !is_excluded(&a_exform, a_excludeForm);
|
||||
});
|
||||
|
||||
for (const auto& [item, data] : inv) {
|
||||
const auto& [count, entry] = data;
|
||||
if (count > 0) {
|
||||
a_targetList->AddForm(item);
|
||||
for (const auto& item : inv) {
|
||||
if (item.second.first > 0) {
|
||||
a_targetList->AddForm(item.first);
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,52 +194,6 @@ namespace Papyrus::ArtifactTracker
|
||||
return result;
|
||||
}
|
||||
|
||||
inline bool HasRefInCell(VM* a_vm, StackID a_stackID, RE::StaticFunctionTag*,
|
||||
RE::TESBoundObject* a_item,
|
||||
RE::TESObjectCELL* a_cell = NULL,
|
||||
bool a_checkInContainers = true,
|
||||
RE::BGSListForm* a_excludeList = NULL)
|
||||
{
|
||||
bool bResult = false;
|
||||
|
||||
if (!a_cell) {
|
||||
a_cell = RE::PlayerCharacter::GetSingleton()->GetParentCell();
|
||||
}
|
||||
|
||||
a_cell->ForEachReference([&](RE::TESObjectREFR& a_ref) {
|
||||
const auto baseObj = a_ref.GetBaseObject();
|
||||
|
||||
if (a_item->formID == baseObj->formID) {
|
||||
if (a_ref.IsDisabled() || a_ref.IsMarkedForDeletion()) {
|
||||
return true;
|
||||
}
|
||||
if (a_excludeList && a_excludeList->HasForm(a_ref.formID)) {
|
||||
return true;
|
||||
}
|
||||
bResult = true;
|
||||
return false;
|
||||
} else if (a_checkInContainers) {
|
||||
if (baseObj->formType == RE::FormType::Container || (baseObj->formType == RE::FormType::NPC && !a_ref.IsDisabled() && baseObj->As<RE::TESNPC>()->GetRace()->formID == 0x0010760A)) {
|
||||
if (a_excludeList && a_excludeList->HasForm(a_ref.formID)) {
|
||||
return true;
|
||||
}
|
||||
const auto inv = a_ref.GetInventory([&](RE::TESBoundObject& a_object) -> bool {
|
||||
return a_item->formID == a_object.formID;
|
||||
});
|
||||
const auto it = inv.find(a_item);
|
||||
if (it != inv.end() ? it->second.first : 0) {
|
||||
bResult = true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
inline void SyncCellStorage(VM* a_vm, StackID a_stackID, RE::StaticFunctionTag*,
|
||||
RE::TESObjectREFR* a_cellStorage,
|
||||
RE::TESForm* a_excludeForm = NULL)
|
||||
@ -245,7 +208,7 @@ namespace Papyrus::ArtifactTracker
|
||||
const auto cell = a_cellStorage->GetParentCell();
|
||||
const auto inv = a_cellStorage->GetInventory();
|
||||
|
||||
for (const auto a_ref : cell->references) {
|
||||
for (const RE::NiPointer<RE::TESObjectREFR> a_ref : cell->references) {
|
||||
const auto baseObj = a_ref->GetBaseObject();
|
||||
|
||||
if (baseObj->formType == RE::FormType::Container || (baseObj->formType == RE::FormType::NPC && !a_ref->IsDisabled() && baseObj->As<RE::TESNPC>()->GetRace()->formID == 0x0010760A)) {
|
||||
@ -258,8 +221,7 @@ namespace Papyrus::ArtifactTracker
|
||||
});
|
||||
|
||||
for (const auto& [item, data] : contInv) {
|
||||
const auto& [count, entry] = data;
|
||||
if (count > 0) {
|
||||
if (data.first > 0) {
|
||||
cellItems[item->formID] = true;
|
||||
if (inv.find(item) == inv.end()) {
|
||||
if (is_artifact(item) && !is_excluded(item, a_excludeForm)) {
|
||||
@ -311,8 +273,6 @@ namespace Papyrus::ArtifactTracker
|
||||
logger::info("Registered AddArtifactsToList"sv);
|
||||
BIND(GetCellStorage);
|
||||
logger::info("Registered GetCellStorage"sv);
|
||||
BIND(HasRefInCell);
|
||||
logger::info("Registered HasRefInCell"sv);
|
||||
BIND(SyncCellStorage);
|
||||
logger::info("Registered SyncCellStorage"sv);
|
||||
}
|
||||
|
@ -12,6 +12,4 @@ Actor[] function GetPlayerFollowers() native global
|
||||
|
||||
ObjectReference function GetCellStorage(ObjectReference ref, FormList refList, Form refToCreate, bool autoCreate = true) native global
|
||||
|
||||
bool function HasRefInCell(Form item, Cell currentCell = None, bool checkContainers = true, FormList excludeList = None) native global
|
||||
|
||||
function SyncCellStorage(ObjectReference cellStorage, Form excludeForm = None) native global
|
||||
|
Loading…
Reference in New Issue
Block a user