Create cell storage in a task, fixes CTD when accessing a created container from another thread
This commit is contained in:
parent
4a1218782f
commit
7918a84386
Binary file not shown.
Binary file not shown.
@ -375,6 +375,7 @@ namespace ArtifactTracker
|
|||||||
log::info("Adding new storage in {}", cell->GetName());
|
log::info("Adding new storage in {}", cell->GetName());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SKSE::GetTaskInterface()->AddTask([&]() {
|
||||||
cellStorage = RE::PlayerCharacter::GetSingleton()->PlaceObjectAtMe(g_cellContainer, true).get();
|
cellStorage = RE::PlayerCharacter::GetSingleton()->PlaceObjectAtMe(g_cellContainer, true).get();
|
||||||
|
|
||||||
if (cellStorage) {
|
if (cellStorage) {
|
||||||
@ -382,14 +383,12 @@ namespace ArtifactTracker
|
|||||||
g_persistentStorage->AddForm(cellStorage);
|
g_persistentStorage->AddForm(cellStorage);
|
||||||
g_persistentMap[cellStorage->formID] = cellStorage;
|
g_persistentMap[cellStorage->formID] = cellStorage;
|
||||||
ToggleHomeMode(cellStorage);
|
ToggleHomeMode(cellStorage);
|
||||||
std::thread([]() {
|
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
|
||||||
SyncCellStorage();
|
SyncCellStorage();
|
||||||
}).detach();
|
|
||||||
} else {
|
} else {
|
||||||
log::error("Failed to create cell storage in OnCellEnter");
|
log::error("Failed to create cell storage in OnCellEnter");
|
||||||
ToggleHomeMode(nullptr);
|
ToggleHomeMode(nullptr);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyncCellStorage(const RE::TESObjectREFR* a_ignoreRef)
|
void SyncCellStorage(const RE::TESObjectREFR* a_ignoreRef)
|
||||||
|
Loading…
Reference in New Issue
Block a user