1
Fork 0

Do not iterate through remaining followers when item is found

ae-1.6.629
Eddoursul 2 years ago
parent 8d6db7e045
commit 8039f6315f
  1. BIN
      SKSE/Plugins/ArtifactTracker.dll
  2. 4
      Source/ArtifactTrackerDLL/src/ArtifactTracker.cpp
  3. 10
      Source/ArtifactTrackerDLL/src/Util.h

Binary file not shown.

@ -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);
} }

@ -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;
} }

Loading…
Cancel
Save