Precache books as an unordered map
This commit is contained in:
parent
58890efc21
commit
1e71ef6032
Binary file not shown.
@ -3,7 +3,7 @@
|
||||
// Mostly borrowed from Fix Note icon for SkyUI by 0xC0000005
|
||||
namespace BookCheck
|
||||
{
|
||||
std::vector<RE::TESObjectBOOK*> validBooks;
|
||||
std::unordered_map<RE::FormID, RE::TESObjectBOOK*> validBooks;
|
||||
|
||||
void PreloadBookList()
|
||||
{
|
||||
@ -20,12 +20,12 @@ namespace BookCheck
|
||||
continue;
|
||||
}
|
||||
if (form->HasKeyword(recipeKeyword) || IsBook(form)) {
|
||||
validBooks.push_back(form);
|
||||
validBooks[form->formID] = form;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<RE::TESObjectBOOK*> GetBookList()
|
||||
std::unordered_map<RE::FormID, RE::TESObjectBOOK*> GetBookList()
|
||||
{
|
||||
return validBooks;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace BookCheck
|
||||
{
|
||||
void PreloadBookList();
|
||||
|
||||
std::vector<RE::TESObjectBOOK*> GetBookList();
|
||||
std::unordered_map<RE::FormID, RE::TESObjectBOOK*> GetBookList();
|
||||
|
||||
const char* ExtractFileName(const char* const path, size_t& fileNameLength);
|
||||
|
||||
|
@ -132,7 +132,7 @@ namespace Papyrus::ArtifactTracker
|
||||
a_exform.formType == RE::FormType::Armor
|
||||
|| (a_exform.formType == RE::FormType::Weapon && a_exform.formID != 0x000001F4)
|
||||
|| a_exform.formType == RE::FormType::Misc
|
||||
|| (a_exform.formType == RE::FormType::Book && !a_exform.As<RE::TESObjectBOOK>()->TeachesSpell() && (a_exform.As<RE::BGSKeywordForm>()->HasKeyword(recipeKeyword) || BookCheck::IsBook(a_exform.As<RE::TESObjectBOOK>())))
|
||||
|| (a_exform.formType == RE::FormType::Book && BookCheck::GetBookList().contains(a_exform.formID))
|
||||
)
|
||||
&& (excludeOnlyMisc ? (a_exform.formType != RE::FormType::Misc || !is_excluded(&a_exform, a_excludeForm)) : !is_excluded(&a_exform, a_excludeForm));
|
||||
});
|
||||
@ -307,14 +307,14 @@ namespace Papyrus::ArtifactTracker
|
||||
}
|
||||
|
||||
if (a_excludeForm) {
|
||||
for (const auto& book : BookCheck::GetBookList()) {
|
||||
if (!is_excluded(book, a_excludeForm)) {
|
||||
a_targetList->AddForm(book);
|
||||
for (auto const& item : BookCheck::GetBookList()) {
|
||||
if (!is_excluded(item.second, a_excludeForm)) {
|
||||
a_targetList->AddForm(item.second);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (const auto& book : BookCheck::GetBookList()) {
|
||||
a_targetList->AddForm(book);
|
||||
for (const auto& item : BookCheck::GetBookList()) {
|
||||
a_targetList->AddForm(item.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,15 +27,11 @@ namespace {
|
||||
}
|
||||
|
||||
void InitializeMessaging() {
|
||||
if (!GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) {
|
||||
|
||||
GetMessagingInterface()->RegisterListener([](MessagingInterface::Message* message) {
|
||||
if (message->type == MessagingInterface::kDataLoaded) {
|
||||
BookCheck::PreloadBookList();
|
||||
}
|
||||
|
||||
})) {
|
||||
stl::report_and_fail("Unable to register message listener.");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user