1

Save in cell storage all artifact form types - allows to properly update statuses of non-persistent items after changes in the artifact list

This commit is contained in:
Eddoursul 2022-07-16 20:14:12 +02:00
parent deaac1c723
commit ea079eafae
3 changed files with 15 additions and 5 deletions

Binary file not shown.

View File

@ -23,6 +23,7 @@ namespace ArtifactTracker
RE::BGSKeyword* g_homeKeyword; RE::BGSKeyword* g_homeKeyword;
std::unordered_map<RE::FormID, RE::TESForm*> g_artifactMap; std::unordered_map<RE::FormID, RE::TESForm*> g_artifactMap;
std::unordered_set<RE::FormType> g_artifactFormTypes; std::unordered_set<RE::FormType> g_artifactFormTypes;
std::unordered_set<RE::FormType> g_artifactAllFormTypes;
std::unordered_map<RE::FormID, RE::TESObjectREFR*> g_persistentMap; std::unordered_map<RE::FormID, RE::TESObjectREFR*> g_persistentMap;
RE::TESObjectREFR* g_cellStorage; RE::TESObjectREFR* g_cellStorage;
const SKSE::LoadInterface* g_loadInterface; const SKSE::LoadInterface* g_loadInterface;
@ -72,6 +73,14 @@ namespace ArtifactTracker
// Preloading item lists // Preloading item lists
g_artifactAllFormTypes.insert(RE::FormType::Weapon);
g_artifactAllFormTypes.insert(RE::FormType::Armor);
g_artifactAllFormTypes.insert(RE::FormType::Book);
g_artifactAllFormTypes.insert(RE::FormType::Misc);
g_artifactAllFormTypes.insert(RE::FormType::AlchemyItem);
g_artifactAllFormTypes.insert(RE::FormType::Ingredient);
g_artifactAllFormTypes.insert(RE::FormType::SoulGem);
g_artifactFormTypes.insert(RE::FormType::Weapon); g_artifactFormTypes.insert(RE::FormType::Weapon);
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectWEAP>()) { for (const auto& form : dataHandler->GetFormArray<RE::TESObjectWEAP>()) {
if (form->GetPlayable() && !form->IsBound() && !form->weaponData.flags.all(RE::TESObjectWEAP::Data::Flag::kCantDrop)) { if (form->GetPlayable() && !form->IsBound() && !form->weaponData.flags.all(RE::TESObjectWEAP::Data::Flag::kCantDrop)) {
@ -425,7 +434,7 @@ namespace ArtifactTracker
} }
const auto contInv = a_ref.GetInventory([&](RE::TESBoundObject& a_object) -> bool { const auto contInv = a_ref.GetInventory([&](RE::TESBoundObject& a_object) -> bool {
return !cellItems.contains(a_object.formID) && IsArtifact(&a_object); return !cellItems.contains(a_object.formID) && g_artifactAllFormTypes.contains(a_object.GetFormType());
}); });
for (const auto& [item, data] : contInv) { for (const auto& [item, data] : contInv) {
@ -434,7 +443,7 @@ namespace ArtifactTracker
if (inv.find(item) == inv.end()) { if (inv.find(item) == inv.end()) {
g_cellStorage->AddObjectToContainer(item, nullptr, 1, nullptr); g_cellStorage->AddObjectToContainer(item, nullptr, 1, nullptr);
} }
if (!g_listStored->HasForm(item)) { if (IsArtifact(item) && !g_listStored->HasForm(item)) {
ListRemoveItem(g_listNew, item); ListRemoveItem(g_listNew, item);
ListRemoveItem(g_listFound, item); ListRemoveItem(g_listFound, item);
g_listStored->AddForm(item); g_listStored->AddForm(item);
@ -445,7 +454,7 @@ namespace ArtifactTracker
return true; return true;
} }
if (a_ref.IsDisabled() || a_ref.IsMarkedForDeletion() || cellItems.contains(baseObj->formID) || !IsArtifact(baseObj)) { if (!g_artifactAllFormTypes.contains(baseObj->GetFormType()) || a_ref.IsDisabled() || a_ref.IsMarkedForDeletion() || cellItems.contains(baseObj->formID)) {
return true; return true;
} }
@ -455,7 +464,7 @@ namespace ArtifactTracker
g_cellStorage->AddObjectToContainer(baseObj, nullptr, 1, nullptr); g_cellStorage->AddObjectToContainer(baseObj, nullptr, 1, nullptr);
} }
if (!g_listStored->HasForm(baseObj)) { if (IsArtifact(baseObj) && !g_listStored->HasForm(baseObj)) {
ListRemoveItem(g_listNew, baseObj); ListRemoveItem(g_listNew, baseObj);
ListRemoveItem(g_listFound, baseObj); ListRemoveItem(g_listFound, baseObj);
g_listStored->AddForm(baseObj); g_listStored->AddForm(baseObj);
@ -469,7 +478,7 @@ namespace ArtifactTracker
if (count > 0 && !cellItems.contains(item->formID)) { if (count > 0 && !cellItems.contains(item->formID)) {
g_cellStorage->RemoveItem(item, count, RE::ITEM_REMOVE_REASON::kRemove, nullptr, nullptr); g_cellStorage->RemoveItem(item, count, RE::ITEM_REMOVE_REASON::kRemove, nullptr, nullptr);
if (!RefListHasItem(g_persistentStorage, item->formID)) { if (IsArtifact(item) && !RefListHasItem(g_persistentStorage, item->formID)) {
ListRemoveItem(g_listStored, item); ListRemoveItem(g_listStored, item);
if (GetItemCount(RE::PlayerCharacter::GetSingleton(), item) || FollowersHaveItem(item)) { if (GetItemCount(RE::PlayerCharacter::GetSingleton(), item) || FollowersHaveItem(item)) {
ListRemoveItem(g_listNew, item); ListRemoveItem(g_listNew, item);

View File

@ -16,6 +16,7 @@ namespace ArtifactTracker
extern RE::BGSKeyword* g_homeKeyword; extern RE::BGSKeyword* g_homeKeyword;
extern std::unordered_map<RE::FormID, RE::TESForm*> g_artifactMap; extern std::unordered_map<RE::FormID, RE::TESForm*> g_artifactMap;
extern std::unordered_set<RE::FormType> g_artifactFormTypes; extern std::unordered_set<RE::FormType> g_artifactFormTypes;
extern std::unordered_set<RE::FormType> g_artifactAllFormTypes;
extern std::unordered_map<RE::FormID, RE::TESObjectREFR*> g_persistentMap; extern std::unordered_map<RE::FormID, RE::TESObjectREFR*> g_persistentMap;
extern RE::TESObjectREFR* g_cellStorage; extern RE::TESObjectREFR* g_cellStorage;
extern const SKSE::LoadInterface* g_loadInterface; extern const SKSE::LoadInterface* g_loadInterface;