1

Rebuild the artifact list if its size changed

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

Binary file not shown.

Binary file not shown.

View File

@ -467,7 +467,7 @@ namespace ArtifactTracker
} }
// NB: During OnContainerChanged, InventoryChanges do not have the current change included yet // NB: During OnContainerChanged, InventoryChanges do not have the current change included yet
if ((GetItemCount(RE::PlayerCharacter::GetSingleton(), form->formID) - a_event->itemCount <= 0) && !FollowersHaveItem(form)) { if ((GetItemCount(RE::PlayerCharacter::GetSingleton(), form) - a_event->itemCount <= 0) && !FollowersHaveItem(form)) {
ListRemoveItem(g_listFound, form); ListRemoveItem(g_listFound, form);
ListRemoveItem(g_listNew, form); ListRemoveItem(g_listNew, form);
g_listNew->AddForm(form); g_listNew->AddForm(form);
@ -506,7 +506,7 @@ namespace ArtifactTracker
} }
// NB: During OnContainerChanged, InventoryChanges do not have the current change included yet // NB: During OnContainerChanged, InventoryChanges do not have the current change included yet
} else if (g_listFound->HasForm(form) && (GetItemCount(RE::PlayerCharacter::GetSingleton(), form->formID) - a_event->itemCount <= 0) && !FollowersHaveItem(form)) { } else if (g_listFound->HasForm(form) && (GetItemCount(RE::PlayerCharacter::GetSingleton(), form) - a_event->itemCount <= 0) && !FollowersHaveItem(form)) {
ListRemoveItem(g_listFound, form); ListRemoveItem(g_listFound, form);
g_listNew->AddForm(form); g_listNew->AddForm(form);
} }

View File

@ -20,6 +20,11 @@ namespace Papyrus::PapyrusFunctions
ArtifactTracker::SyncCellStorage(); ArtifactTracker::SyncCellStorage();
} }
inline std::uint32_t GetArtifactCount(RE::StaticFunctionTag*)
{
return (ArtifactTracker::g_artifactMap).size();
}
// From po3's Papyrus Extender // From po3's Papyrus Extender
inline std::vector<RE::Actor*> GetPlayerFollowers(RE::StaticFunctionTag*) inline std::vector<RE::Actor*> GetPlayerFollowers(RE::StaticFunctionTag*)
{ {
@ -72,6 +77,8 @@ namespace Papyrus::PapyrusFunctions
{ {
BIND(IsLoaded); BIND(IsLoaded);
logger::info("Registered IsLoaded"sv); logger::info("Registered IsLoaded"sv);
BIND(GetArtifactCount);
logger::info("Registered GetArtifactCount"sv);
BIND(RescanStoredArtifacts); BIND(RescanStoredArtifacts);
logger::info("Registered RescanStoredArtifacts"sv); logger::info("Registered RescanStoredArtifacts"sv);
BIND(RescanFoundArtifacts); BIND(RescanFoundArtifacts);

View File

@ -9,8 +9,9 @@ Keyword Property LocTypePlayerHouse Auto
Perk Property ETR_PickupPerk Auto Perk Property ETR_PickupPerk Auto
bool bAtHome = false bool bAtHome = false
int iFollowerIndex
ObjectReference bookShelf = None ObjectReference bookShelf = None
int iFollowerIndex = 0
int iArtifactCount = 0
event OnInit() event OnInit()
@ -51,6 +52,13 @@ Event OnPlayerLoadGame()
QuickLootEE.RegisterFoundItemsList(ETR_ItemsFound) QuickLootEE.RegisterFoundItemsList(ETR_ItemsFound)
endif endif
int iNewArtifactCount = GetArtifactCount()
if iNewArtifactCount != iArtifactCount
iArtifactCount = iNewArtifactCount
Debug.Notification("Artifact list changed, rebuilding the list")
ETR_ItemsNew.Revert() ; rebuild the list
endif
; Rebuild all lists to avoid discrepancies, stale data, and broken records ; Rebuild all lists to avoid discrepancies, stale data, and broken records
RescanStoredArtifacts() RescanStoredArtifacts()
RescanFoundArtifacts() RescanFoundArtifacts()
@ -159,6 +167,8 @@ endstate
bool function IsLoaded() native global bool function IsLoaded() native global
int function GetArtifactCount() native global
function RescanStoredArtifacts() native global function RescanStoredArtifacts() native global
function RescanFoundArtifacts() native global function RescanFoundArtifacts() native global