Skip to content

Commit

Permalink
cache lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
aronwk-aaron committed Feb 25, 2024
1 parent 5674f76 commit c4d1a09
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
15 changes: 1 addition & 14 deletions dDatabase/CDClientDatabase/CDClientTables/CDMissionsTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,21 +121,8 @@ const CDMissions& CDMissionsTable::GetByMissionID(uint32_t missionID, bool& foun
const std::set<int32_t> CDMissionsTable::GetMissionsForReward(LOT lot) {
std::set<int32_t> 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;
Expand Down
13 changes: 11 additions & 2 deletions dGame/dComponents/AchievementVendorComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MissionComponent>();
if (!missionComponent) return false;

if (m_PlayerPurchasableItems[buyer->GetObjectID()].contains(lot)){

Check failure on line 16 in dGame/dComponents/AchievementVendorComponent.cpp

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-22.04)

passing ‘const std::map<long int, std::set<int> >’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 16 in dGame/dComponents/AchievementVendorComponent.cpp

View workflow job for this annotation

GitHub Actions / Build & Test (macos-13)

no viable overloaded operator[] for type 'const std::map<LWOOBJID, std::set<LOT>>' (aka 'const map<long long, set<int>>')
return true;
}

CDMissionsTable* missionsTable = CDClientManager::GetTable<CDMissionsTable>();
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);

Check failure on line 24 in dGame/dComponents/AchievementVendorComponent.cpp

View workflow job for this annotation

GitHub Actions / Build & Test (ubuntu-22.04)

passing ‘const std::map<long int, std::set<int> >’ as ‘this’ argument discards qualifiers [-fpermissive]

Check failure on line 24 in dGame/dComponents/AchievementVendorComponent.cpp

View workflow job for this annotation

GitHub Actions / Build & Test (macos-13)

no viable overloaded operator[] for type 'const std::map<LWOOBJID, std::set<LOT>>' (aka 'const map<long long, set<int>>')
return true;
}
}
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/AchievementVendorComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AchievementVendorComponent final : public VendorComponent {
void Buy(Entity* buyer, LOT lot, uint32_t count);

private:

std::map<LWOOBJID,std::set<LOT>> m_PlayerPurchasableItems;
};


Expand Down

0 comments on commit c4d1a09

Please sign in to comment.