1

Do not iterate through remaining followers when item is found

This commit is contained in:
Eddoursul 2022-07-02 18:37:52 +02:00
parent 8d6db7e045
commit 8039f6315f
3 changed files with 7 additions and 7 deletions

Binary file not shown.

View File

@ -418,7 +418,7 @@ namespace ArtifactTracker
} }
// NB: During OnContainerChanged, InventoryChanges do not have the current change included yet // NB: During OnContainerChanged, InventoryChanges do not have the current change included yet
if ((GetItemCount(RE::PlayerCharacter::GetSingleton(), form->formID) - a_event->itemCount <= 0) && GetFollowerItemCount(form->formID) <= 0) { if ((GetItemCount(RE::PlayerCharacter::GetSingleton(), form->formID) - a_event->itemCount <= 0) && !FollowersHaveItem(form->formID)) {
ListRemoveItem(g_listFound, form); ListRemoveItem(g_listFound, form);
ListRemoveItem(g_listNew, form); ListRemoveItem(g_listNew, form);
g_listNew->AddForm(form); g_listNew->AddForm(form);
@ -457,7 +457,7 @@ namespace ArtifactTracker
} }
// NB: During OnContainerChanged, InventoryChanges do not have the current change included yet // NB: During OnContainerChanged, InventoryChanges do not have the current change included yet
} else if (g_listFound->HasForm(form) && (GetItemCount(RE::PlayerCharacter::GetSingleton(), form->formID) - a_event->itemCount <= 0) && GetFollowerItemCount(form->formID) <= 0) { } else if (g_listFound->HasForm(form) && (GetItemCount(RE::PlayerCharacter::GetSingleton(), form->formID) - a_event->itemCount <= 0) && !FollowersHaveItem(form->formID)) {
ListRemoveItem(g_listFound, form); ListRemoveItem(g_listFound, form);
g_listNew->AddForm(form); g_listNew->AddForm(form);
} }

View File

@ -72,19 +72,19 @@ inline bool RefHasItem(RE::TESForm* a_refOrList, RE::FormID a_formID)
return false; return false;
} }
inline std::uint32_t GetFollowerItemCount(RE::FormID a_formID) inline bool FollowersHaveItem(RE::FormID a_formID)
{ {
std::int32_t iResult = 0;
if (const auto processLists = RE::ProcessLists::GetSingleton(); processLists) { if (const auto processLists = RE::ProcessLists::GetSingleton(); processLists) {
for (auto& actorHandle : processLists->highActorHandles) { for (auto& actorHandle : processLists->highActorHandles) {
if (auto actor = actorHandle.get(); actor && actor->IsPlayerTeammate()) { if (auto actor = actorHandle.get(); actor && actor->IsPlayerTeammate()) {
iResult += GetItemCount(actor->As<RE::TESObjectREFR>(), a_formID); if (GetItemCount(actor->As<RE::TESObjectREFR>(), a_formID) > 0) {
return true;
}
} }
} }
} }
return iResult; return false;
} }