1

Removed redundant IsDeleted checks

This commit is contained in:
Eddoursul 2022-07-08 01:10:14 +02:00
parent f2cbb5ea8a
commit 11311399ce
3 changed files with 17 additions and 7 deletions

Binary file not shown.

View File

@ -62,7 +62,7 @@ namespace ArtifactTracker
g_artifactFormTypes.insert(RE::FormType::Weapon); g_artifactFormTypes.insert(RE::FormType::Weapon);
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectWEAP>()) { for (const auto& form : dataHandler->GetFormArray<RE::TESObjectWEAP>()) {
if (form->GetPlayable() && !form->IsBound() && !form->weaponData.flags.all(RE::TESObjectWEAP::Data::Flag::kCantDrop) && !form->IsDeleted()) { if (form->GetPlayable() && !form->IsBound() && !form->weaponData.flags.all(RE::TESObjectWEAP::Data::Flag::kCantDrop)) {
if ((!form->HasKeyword(notArtifactKeyword) || form->HasKeyword(extraArtifactKeyword)) && strlen(form->GetName()) > 0) { if ((!form->HasKeyword(notArtifactKeyword) || form->HasKeyword(extraArtifactKeyword)) && strlen(form->GetName()) > 0) {
g_artifactMap[form->formID] = form; g_artifactMap[form->formID] = form;
} }
@ -72,7 +72,7 @@ namespace ArtifactTracker
g_artifactFormTypes.insert(RE::FormType::Armor); g_artifactFormTypes.insert(RE::FormType::Armor);
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectARMO>()) { for (const auto& form : dataHandler->GetFormArray<RE::TESObjectARMO>()) {
if (form->GetPlayable() && !form->IsDeleted() && form->race && (form->race->formID == 0x19 || form->race->HasKeyword(npcRaceKeyword))) { if (form->GetPlayable() && form->race && (form->race->formID == 0x19 || form->race->HasKeyword(npcRaceKeyword))) {
if ((!form->HasKeyword(notArtifactKeyword) || form->HasKeyword(extraArtifactKeyword)) && strlen(form->GetName()) > 0) { if ((!form->HasKeyword(notArtifactKeyword) || form->HasKeyword(extraArtifactKeyword)) && strlen(form->GetName()) > 0) {
g_artifactMap[form->formID] = form; g_artifactMap[form->formID] = form;
} }
@ -84,14 +84,14 @@ namespace ArtifactTracker
g_artifactFormTypes.insert(RE::FormType::Book); g_artifactFormTypes.insert(RE::FormType::Book);
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectBOOK>()) { for (const auto& form : dataHandler->GetFormArray<RE::TESObjectBOOK>()) {
if (!form->IsDeleted() && (form->HasKeyword(extraArtifactKeyword) || (!form->TeachesSpell() && BookCheck::IsBook(form))) && !form->HasKeyword(notArtifactKeyword)) { if ((form->HasKeyword(extraArtifactKeyword) || (!form->TeachesSpell() && BookCheck::IsBook(form))) && !form->HasKeyword(notArtifactKeyword)) {
g_artifactMap[form->formID] = form; g_artifactMap[form->formID] = form;
} }
} }
g_artifactFormTypes.insert(RE::FormType::Misc); g_artifactFormTypes.insert(RE::FormType::Misc);
for (const auto& form : dataHandler->GetFormArray<RE::TESObjectMISC>()) { for (const auto& form : dataHandler->GetFormArray<RE::TESObjectMISC>()) {
if (form->GetPlayable() && !form->IsDeleted() && (form->GetNumKeywords() == 0 || (!bKID && form->HasKeyword(extraArtifactKeyword)) || (bKID && (!form->HasKeyword(notArtifactKeyword) || form->HasKeyword(extraArtifactKeyword)))) && strlen(form->GetName()) > 0) { if (form->GetPlayable() && (form->GetNumKeywords() == 0 || (!bKID && form->HasKeyword(extraArtifactKeyword)) || (bKID && (!form->HasKeyword(notArtifactKeyword) || form->HasKeyword(extraArtifactKeyword)))) && strlen(form->GetName()) > 0) {
g_artifactMap[form->formID] = form; g_artifactMap[form->formID] = form;
} }
} }
@ -99,21 +99,21 @@ namespace ArtifactTracker
g_artifactMap.erase(0xF); // Gold g_artifactMap.erase(0xF); // Gold
for (const auto& form : dataHandler->GetFormArray<RE::AlchemyItem>()) { for (const auto& form : dataHandler->GetFormArray<RE::AlchemyItem>()) {
if (!form->IsDeleted() && form->HasKeyword(extraArtifactKeyword) && !form->HasKeyword(notArtifactKeyword)) { if (form->HasKeyword(extraArtifactKeyword) && !form->HasKeyword(notArtifactKeyword)) {
g_artifactMap[form->formID] = form; g_artifactMap[form->formID] = form;
g_artifactFormTypes.insert(RE::FormType::AlchemyItem); g_artifactFormTypes.insert(RE::FormType::AlchemyItem);
} }
} }
for (const auto& form : dataHandler->GetFormArray<RE::IngredientItem>()) { for (const auto& form : dataHandler->GetFormArray<RE::IngredientItem>()) {
if (!form->IsDeleted() && form->HasKeyword(extraArtifactKeyword) && !form->HasKeyword(notArtifactKeyword)) { if (form->HasKeyword(extraArtifactKeyword) && !form->HasKeyword(notArtifactKeyword)) {
g_artifactMap[form->formID] = form; g_artifactMap[form->formID] = form;
g_artifactFormTypes.insert(RE::FormType::Ingredient); g_artifactFormTypes.insert(RE::FormType::Ingredient);
} }
} }
for (const auto& form : dataHandler->GetFormArray<RE::TESSoulGem>()) { for (const auto& form : dataHandler->GetFormArray<RE::TESSoulGem>()) {
if (!form->IsDeleted() && form->HasKeyword(extraArtifactKeyword) && !form->HasKeyword(notArtifactKeyword)) { if (form->HasKeyword(extraArtifactKeyword) && !form->HasKeyword(notArtifactKeyword)) {
g_artifactMap[form->formID] = form; g_artifactMap[form->formID] = form;
g_artifactFormTypes.insert(RE::FormType::SoulGem); g_artifactFormTypes.insert(RE::FormType::SoulGem);
} }

View File

@ -178,3 +178,13 @@ inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
SKSE::log::error(e.what()); SKSE::log::error(e.what());
} }
} }
inline void RunBenchmark(std::function<void()> benchmark, std::string desc)
{
const auto start = std::chrono::high_resolution_clock::now();
benchmark();
const auto end = std::chrono::high_resolution_clock::now();
const auto elapsed = std::chrono::duration<double>(end - start);
SKSE::log::info("{}: Elapsed time: {} seconds", desc, elapsed.count());
}