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,21 +375,20 @@ namespace ArtifactTracker
|
|||||||
log::info("Adding new storage in {}", cell->GetName());
|
log::info("Adding new storage in {}", cell->GetName());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
cellStorage = RE::PlayerCharacter::GetSingleton()->PlaceObjectAtMe(g_cellContainer, true).get();
|
SKSE::GetTaskInterface()->AddTask([&]() {
|
||||||
|
cellStorage = RE::PlayerCharacter::GetSingleton()->PlaceObjectAtMe(g_cellContainer, true).get();
|
||||||
|
|
||||||
if (cellStorage) {
|
if (cellStorage) {
|
||||||
cellStorage->Disable();
|
cellStorage->Disable();
|
||||||
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