fix stale reference (#1594)

This commit is contained in:
David Markowitz 2024-05-24 07:15:30 -07:00 committed by GitHub
parent f0960d48b2
commit 8ae1a8ff7c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -76,8 +76,8 @@ void VendorComponent::RefreshInventory(bool isCreation) {
if (vendorItems.empty()) break;
auto randomItemIndex = GeneralUtils::GenerateRandomNumber<int32_t>(0, vendorItems.size() - 1);
const auto& randomItem = vendorItems.at(randomItemIndex);
vendorItems.erase(vendorItems.begin() + randomItemIndex);
if (SetupItem(randomItem.itemid)) m_Inventory.push_back(SoldItem(randomItem.itemid, randomItem.sortPriority));
vendorItems.erase(vendorItems.begin() + randomItemIndex);
}
}
}