diff --git a/Source/Contents/AdventureGuideMgr.cpp b/Source/Contents/AdventureGuideMgr.cpp index 49ea9a8f..8a2b8b96 100644 --- a/Source/Contents/AdventureGuideMgr.cpp +++ b/Source/Contents/AdventureGuideMgr.cpp @@ -1225,11 +1225,11 @@ void CAdventureGuideMgr::GetContentsList(std::listbegin(), (*contents)->end(), std::back_inserter(out), + [](const std::pair& entry) { + return entry.second.unknown_0004 <= g_session.m_level && g_session.m_level <= entry.second.unknown_0008; + }); + out.sort([](const std::pair& lhs, const std::pair& rhs) { return lhs.second.unknown_0004 < rhs.second.unknown_0004; }); @@ -1569,8 +1569,8 @@ bool CAdventureGuideMgr::Load() { // OFFSET: 0x00667200 // FUNCTION: fn_05256 -bool CAdventureGuideMgr::IsAvailable(int type, int id) const { - const std::map>* contents = nullptr; +bool CAdventureGuideMgr::IsAvailable(int type, int id) { + std::map>* contents = nullptr; switch (type) { case 1: contents = &this->unknown_003C; @@ -1583,12 +1583,12 @@ bool CAdventureGuideMgr::IsAvailable(int type, int id) const { break; case 5: case 6: { - const auto& entries = type == 5 ? this->unknown_0054 : this->unknown_005C; - const auto found = entries.find(id); - if (found == entries.end()) { + auto& entries = type == 5 ? this->unknown_0054 : this->unknown_005C; + const std::optional*> found = FindMapped(entries, id); + if (!found) { return true; } - for (const auto& entry : found->second) { + for (const auto& entry : **found) { if (entry.second.IsAvailable(entry.first)) { return true; } @@ -1599,11 +1599,11 @@ bool CAdventureGuideMgr::IsAvailable(int type, int id) const { return true; } - const auto found = contents->find(id); - if (found == contents->end()) { + const std::optional*> found = FindMapped(*contents, id); + if (!found) { return true; } - for (const auto& entry : found->second) { + for (const auto& entry : **found) { if (entry.second.unknown_0004 <= g_session.m_level && g_session.m_level <= entry.second.unknown_0008) { return true; } diff --git a/Source/Contents/AdventureGuideMgr.h b/Source/Contents/AdventureGuideMgr.h index f680ce44..0671a3d8 100644 --- a/Source/Contents/AdventureGuideMgr.h +++ b/Source/Contents/AdventureGuideMgr.h @@ -101,7 +101,7 @@ public: CAdventureGuideMgr(); virtual ~CAdventureGuideMgr(); - bool IsAvailable(int type, int id) const; + bool IsAvailable(int type, int id); void Init(); bool Load(); void GetEpisodeList(std::list& out);