1

Schedule inventory checks in OnContainerChanged to work around a non-deterministic issue, when ContainerChanges has not been propagated yet

This commit is contained in:
Eddoursul 2022-07-18 15:13:23 +02:00
parent 29f7c4e566
commit 4220779b99
4 changed files with 21 additions and 13 deletions

Binary file not shown.

View File

@ -6,7 +6,7 @@ message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.")
########################################################################################################################
project(
ArtifactTracker
VERSION 1.0.4
VERSION 1.0.5
DESCRIPTION "Artifact Tracker"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 23)

View File

@ -627,11 +627,15 @@ namespace ArtifactTracker
g_listStored->AddForm(form);
}
} else if (a_event->oldContainer == 0x14 && !g_listStored->HasForm(form) && !GetItemCount(RE::PlayerCharacter::GetSingleton(), form) && !FollowersHaveItem(form)) {
} else if (a_event->oldContainer == 0x14 && !g_listStored->HasForm(form)) {
SKSE::GetTaskInterface()->AddTask([form]() {
if (!GetItemCount(RE::PlayerCharacter::GetSingleton(), form) && !FollowersHaveItem(form)) {
// disposed by player
ListRemoveItem(g_listFound, form);
g_listNew->AddForm(form);
}
});
}
}
}
}
@ -664,6 +668,9 @@ namespace ArtifactTracker
} else if (a_event->oldContainer == 0x14) { // dropped, consumed, dismantled, removed by script
if (!g_listStored->HasForm(form)) {
// Seems like OnContainerChanged runs concurrently with updating ContainerChanges.
// In small modlists ContainerChanges may not be propagated yet in this event, so we need to schedule GetItemCount.
SKSE::GetTaskInterface()->AddTask([form]() {
if (!GetItemCount(RE::PlayerCharacter::GetSingleton(), form) && !FollowersHaveItem(form)) {
ListRemoveItem(g_listFound, form);
g_listNew->AddForm(form);
@ -672,6 +679,7 @@ namespace ArtifactTracker
ListRemoveItem(g_listNew, form);
g_listFound->AddForm(form);
}
});
}
} else if (g_cellStorage && g_cellStorage->formID == a_event->oldContainer) {

View File

@ -1,7 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/vcpkg/master/scripts/vcpkg.schema.json",
"name": "artifact-tracker",
"version-string": "1.0.4",
"version-string": "1.0.5",
"port-version": 0,
"description": "Artifact Tracker",
"homepage": "https://eddoursul.win/mods/artifact-tracker/",