diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 882c98e..5f84112 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -58,7 +58,9 @@ public: /* 1058 */ int m_petActionTable[5][5][7]; /* 1314 */ unsigned char unknown_1314[0x314]; /* 1628 */ int m_job; - /* 162C */ unsigned char unknown_162C[0xE4]; + /* 162C */ unsigned char unknown_162C[0x24]; + /* 1650 */ int m_level; + /* 1654 */ unsigned char unknown_1654[0xBC]; /* 1710 */ std::list m_inventoryItems; /* 1718 */ unsigned char unknown_1718[0x1438]; /* 2B50 */ ItemInfo unknown_2B50[10]; @@ -130,6 +132,7 @@ static_assert(sizeof(SessionRecord6144) == 0x38); static_assert(offsetof(SessionRecord6144, unknown_002C) == 0x2C); static_assert(offsetof(SessionRecord6144, unknown_0030) == 0x30); static_assert(offsetof(CSession, m_additionalSkills) == 0x4); +static_assert(offsetof(CSession, m_level) == 0x1650); static_assert(offsetof(CSession, m_skillBundle) == 0xC); static_assert(offsetof(CSession, m_homunSkills) == 0x84); static_assert(offsetof(CSession, m_mercSkills) == 0x8C); diff --git a/Source/Contents/AdventureGuideMgr.cpp b/Source/Contents/AdventureGuideMgr.cpp index 59295be..8563b95 100644 --- a/Source/Contents/AdventureGuideMgr.cpp +++ b/Source/Contents/AdventureGuideMgr.cpp @@ -1,8 +1,23 @@ #include "Contents/AdventureGuideMgr.h" +#include "Client/Session.h" + +#include +#include +#include + // GLOBAL: gl_24502 CAdventureGuideMgr* g_adventureGuideMgr; +template +static std::optional FindMapped(Map& map, const typename Map::key_type& key) { + auto it = map.find(key); + if (it == map.end()) { + return std::nullopt; + } + return &it->second; +} + // OFFSET: 0x00660F70 // FUNCTION: fn_05222 CAdventureGuideMgr::CAdventureGuideMgr() : m_initialized(true) { @@ -21,3 +36,49 @@ void CAdventureGuideMgr::Destroy() { g_adventureGuideMgr = nullptr; } } + +// OFFSET: 0x00663890 +// FUNCTION: fn_05237 +void CAdventureGuideMgr::GetEpisodeList(std::list& out) { + out.clear(); + + for (const AdventureGuideEpisode& episode : m_episodes) { + if (episode.order <= g_session.m_level && g_session.m_level <= episode.unknown_001C) { + out.push_back(episode); + } + } +} + +// OFFSET: 0x006639D0 +// FUNCTION: fn_05238 +void CAdventureGuideMgr::GetContentsList(std::list>& out, int type, int id) { + out.clear(); + + std::map>* table; + switch (type) { + case 1: + table = &unknown_003C; + break; + case 3: + table = &unknown_0044; + break; + case 4: + table = &unknown_004C; + break; + default: + return; + } + + std::optional*> contents = FindMapped(*table, id); + if (!contents) { + return; + } + + std::copy_if((*contents)->begin(), (*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; + }); +} diff --git a/Source/Contents/AdventureGuideMgr.h b/Source/Contents/AdventureGuideMgr.h index aa20a75..cb4a639 100644 --- a/Source/Contents/AdventureGuideMgr.h +++ b/Source/Contents/AdventureGuideMgr.h @@ -8,6 +8,7 @@ #include #include #include +#include #include struct AdventureGuideDetail { @@ -75,6 +76,9 @@ public: CAdventureGuideMgr(); virtual ~CAdventureGuideMgr(); + + void GetEpisodeList(std::list& out); + void GetContentsList(std::list>& out, int type, int id); }; extern CAdventureGuideMgr* g_adventureGuideMgr;