diff --git a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp index 75cd2015..fb576016 100644 --- a/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp +++ b/dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp @@ -121,21 +121,8 @@ const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& foun const std::set CDMissionsTable::GetMissionsForReward(LOT lot) { std::set toReturn {}; for (const auto& entry : GetEntries()) { - if (lot == entry.reward_item1) { + if (lot == entry.reward_item1 || lot == entry.reward_item2 || lot == entry.reward_item3 || lot == entry.reward_item4) { toReturn.insert(entry.id); - continue; - } - if (lot == entry.reward_item2) { - toReturn.insert(entry.id); - continue; - } - if (lot == entry.reward_item3) { - toReturn.insert(entry.id); - continue; - } - if (lot == entry.reward_item4) { - toReturn.insert(entry.id); - continue; } } return toReturn; diff --git a/dGame/dComponents/AchievementVendorComponent.cpp b/dGame/dComponents/AchievementVendorComponent.cpp index 79b1f2b1..16d165a2 100644 --- a/dGame/dComponents/AchievementVendorComponent.cpp +++ b/dGame/dComponents/AchievementVendorComponent.cpp @@ -9,12 +9,21 @@ #include "UserManager.h" #include "CDMissionsTable.h" -bool AchievementVendorComponent::SellsItem( Entity* buyer, const LOT lot) const { +bool AchievementVendorComponent::SellsItem(Entity* buyer, const LOT lot) const { auto* missionComponent = buyer->GetComponent(); + if (!missionComponent) return false; + + if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)){ + return true; + } + CDMissionsTable* missionsTable = CDClientManager::GetTable(); const auto missions = missionsTable->GetMissionsForReward(lot); for (const auto mission : missions) { - if (missionComponent->GetMissionState(mission) == eMissionState::COMPLETE) return true; + if (missionComponent->GetMissionState(mission) == eMissionState::COMPLETE) { + m_PlayerPurchasableItems[buyer->GetObjectID()].insert(lot); + return true; + } } return false; } diff --git a/dGame/dComponents/AchievementVendorComponent.h b/dGame/dComponents/AchievementVendorComponent.h index c5985f04..5b919ad9 100644 --- a/dGame/dComponents/AchievementVendorComponent.h +++ b/dGame/dComponents/AchievementVendorComponent.h @@ -14,7 +14,7 @@ class AchievementVendorComponent final : public VendorComponent { void Buy(Entity* buyer, LOT lot, uint32_t count); private: - + std::map> m_PlayerPurchasableItems; };