1

Exclude registered persistent containers during cell scan

This commit is contained in:
Eddoursul 2022-06-22 14:21:32 +02:00
parent 0e2a31fbb1
commit 812dfa556a
8 changed files with 8 additions and 7 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -198,6 +198,7 @@ namespace Papyrus::ArtifactTracker
inline void SyncCellStorage(VM* a_vm, StackID a_stackID, RE::StaticFunctionTag*,
RE::TESObjectREFR* a_cellStorage,
RE::BGSListForm* a_excludeContainers,
RE::TESForm* a_excludeForm = NULL)
{
if (!a_cellStorage) {
@ -206,7 +207,6 @@ namespace Papyrus::ArtifactTracker
std::unordered_map<RE::FormID, bool> cellItems;
const auto storageBase = a_cellStorage->GetBaseObject();
const auto cell = a_cellStorage->GetParentCell();
const auto inv = a_cellStorage->GetInventory();
@ -214,7 +214,7 @@ namespace Papyrus::ArtifactTracker
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)) {
if (a_ref->GetBaseObject()->formID == storageBase->formID) {
if (a_excludeContainers->HasForm(a_ref->formID)) {
continue;
}
@ -249,7 +249,7 @@ namespace Papyrus::ArtifactTracker
if (!is_artifact(baseObj)) {
continue;
}
if (inv.find(baseObj) == inv.end()) {
if (!a_excludeForm || !is_excluded(baseObj, a_excludeForm)) {
a_cellStorage->AddObjectToContainer(baseObj, nullptr, 1, nullptr);

View File

@ -8,7 +8,7 @@ int function GetItemCountInList(FormList refList, Form baseForm) native global
ObjectReference function GetCellStorage(ObjectReference ref, FormList refList, Form refToCreate, bool autoCreate = true) native global
function SyncCellStorage(ObjectReference cellStorage, Form excludeForm = None) native global
function SyncCellStorage(ObjectReference cellStorage, FormList excludeContainers, Form excludeForm = None) native global
Actor[] function GetPlayerFollowers() native global

View File

@ -87,7 +87,7 @@ Event OnUpdate()
endif
bRescanHome = false
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
ETR_Functions.SyncCellStorage(cellStorage)
ETR_Functions.SyncCellStorage(cellStorage, ETR_PersistentStorageList)
if ! bRescanPersistent
ETR_Functions.AddArtifactsToList(cellStorage, ETR_ItemsStored)
endif
@ -119,6 +119,7 @@ event OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemRefe
lastDestContainer = akDestContainer
lastDestIsPersistent = ETR_PersistentStorageList.HasForm(akDestContainer)
endif
; Moving items without latent functions should help with avoiding stack dumps
if lastDestIsPersistent
bRescanHome = false

View File

@ -78,7 +78,7 @@ Event OnUpdate()
return
endif
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
ETR_Functions.SyncCellStorage(cellStorage)
ETR_Functions.SyncCellStorage(cellStorage, ETR_PersistentStorageList)
endif
if bRescanPersistent
@ -118,7 +118,7 @@ event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemRefere
elseif bAtHome
ObjectReference cellStorage = ETR_Functions.GetCellStorage(PlayerRef, ETR_PersistentStorageList, ETR_CellStorageContainer)
if cellStorage.GetItemCount(akBaseItem)
ETR_Functions.SyncCellStorage(cellStorage)
ETR_Functions.SyncCellStorage(cellStorage, ETR_PersistentStorageList)
if ETR_Functions.GetItemCountInList(ETR_PersistentStorageList, akBaseItem) == 0
ETR_ItemsStored.RemoveAddedForm(akBaseItem)
ETR_ItemsFound.AddForm(akBaseItem)