diff --git a/Source/Client/Session.h b/Source/Client/Session.h index a58fe20..ffb4e9e 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -1,14 +1,47 @@ #ifndef RAGNAROK_SOURCE_CLIENT_SESSION_H #define RAGNAROK_SOURCE_CLIENT_SESSION_H +#include "Contents/Items/ItemInfo.h" +#include "Contents/Skills/PlayerSkillBundle.h" +#include "Contents/UserData/NormalItemSlots.h" + #include #include +#include +#include +#include +#include +#include class LuaScript; +struct SessionRecord6144 { + /* 0000 */ std::uint16_t unknown_0000 = 0; + /* 0004 */ std::uint32_t unknown_0004[10] = {}; + /* 002C */ std::uint32_t unknown_002C = 0; + /* 0030 */ std::uint8_t unknown_0030 = 0; + /* 0031 */ std::uint8_t unknown_0031[7]; +}; + class CSession { public: - /* 0000 */ unsigned char unknown_0000[0xF18]; + /* 0000 */ std::uint32_t unknown_0000; + /* 0004 */ std::list m_additionalSkills; + /* 000C */ CPlayerSkillBundle m_skillBundle; + /* 0084 */ std::list m_homunSkills; + /* 008C */ std::list m_mercSkills; + /* 0094 */ unsigned char unknown_0094[0x38C]; + /* 0420 */ std::uint32_t unknown_0420[36]; + /* 04B0 */ NormalItemSlot m_shortcutSlots[36]; + /* 05AC */ NormalItemSlot m_secondaryShortcutSlots[36]; + /* 06A8 */ unsigned char unknown_06A8[0x43]; + /* 06EB */ NormalItemSlot unknown_06EB; + /* 06F2 */ NormalItemSlot unknown_06F2; + /* 06F9 */ unsigned char unknown_06F9[0x7F]; + /* 0778 */ std::vector> unknown_0778; + /* 0784 */ std::map unknown_0784; + /* 078C */ std::map unknown_078C; + /* 0794 */ unsigned char unknown_0794[0x784]; /* 0F18 */ int m_playerX; /* 0F1C */ int m_playerY; /* 0F20 */ unsigned char unknown_0F20[0x08]; @@ -19,17 +52,68 @@ public: /* 0FAC */ const char* const* m_jobNamesEnd; /* 0FB0 */ unsigned char unknown_0FB0[0x678]; /* 1628 */ int m_job; - /* 162C */ unsigned char unknown_162C[0x43AC]; + /* 162C */ unsigned char unknown_162C[0x1524]; + /* 2B50 */ ItemInfo unknown_2B50[10]; + /* 3500 */ ItemInfo unknown_3500[10]; + /* 3EB0 */ unsigned char unknown_3EB0[0x1B28]; /* 59D8 */ LuaScript* m_hotkeyScript; - /* 59DC */ unsigned char unknown_59DC[0x275C]; + /* 59DC */ unsigned char unknown_59DC[0x28C]; + /* 5C68 */ ItemInfo unknown_5C68[5]; + /* 6140 */ std::uint16_t unknown_6140; + /* 6144 */ std::map unknown_6144; + /* 614C */ unsigned char unknown_614C[0x20]; + /* 616C */ std::vector unknown_616C; + /* 6178 */ unsigned char unknown_6178[0x1FC0]; /* 8138 */ std::int64_t m_startTimeTicks; /* 8140 */ std::int64_t m_loginTimeTicks; /* 8148 */ int unknown_8148; + + bool UpdateHomunSkill(const CSkillInfo& value, unsigned char notify); + bool UpdateMercSkill(const CSkillInfo& value, unsigned char notify); + void AddUnknownId(int id); + void AddStackedItem(ItemInfo item); + void AddItemToFreeSlot(ItemInfo item); + bool IsListedId(int id, int variant) const; + void ClearItemQuantities(); + void ResetItems3500(); + void ClearSlots06EB(); + void ClearShortcutSlots(); + void ClearSecondaryShortcutSlots(); + void ClearUnknown0420(); + void EraseUnknownKey(std::int64_t key); + std::int64_t FindUnknown0784(std::int64_t key) const; + std::int64_t FindUnknown078C(std::int64_t key) const; + SessionRecord6144 FindRecord6144(int key) const; + int GetBeginEffectId(int skillId) const; + ItemInfo GetItem2B50(int index) const; + int CountItems5C68() const; + void SplitDate(__time32_t time, std::uint16_t& year, std::uint16_t& month, std::uint16_t& day) const; + int GetDefaultOptionValue(const char* name, int fallback) const; + int FindUnknown0778(int key) const; + CSkillInfo AdditionalSkillAt(int index) const; + CSkillInfo HomunSkillAt(int index) const; + void NotifyHomunSkillWindows(); + void NotifyMercSkillWindows(); }; extern CSession g_session; #if defined(_WIN32) && !defined(_WIN64) +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_skillBundle) == 0xC); +static_assert(offsetof(CSession, m_homunSkills) == 0x84); +static_assert(offsetof(CSession, m_mercSkills) == 0x8C); +static_assert(offsetof(CSession, unknown_0420) == 0x420); +static_assert(offsetof(CSession, m_shortcutSlots) == 0x4B0); +static_assert(offsetof(CSession, m_secondaryShortcutSlots) == 0x5AC); +static_assert(offsetof(CSession, unknown_06EB) == 0x6EB); +static_assert(offsetof(CSession, unknown_06F2) == 0x6F2); +static_assert(offsetof(CSession, unknown_0778) == 0x778); +static_assert(offsetof(CSession, unknown_0784) == 0x784); +static_assert(offsetof(CSession, unknown_078C) == 0x78C); static_assert(offsetof(CSession, m_playerX) == 0xF18); static_assert(offsetof(CSession, m_playerY) == 0xF1C); static_assert(offsetof(CSession, m_score1) == 0xF28); @@ -37,7 +121,13 @@ static_assert(offsetof(CSession, m_score2) == 0xF2C); static_assert(offsetof(CSession, m_jobNamesBegin) == 0xFA8); static_assert(offsetof(CSession, m_jobNamesEnd) == 0xFAC); static_assert(offsetof(CSession, m_job) == 0x1628); +static_assert(offsetof(CSession, unknown_2B50) == 0x2B50); +static_assert(offsetof(CSession, unknown_3500) == 0x3500); static_assert(offsetof(CSession, m_hotkeyScript) == 0x59D8); +static_assert(offsetof(CSession, unknown_5C68) == 0x5C68); +static_assert(offsetof(CSession, unknown_6140) == 0x6140); +static_assert(offsetof(CSession, unknown_6144) == 0x6144); +static_assert(offsetof(CSession, unknown_616C) == 0x616C); static_assert(offsetof(CSession, m_startTimeTicks) == 0x8138); static_assert(offsetof(CSession, m_loginTimeTicks) == 0x8140); #endif diff --git a/Source/Contents/Skills/ClientSkills.cpp b/Source/Contents/Skills/ClientSkills.cpp index 6b50177..5fd6489 100644 --- a/Source/Contents/Skills/ClientSkills.cpp +++ b/Source/Contents/Skills/ClientSkills.cpp @@ -1,8 +1,11 @@ #include "Contents/Skills/ClientSkills.h" +#include "Client/Session.h" #include "Script/LuaScript.h" #include "UI/Window/UIWindow.h" +#include "UI/Window/UIWindowMgr.h" #include "UI/Window/WindowManagerWindows.h" +#include #include namespace { @@ -193,8 +196,6 @@ bool ClientSkills::Update( return true; } -// OFFSET: 0x00E251C0 -// OFFSET: 0x00E25200 void CompanionSkills::Notify() { if (this->window) { this->window->SendMsg(nullptr, 23, 0, 0, 0, 0); @@ -205,8 +206,6 @@ void CompanionSkills::Notify() { } } -// OFFSET: 0x00E072F0 -// OFFSET: 0x00E07380 bool CompanionSkills::Update(const CSkillInfo& value, unsigned char notify) { for (CSkillInfo& skill : this->skills) { if (skill.id == value.id) { @@ -251,3 +250,107 @@ bool ClientSkills::UpdateAdditional(const CSkillInfo& value, int) { this->additional.push_back(value); return true; } + +// OFFSET: 0x00E072F0 + +// OFFSET: 0x00E07380 + +// OFFSET: 0x00E07410 + +// OFFSET: 0x00E07930 + +// OFFSET: 0x00E07A10 + +// OFFSET: 0x00E081E0 + +// OFFSET: 0x00E08290 +// FUNCTION: fn_23754 +void CSession::ClearItemQuantities() { + for (int index = 0; index < 5; ++index) { + this->unknown_5C68[index].quantity = 0; + } + + this->unknown_6140 = 0; +} + +// OFFSET: 0x00E082D0 +// FUNCTION: fn_23755 +void CSession::ResetItems3500() { + for (int index = 0; index < 10; ++index) { + this->unknown_3500[index].Reset(); + } +} + +// OFFSET: 0x00E08300 +// FUNCTION: fn_23756 +void CSession::ClearSlots06EB() { + this->unknown_06EB.unknown_0000 = 0; + this->unknown_06EB.itemId = 0; + this->unknown_06EB.unknown_0005 = 0; + this->unknown_06F2.unknown_0000 = 0; + this->unknown_06F2.itemId = 0; + this->unknown_06F2.unknown_0005 = 0; +} + +// OFFSET: 0x00E08330 +// FUNCTION: fn_23757 +void CSession::ClearShortcutSlots() { + for (int index = 0; index < 36; ++index) { + this->m_shortcutSlots[index].unknown_0000 = 0; + this->m_shortcutSlots[index].itemId = 0; + this->m_shortcutSlots[index].unknown_0005 = 0; + } +} + +// OFFSET: 0x00E08360 +// FUNCTION: fn_23758 +void CSession::ClearSecondaryShortcutSlots() { + std::memset(this->m_secondaryShortcutSlots, 0, sizeof(this->m_secondaryShortcutSlots)); +} + +// OFFSET: 0x00E08380 +// FUNCTION: fn_23759 +void CSession::ClearUnknown0420() { + for (int index = 0; index < 36; ++index) { + this->unknown_0420[index] = 0; + } +} + +// OFFSET: 0x00E083D0 + +// OFFSET: 0x00E08690 + +// OFFSET: 0x00E086F0 + +// OFFSET: 0x00E08750 + +// OFFSET: 0x00E08A00 + +// OFFSET: 0x00E08EE0 + +// OFFSET: 0x00E08F70 +// FUNCTION: fn_23774 +int CSession::CountItems5C68() const { + int count = 0; + for (int index = 0; index < 5; ++index) { + if (this->unknown_5C68[index].quantity != 0) { + ++count; + } + } + + return count; +} + +// OFFSET: 0x00E09080 + +// OFFSET: 0x00E091F0 + +// OFFSET: 0x00E094B0 + +// OFFSET: 0x00E09510 + +// OFFSET: 0x00E09650 + +// OFFSET: 0x00E251C0 + +// OFFSET: 0x00E25200