diff --git a/Source/Client/Application/Launcher.cpp b/Source/Client/Application/Launcher.cpp index 8bc70094..e40f0889 100644 --- a/Source/Client/Application/Launcher.cpp +++ b/Source/Client/Application/Launcher.cpp @@ -1039,9 +1039,6 @@ int sub_E58100(HINSTANCE instance, int showCommand) { return 1; } -struct SessionMessengerContext { - void sub_DD9D50(); -}; // INLINED template @@ -1685,7 +1682,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE previous, LPSTR commandLine, in } } - reinterpret_cast(&g_session)->sub_DD9D50(); + g_session.sub_DD9D50(); ResourceMgr& resources = ResourceMgr::Instance(); const std::uint8_t resourceNamesSource[] = {0x8F, 0xA4, 0x00, 0x0D, 0x46, 0x3C, 0x78, 0x4B, 0x9C, 0xA3, 0x1F, 0x26, 0x09, 0x25, 0x65, 0x6B, diff --git a/Source/Client/Mode/GameMode.cpp b/Source/Client/Mode/GameMode.cpp index b8960584..c9a1c73d 100644 --- a/Source/Client/Mode/GameMode.cpp +++ b/Source/Client/Mode/GameMode.cpp @@ -3216,13 +3216,7 @@ void CGameMode::PlayItemUseEffect(int itemId, std::uint32_t aid) { #include #include -struct SessionMessengerContext { - void UpdateRandomStats(); -}; -struct SessionItemLists { - void ClearTradeItems(); -}; // GLOBAL: gl_24776 int g_visibleMinX; @@ -3409,9 +3403,9 @@ void CGameMode::InitializeState() { } reinterpret_cast(&g_session)->ResetUnknown166C(); - reinterpret_cast(&g_session)->UpdateRandomStats(); + g_session.UpdateRandomStats(); reinterpret_cast(&g_session)->ClearItems1738(); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); reinterpret_cast(&g_session)->ClearItems1768(); reinterpret_cast(&g_session)->ClearItems1758(); reinterpret_cast(&g_session)->ClearItems1750(); diff --git a/Source/Client/Mode/GameModeHandlers.cpp b/Source/Client/Mode/GameModeHandlers.cpp index 253af6b9..5e88f20f 100644 --- a/Source/Client/Mode/GameModeHandlers.cpp +++ b/Source/Client/Mode/GameModeHandlers.cpp @@ -362,9 +362,6 @@ struct GroundSkillArgumentData { static_assert(sizeof(GroundSkillExtendedData) == 0x20); static_assert(sizeof(GroundSkillArgumentData) == 0x24); -struct SessionItemLists { - void ClearTradeItems(); -}; // OFFSET: 0x00D66230 // FUNCTION: fn_22010 @@ -673,7 +670,7 @@ void CGameMode::ReceivePendingResult(const unsigned char* packet) { // OFFSET: 0x00D3C1C0 // FUNCTION: fn_21792 void CGameMode::ReceiveItem1718BasicList(const unsigned char* packet) { - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); const std::int64_t count = (static_cast(*reinterpret_cast(packet + 2)) - 4) / 19; const Item1718BasicRecord* records = reinterpret_cast(packet + 4); @@ -758,7 +755,7 @@ void CGameMode::ReceiveItem1718Result(const unsigned char* packet) { // OFFSET: 0x00D3C710 // FUNCTION: fn_21794 void CGameMode::ReceiveItem1718IndexList(const unsigned char* packet) { - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); const int count = (*reinterpret_cast(packet + 2) - 4) / sizeof(Item1718IndexRecord); const Item1718IndexRecord* records = reinterpret_cast(packet + 4); @@ -2908,7 +2905,7 @@ void CGameMode::ReceivePendingItem1718List(const unsigned char* packet) { return; } - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); if (g_hangameLogin == 1) { g_windowMgr.SendNotice(3, 0, 0, 0, 0, 0); g_windowMgr.SendNotice(1, reinterpret_cast("한게임 유저는 12월 3일부로 유료아이템 구매가 불가능합니다."), 0xFF, 0, 0, 0); diff --git a/Source/Client/Mode/GameModeItemLists.cpp b/Source/Client/Mode/GameModeItemLists.cpp index 4970b74b..50d3f7fc 100644 --- a/Source/Client/Mode/GameModeItemLists.cpp +++ b/Source/Client/Mode/GameModeItemLists.cpp @@ -30,9 +30,6 @@ struct ClientItemLists { void ClearItems1740(); }; -struct SessionMessengerContext { - void ResetEquipment(); -}; namespace { #pragma pack(push, 1) @@ -183,7 +180,7 @@ void CGameMode::ReceiveInventoryStart(const unsigned char* packet) { switch (g_gameModePacketBuffer[4]) { case 0: reinterpret_cast(&g_session)->ClearInventory(); - reinterpret_cast(&g_session)->ResetEquipment(); + g_session.ResetEquipment(); g_session.ResetItems2B50(); break; case 1: diff --git a/Source/Client/Mode/GameModeNotices.cpp b/Source/Client/Mode/GameModeNotices.cpp index 89866143..4c1aa04e 100644 --- a/Source/Client/Mode/GameModeNotices.cpp +++ b/Source/Client/Mode/GameModeNotices.cpp @@ -2862,10 +2862,6 @@ struct LongParChangePacket { }; #pragma pack(pop) -struct SessionMessengerContext { - void ResetSlots(); - int GetList0Size() const; -}; // OFFSET: 0x00D195D0 // FUNCTION: fn_21606 @@ -2951,16 +2947,13 @@ struct TradeItemFilterPacket { }; #pragma pack(pop) -struct SessionItemLists { - void ClearTradeItems(); -}; // OFFSET: 0x00D198F0 // FUNCTION: fn_21612 void CGameMode::ReceiveTradeItemFilter(const unsigned char* data) { const auto* packet = reinterpret_cast(data); - reinterpret_cast(&g_session)->ClearTradeItems(); - const int count = reinterpret_cast(&g_session)->GetList0Size(); + g_session.ClearTradeItems(); + const int count = g_session.GetList0Size(); for (int i = 0; i < count; ++i) { ITEM_INFO item = g_session.GetInventoryItemAt(i); if (item.unknown_0000[1] == 0) { @@ -3034,7 +3027,7 @@ void CGameMode::ReceiveExchangeRequestAck2(const unsigned char* data) { case 3: { this->SendMsg(40, 0, 0, 0, 0); *reinterpret_cast(&this->unknown_0100[0x14]) = 1; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); reinterpret_cast(&g_session)->ClearItemSlotQuantities(); g_windowMgr.CloseWindow(10011); UIWindow* window = g_windowMgr.EnsureWindow(10011); @@ -3076,7 +3069,7 @@ void CGameMode::ReceiveExchangeRequestAck(const unsigned char* data) { case 3: { this->SendMsg(40, 0, 0, 0, 0); *reinterpret_cast(&this->unknown_0100[0x14]) = 1; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); reinterpret_cast(&g_session)->ClearItemSlotQuantities(); g_windowMgr.CloseWindow(10011); UIWindow* window = g_windowMgr.EnsureWindow(10011); @@ -3567,7 +3560,7 @@ void CGameMode::ReceiveLongParChange(const unsigned char* data) { case 20: if (*reinterpret_cast(&this->unknown_0100[0x14])) { *reinterpret_cast(&this->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.m_zeny = static_cast(packet->value); g_session.RefreshHpSpWindows(); diff --git a/Source/Client/Mode/GameModePackets.cpp b/Source/Client/Mode/GameModePackets.cpp index add9717a..42eb789f 100644 --- a/Source/Client/Mode/GameModePackets.cpp +++ b/Source/Client/Mode/GameModePackets.cpp @@ -109,18 +109,7 @@ void CGameMode::ReceiveItemDisappear(std::uint32_t itemAid) { } } -struct SessionMessengerContext { - void UpdateRandomStats(); - int GetList9Size() const; - void KeepEquipment(); - void ResetEquipment(); - void ResetSlots(); -}; -struct SessionItemLists { - void ClearTradeItems(); - void RemoveEquipment(); -}; #pragma pack(push, 1) struct TradeItemRecord { @@ -1281,7 +1270,7 @@ void CGameMode::ReceiveHpSpRecovery(const unsigned char* packet, int variant) { switch (type) { case 5: { - reinterpret_cast(&g_session)->UpdateRandomStats(); + g_session.UpdateRandomStats(); const int hp = g_session.unknown_5568 + amount; if (g_session.unknown_5568 != hp) { g_session.unknown_5568 = hp; @@ -1292,7 +1281,7 @@ void CGameMode::ReceiveHpSpRecovery(const unsigned char* packet, int variant) { break; } case 7: { - reinterpret_cast(&g_session)->UpdateRandomStats(); + g_session.UpdateRandomStats(); int& sp = *reinterpret_cast(&g_session.unknown_5570[0]); const int value = sp + amount; if (sp != value) { @@ -1905,7 +1894,7 @@ void __stdcall sub_D08110(int field8, int itemIdWord, int quantityWord, int fiel if (g_vendingOpenWindow != nullptr) { g_vendingOpenWindow->SendMsg(nullptr, 0x17, 0, 0, 0, 0); } - if (reinterpret_cast(&g_session)->GetList9Size() == 0) { + if (g_session.GetList9Size() == 0) { g_windowMgr.SendNotice(1, reinterpret_cast(LookupMessage(0x137)), 0xFF00, 0, 0, 0); if (g_vendingOpenResultWindow != nullptr) { g_vendingOpenResultWindow->SendMsg(nullptr, 0x17, 0, 0, 0, 0); @@ -1938,7 +1927,7 @@ void __declspec(noinline) __stdcall sub_D08670(int field14, int itemId, int quan if (g_vendingSaleAlarm) { g_soundMgr->PlayWave("effect\\ef_steal.wav", 0.0f, 0.0f, 0.0f, 250, 40, 1.0f, 0); } - if (reinterpret_cast(&g_session)->GetList9Size() == 0) { + if (g_session.GetList9Size() == 0) { g_saleResultWindow->SendMsg(nullptr, 6, 0xC9, 0, 0, 0); } } @@ -2011,7 +2000,7 @@ void CGameMode::ReceiveItem1740BasicListBind(const unsigned char* data) { // OFFSET: 0x00D2D770 // FUNCTION: fn_21720 void CGameMode::ReceiveItemInventoryList(const unsigned char* data) { - reinterpret_cast(&g_session)->KeepEquipment(); + g_session.KeepEquipment(); const PacketLengthHeader* packet = reinterpret_cast(data); const int count = (packet->length - sizeof(PacketLengthHeader)) / sizeof(StoreNormalRecord); @@ -3619,7 +3608,7 @@ void CGameMode::ReceiveActorStatusValue(std::uint32_t aid, int status, int amoun switch (status) { case 0x14b: if (aid == g_session.m_aid) { - reinterpret_cast(&g_session)->UpdateRandomStats(); + g_session.UpdateRandomStats(); const int hp = g_session.unknown_5568 + amount; if (g_session.unknown_5568 != hp) { g_session.unknown_5568 = hp; @@ -3630,7 +3619,7 @@ void CGameMode::ReceiveActorStatusValue(std::uint32_t aid, int status, int amoun break; case 0x14c: if (aid == g_session.m_aid) { - reinterpret_cast(&g_session)->UpdateRandomStats(); + g_session.UpdateRandomStats(); int& sp = *reinterpret_cast(&g_session.unknown_5570[0]); const int value = sp + amount; if (sp != value) { @@ -3678,7 +3667,7 @@ void CGameMode::ReceiveActorStatusValue(std::uint32_t aid, int status, int amoun // OFFSET: 0x00D39BB0 // FUNCTION: fn_21773 void CGameMode::ReceiveItem1718List(const unsigned char* packet) { - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); const std::int64_t count = (static_cast(*reinterpret_cast(packet + 2)) - 4) / 19; const Item1718Record* record = reinterpret_cast(packet + 4); @@ -3713,7 +3702,7 @@ void CGameMode::ReceiveItem1718List(const unsigned char* packet) { // OFFSET: 0x00D77C90 // FUNCTION: fn_22154 void ReceiveTradeItems(int count, const TradeItemRecord* records) { - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); for (int i = 0; i < count; ++i) { const TradeItemRecord& record = records[i]; @@ -6851,7 +6840,7 @@ void CGameMode::ReceiveItemConsumed(const unsigned char* packet) { if (*reinterpret_cast(&this->unknown_0100[0x14])) { *reinterpret_cast(&this->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } reinterpret_cast(&g_session)->RemoveItem1710( @@ -8075,8 +8064,8 @@ namespace { // OFFSET: 0x00D2C7F0 // FUNCTION: fn_21717 void CGameMode::ReceiveInventoryEquipList(const unsigned char* packet) { - reinterpret_cast(&g_session)->RemoveEquipment(); - reinterpret_cast(&g_session)->ResetEquipment(); + g_session.RemoveEquipment(); + g_session.ResetEquipment(); g_session.ResetItems2B50(); const int length = *reinterpret_cast(packet + 2); @@ -8113,8 +8102,8 @@ void CGameMode::ReceiveInventoryEquipList(const unsigned char* packet) { // OFFSET: 0x00D2CC80 // FUNCTION: fn_21718 void CGameMode::ReceiveInventoryEquipList2(const unsigned char* packet) { - reinterpret_cast(&g_session)->RemoveEquipment(); - reinterpret_cast(&g_session)->ResetEquipment(); + g_session.RemoveEquipment(); + g_session.ResetEquipment(); g_session.ResetItems2B50(); const int length = *reinterpret_cast(packet + 2); @@ -8134,8 +8123,8 @@ void CGameMode::ReceiveInventoryEquipList2(const unsigned char* packet) { // OFFSET: 0x00D2D140 // FUNCTION: fn_21719 void CGameMode::ReceiveInventoryEquipList3(const unsigned char* packet) { - reinterpret_cast(&g_session)->RemoveEquipment(); - reinterpret_cast(&g_session)->ResetEquipment(); + g_session.RemoveEquipment(); + g_session.ResetEquipment(); g_session.ResetItems2B50(); const int length = *reinterpret_cast(packet + 2); @@ -8310,7 +8299,7 @@ void CGameMode::ReceiveItemPickupAck2(const unsigned char* data) { window->SendMsg(nullptr, 0x22, reinterpret_cast(&item), 0, 0, 0); if (*reinterpret_cast(&this->unknown_0100[0x14]) != 0) { *reinterpret_cast(&this->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.UpdateInventoryItem(item, 1); } else { @@ -8407,7 +8396,7 @@ void CGameMode::ReceiveItemPickupAck3(const unsigned char* data) { window->SendMsg(nullptr, 0x22, reinterpret_cast(&item), 0, 0, 0); if (*reinterpret_cast(&this->unknown_0100[0x14]) != 0) { *reinterpret_cast(&this->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.UpdateInventoryItem(item, 1); if (UIWindow* quest = g_windowMgr.LookupWindow(0x133)) { @@ -8504,7 +8493,7 @@ void CGameMode::ReceiveItemPickupAck(const unsigned char* data) { window->SendMsg(nullptr, 0x22, reinterpret_cast(&item), 0, 0, 0); if (*reinterpret_cast(&this->unknown_0100[0x14]) != 0) { *reinterpret_cast(&this->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.UpdateInventoryItem(item, 1); } else { @@ -8617,7 +8606,7 @@ void CGameMode::ReceiveItemPickupAck5( window->SendMsg(nullptr, 0x22, reinterpret_cast(&item), 0, 0, 0); if (*reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) != 0) { *reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.UpdateInventoryItem(item, 1); if (UIWindow* quest = g_windowMgr.LookupWindow(0x133)) { @@ -8730,7 +8719,7 @@ void CGameMode::ReceiveItemPickupAck7(const unsigned char* data) { window->SendMsg(nullptr, 0x22, reinterpret_cast(&item), 0, 0, 0); if (*reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) != 0) { *reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.UpdateInventoryItem(item, 1); if (UIWindow* quest = g_windowMgr.LookupWindow(0x133)) { @@ -9803,7 +9792,7 @@ void CGameMode::ReceiveItemPickupAck8(const unsigned char* data) { window->SendMsg(nullptr, 0x22, reinterpret_cast(&item), 0, 0, 0); if (*reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) != 0) { *reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.UpdateInventoryItem(item, 1); if (UIWindow* quest = g_windowMgr.LookupWindow(0x133)) { @@ -9933,7 +9922,7 @@ void CGameMode::ReceiveItemPickupAck9(const unsigned char* data) { window->SendMsg(nullptr, 0x22, reinterpret_cast(&item), 0, 0, 0); if (*reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) != 0) { *reinterpret_cast(&static_cast(g_modeMgr.GetGameMode())->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.UpdateInventoryItem(item, 1); if (UIWindow* quest = g_windowMgr.LookupWindow(0x133)) { @@ -11461,7 +11450,7 @@ void CGameMode::ReceiveExpChange(const unsigned char* packet) { case 20: if (*reinterpret_cast(&this->unknown_0100[0x14])) { *reinterpret_cast(&this->unknown_0100[0x14]) = 0; - reinterpret_cast(&g_session)->ResetSlots(); + g_session.ResetSlots(); } g_session.m_zeny = *reinterpret_cast(packet + 4); g_session.RefreshHpSpWindows(); @@ -11548,8 +11537,8 @@ void CGameMode::ReceiveParaResultList(const unsigned char* packet) { // OFFSET: 0x00D2C5D0 // FUNCTION: fn_21716 void CGameMode::ReceiveEquipItemListFlags(const unsigned char* packet) { - reinterpret_cast(&g_session)->RemoveEquipment(); - reinterpret_cast(&g_session)->ResetEquipment(); + g_session.RemoveEquipment(); + g_session.ResetEquipment(); g_session.ResetItems2B50(); const int count = static_cast(*reinterpret_cast(packet + 2) - 4) / 0x25; const unsigned char* record = packet + 4; @@ -11594,8 +11583,8 @@ void CGameMode::ReceiveEquipItemListFlags(const unsigned char* packet) { // OFFSET: 0x00D27EC0 // FUNCTION: fn_21692 void CGameMode::ReceiveEquipItemList34(const unsigned char* packet) { - reinterpret_cast(&g_session)->RemoveEquipment(); - reinterpret_cast(&g_session)->ResetEquipment(); + g_session.RemoveEquipment(); + g_session.ResetEquipment(); const int count = static_cast(*reinterpret_cast(packet + 2) - 4) / 0x22; const unsigned char* record = packet + 4; for (int i = 0; i < count; ++i) { @@ -11633,8 +11622,8 @@ void CGameMode::ReceiveEquipItemList34(const unsigned char* packet) { // OFFSET: 0x00D280B0 // FUNCTION: fn_21693 void CGameMode::ReceiveEquipItemList38(const unsigned char* packet) { - reinterpret_cast(&g_session)->RemoveEquipment(); - reinterpret_cast(&g_session)->ResetEquipment(); + g_session.RemoveEquipment(); + g_session.ResetEquipment(); g_session.ResetItems2B50(); const int count = static_cast(*reinterpret_cast(packet + 2) - 4) / 0x26; const unsigned char* record = packet + 4; diff --git a/Source/Client/Mode/LoginMode.cpp b/Source/Client/Mode/LoginMode.cpp index 817bdf8b..a3b834a1 100644 --- a/Source/Client/Mode/LoginMode.cpp +++ b/Source/Client/Mode/LoginMode.cpp @@ -1818,9 +1818,6 @@ void CLoginMode::SubD911C0(const PasswordModePacket* packet) { } } -struct SessionItemLists { - void ClearItems1780(); -}; // OFFSET: 0x00D97410 // FUNCTION: fn_22300 @@ -1852,7 +1849,7 @@ void CLoginMode::Initialize(const char* name) { g_soundMgr->PlayStream("bgm\\01.mp3", 0, false); } this->slotExtension = CharacterSlotExtension(); - reinterpret_cast(&g_session)->ClearItems1780(); + g_session.ClearItems1784(); g_entryQueueMgr->ready = 0; g_entryQueueMgr->current = nullptr; g_session.ClearShortcutSlots(); diff --git a/Source/Client/Session.cpp b/Source/Client/Session.cpp index 74d33235..480f032a 100644 --- a/Source/Client/Session.cpp +++ b/Source/Client/Session.cpp @@ -91,9 +91,6 @@ public: // GLOBAL: gl_25445 int g_sessionTableLoadCount; -struct SessionMessengerContext { - void sub_DF33B0(); -}; namespace EquipmentProperties { class CEquipmentPropertiesMgr { @@ -7026,8 +7023,8 @@ void CSession::ReloadLanguageTables() { // OFFSET: 0x00DF33B0 // FUNCTION: fn_23506 -void SessionMessengerContext::sub_DF33B0() { - CSession* session = reinterpret_cast(this); +void CSession::sub_DF33B0() { + CSession* session = this; ++g_sessionTableLoadCount; session->InitJobHitWaveNames(); diff --git a/Source/Client/Session.h b/Source/Client/Session.h index 42e4db65..c332f534 100644 --- a/Source/Client/Session.h +++ b/Source/Client/Session.h @@ -372,7 +372,7 @@ public: /* 5334 */ int unknown_5334; /* 5338 */ int unknown_5338; /* 533C */ int unknown_533C; - /* 5340 */ unsigned char unknown_5340[0x30]; + /* 5340 */ int unknown_5340[12]; /* 5370 */ unsigned char unknown_5370[0x30]; /* 53A0 */ unsigned char unknown_53A0[0x30]; /* 53D0 */ unsigned char unknown_53D0[0x30]; @@ -887,6 +887,27 @@ public: void LoadXmlTables(); void LoadExternalSettings(); void ReloadLanguageTables(); + void ClearItems1784(); + void UpdateRandomStats(); + void ResetEquipment(); + void ResetSlots(); + void sub_DD9D50(); + void sub_DF33B0(); + int GetList0Size() const; + int GetList1Size() const; + int GetList2Size() const; + int GetList4Size() const; + int GetList5Size() const; + int GetList6Size() const; + int GetList7Size() const; + int GetList8Size() const; + int GetList9Size() const; + int GetList10Size() const; + int GetList11Size() const; + int GetList1788(int index) const; + void KeepEquipment(); + void ClearTradeItems(); + void RemoveEquipment(); float GetOptionFloat(const char* key, float fallback); // INLINED bool& ItemSlotActive() { diff --git a/Source/Client/Stove/StoveMgr.cpp b/Source/Client/Stove/StoveMgr.cpp index 492e01c2..4eacbe53 100644 --- a/Source/Client/Stove/StoveMgr.cpp +++ b/Source/Client/Stove/StoveMgr.cpp @@ -166,9 +166,6 @@ struct ConfirmPurchaseCallback { void operator()(Stove::PCSDK::CallbackResult callbackResult, bool purchased, int unknown1, unsigned int count, int unknown2, int unknown3) const; }; -struct SessionItemLists { - void ClearItems1780(); -}; // OFFSET: 0x0063AAE0 // FUNCTION: fn_04778 @@ -303,7 +300,7 @@ void CategoryProductsCallback::operator()(Stove::PCSDK::CallbackResult callbackR unsigned int count) const { g_stoveWaitingCallback = false; if (callbackResult.GetResult().IsSuccessful()) { - reinterpret_cast(&g_session)->ClearItems1780(); + g_session.ClearItems1784(); for (unsigned int index = 0; index < count; ++index) { const Stove::PCSDK::IAP::StovePCProduct& product = products[index]; std::string categoryId = EncodeText(CP_ACP, std::wstring(product.GetCategoryId())); diff --git a/Source/Contents/Items/BarterMarketItemMgr.cpp b/Source/Contents/Items/BarterMarketItemMgr.cpp index cd9ad84b..9d8c9406 100644 --- a/Source/Contents/Items/BarterMarketItemMgr.cpp +++ b/Source/Contents/Items/BarterMarketItemMgr.cpp @@ -41,9 +41,6 @@ struct BarterTree { ~BarterTree(); }; -struct SessionMessengerContext { - int GetList0Size() const; -}; struct BarterTreeIterator { /* 0000 */ BarterTreeNode* node; @@ -879,7 +876,7 @@ BarterKeyLookup BarterKeyTree::FindLowerBound(const std::vector& key) void CExpandedBarterMarketItemMgr::LoadInventoryItems() { this->itemInfos.clear(); - const int count = reinterpret_cast(&g_session)->GetList0Size(); + const int count = g_session.GetList0Size(); for (int i = 0; i < count; ++i) { ITEM_INFO item = g_session.GetInventoryItemAt(i); if (item.identified) { diff --git a/Source/Contents/Messenger/ClientMessenger.cpp b/Source/Contents/Messenger/ClientMessenger.cpp index 4f268586..a495a093 100644 --- a/Source/Contents/Messenger/ClientMessenger.cpp +++ b/Source/Contents/Messenger/ClientMessenger.cpp @@ -56,28 +56,6 @@ extern "C" { void __fastcall RefreshItemWindows(UIWindowMgr* mgr); -struct SessionItemLists { - /* 0000 */ unsigned char unknown_0000[0x1710]; - /* 1710 */ std::list inventory; - /* 1718 */ std::list items_1718; - /* 1720 */ std::list items_1720; - /* 1728 */ std::list items_1728; - /* 1730 */ std::list items_1730; - /* 1738 */ unsigned char unknown_1738[0x48]; - /* 1780 */ std::list items_1780[11]; - - void ClearItems1780(); - void KeepEquipment(); - void RemoveEquipment(); - void ClearTradeItems(); -}; - -#if defined(_WIN32) && !defined(_WIN64) -static_assert(offsetof(SessionItemLists, inventory) == 0x1710); -static_assert(offsetof(SessionItemLists, items_1730) == 0x1730); -static_assert(offsetof(SessionItemLists, items_1780) == 0x1780); -#endif - namespace EquipmentProperties { class CEquipmentProperties; } @@ -5118,55 +5096,6 @@ void CSession::SetPartyLeader(std::uint32_t accountId, int leader) { } } -struct SessionMessengerContext { - unsigned char pad_0000[0x1710]; - /* 1710 */ std::list lists[12]; - /* 1770 */ unsigned char pad_1770[0x18]; - /* 1788 */ int listData[11][2]; - /* 17E0 */ unsigned char pad_17E0[0x10]; - /* 17F0 */ ITEM_INFO equipSlots[10]; - /* 21A0 */ unsigned char pad_21A0[0x1D20]; - /* 3EC0 */ int slots[10][62]; - /* 4870 */ unsigned char pad_4870[0x9A0]; - /* 5210 */ int slot5210; - /* 5214 */ unsigned char pad_5214[0x118]; - /* 532C */ int stat2C; - /* 5330 */ int stat30; - /* 5334 */ int stat34; - /* 5338 */ int stat38; - /* 533C */ int stat3C; - /* 5340 */ int stats[12]; - /* 5370 */ unsigned char pad_5370[0x1F8]; - /* 5568 */ int bound68; - /* 556C */ int bound6C; - /* 5570 */ int bound70; - /* 5574 */ int bound74; - - void UpdateRandomStats(); - void sub_DD9D50(); - void sub_DF33B0(); - void ClearMemberLists(); - void PurgeMatchingMembers1(); - void ClearLists(); - void InitSlots(); - void PurgeMatchingMembers2(); - void ResetSlots(); - void ResetEquipment(); - - int GetList0Size() const; - int GetList11Size() const; - int GetList6Size() const; - int GetList8Size() const; - int GetList9Size() const; - int GetList10Size() const; - int GetList7Size() const; - int GetList1788(int index) const; - int GetList2Size() const; - int GetList4Size() const; - int GetList1Size() const; - int GetList5Size() const; -}; - struct ItemNotificationWindow : UIWindow { /* 0080 */ unsigned char unknown_0080[0x34]; /* 00B4 */ MessengerMember member; @@ -5523,33 +5452,33 @@ bool CGameMode::IsValidCell(int x, int y) { // OFFSET: 0x00DD80A0 // FUNCTION: fn_23304 -void SessionMessengerContext::UpdateRandomStats() { +void CSession::UpdateRandomStats() { if (g_resetMessengerRandomStats != 0) { g_resetMessengerRandomStats = 0; - this->stat34 = std::max(std::rand() % 12, 0); - this->stat30 = std::max(std::rand() % 12, 0); - this->stat3C = std::max(std::rand() % 12, 0); - this->stat2C = std::max(std::rand() % 12, 0); - this->stat38 = std::max(std::rand() % 12, 0); + this->unknown_5334 = std::max(std::rand() % 12, 0); + this->unknown_5330 = std::max(std::rand() % 12, 0); + this->unknown_533C = std::max(std::rand() % 12, 0); + this->unknown_532C = std::max(std::rand() % 12, 0); + this->unknown_5338 = std::max(std::rand() % 12, 0); } - const int bound70 = this->bound70; - const int bound74 = this->bound74; - const int bound68 = this->bound68; - const int bound6C = this->bound6C; - this->stat34 = std::max(std::rand() % 12, 0); - this->stat2C = std::max(std::rand() % 12, 0); - this->stat38 = std::max(std::rand() % 12, 0); - this->stat30 = std::max(std::rand() % 12, 0); - this->stat3C = std::max(std::rand() % 12, 0); - for (int& value : this->stats) { + const int bound70 = reinterpret_cast(this->unknown_5570[0]); + const int bound74 = reinterpret_cast(this->unknown_5570[4]); + const int bound68 = this->unknown_5568; + const int bound6C = this->unknown_556C; + this->unknown_5334 = std::max(std::rand() % 12, 0); + this->unknown_532C = std::max(std::rand() % 12, 0); + this->unknown_5338 = std::max(std::rand() % 12, 0); + this->unknown_5330 = std::max(std::rand() % 12, 0); + this->unknown_533C = std::max(std::rand() % 12, 0); + for (int& value : this->unknown_5340) { value = std::max(std::abs(std::rand()) % 1, 0); } const auto notify = [this]() { if (g_modeMgr.GetGameMode()) { if (g_windowMgr.unknown_01DC) { - if (this->bound6C < this->bound68 || this->bound74 < this->bound70) { + if (this->unknown_556C < this->unknown_5568 || reinterpret_cast(this->unknown_5570[4]) < reinterpret_cast(this->unknown_5570[0])) { return; } reinterpret_cast(g_windowMgr.unknown_01DC)->Invalidate(); @@ -5558,20 +5487,20 @@ void SessionMessengerContext::UpdateRandomStats() { static_cast(g_modeMgr.GetGameMode())->NotifyItemBounds(); } }; - if (this->bound68 != bound68) { - this->bound68 = bound68; + if (this->unknown_5568 != bound68) { + this->unknown_5568 = bound68; notify(); } - if (this->bound6C != bound6C) { - this->bound6C = bound6C; + if (this->unknown_556C != bound6C) { + this->unknown_556C = bound6C; notify(); } - if (this->bound70 != bound70) { - this->bound70 = bound70; + if (reinterpret_cast(this->unknown_5570[0]) != bound70) { + reinterpret_cast(this->unknown_5570[0]) = bound70; notify(); } - if (this->bound74 != bound74) { - this->bound74 = bound74; + if (reinterpret_cast(this->unknown_5570[4]) != bound74) { + reinterpret_cast(this->unknown_5570[4]) = bound74; notify(); } } @@ -5590,8 +5519,8 @@ void ClearMemberFlags(std::uint32_t* flags) { // OFFSET: 0x00DD85B0 // FUNCTION: fn_23309 -void SessionMessengerContext::ResetEquipment() { - for (ITEM_INFO& item : this->equipSlots) { +void CSession::ResetEquipment() { + for (ITEM_INFO& item : this->unknown_17F0) { item.Reset(); } RequestBasicInfoRefresh(); @@ -5603,110 +5532,110 @@ void SessionMessengerContext::ResetEquipment() { // OFFSET: 0x00DD8750 // FUNCTION: fn_23311 -void SessionMessengerContext::ResetSlots() { - this->slot5210 = 0; - this->slots[0][0] = 0; - this->slots[1][0] = 0; - this->slots[2][0] = 0; - this->slots[3][0] = 0; - this->slots[4][0] = 0; - this->slots[5][0] = 0; - this->slots[6][0] = 0; - this->slots[7][0] = 0; - this->slots[8][0] = 0; - this->slots[9][0] = 0; +void CSession::ResetSlots() { + this->unknown_5210 = 0; + this->m_exchangeItems[0].quantity = 0; + this->m_exchangeItems[1].quantity = 0; + this->m_exchangeItems[2].quantity = 0; + this->m_exchangeItems[3].quantity = 0; + this->m_exchangeItems[4].quantity = 0; + this->m_exchangeItems[5].quantity = 0; + this->m_exchangeItems[6].quantity = 0; + this->m_exchangeItems[7].quantity = 0; + this->m_exchangeItems[8].quantity = 0; + this->m_exchangeItems[9].quantity = 0; } // OFFSET: 0x00DDF8B0 // FUNCTION: fn_23428 -int SessionMessengerContext::GetList0Size() const { - return static_cast(this->lists[0].size()); +int CSession::GetList0Size() const { + return static_cast(this->m_inventoryItems.size()); } // OFFSET: 0x00DDF8C0 // FUNCTION: fn_23429 -int SessionMessengerContext::GetList11Size() const { - return static_cast(this->lists[11].size()); +int CSession::GetList11Size() const { + return static_cast(this->unknown_1768.size()); } // OFFSET: 0x00DDF8D0 // FUNCTION: fn_23430 -int SessionMessengerContext::GetList6Size() const { - return static_cast(this->lists[6].size()); +int CSession::GetList6Size() const { + return static_cast(this->unknown_1740.size()); } // OFFSET: 0x00DDF8E0 // FUNCTION: fn_23431 -int SessionMessengerContext::GetList8Size() const { - return static_cast(this->lists[8].size()); +int CSession::GetList8Size() const { + return static_cast(this->unknown_1750.size()); } // OFFSET: 0x00DDF8F0 // FUNCTION: fn_23432 -int SessionMessengerContext::GetList9Size() const { - return static_cast(this->lists[9].size()); +int CSession::GetList9Size() const { + return static_cast(this->unknown_1758.size()); } // OFFSET: 0x00DDF900 // FUNCTION: fn_23433 -int SessionMessengerContext::GetList10Size() const { - return static_cast(this->lists[10].size()); +int CSession::GetList10Size() const { + return static_cast(this->unknown_1760.size()); } // OFFSET: 0x00DDF910 // FUNCTION: fn_23434 -int SessionMessengerContext::GetList7Size() const { - return static_cast(this->lists[7].size()); +int CSession::GetList7Size() const { + return static_cast(this->unknown_1748.size()); } // OFFSET: 0x00DDF920 // FUNCTION: fn_23435 -int SessionMessengerContext::GetList1788(int index) const { +int CSession::GetList1788(int index) const { if (index < 0) { return 0; } if (index >= 11) { return 0; } - return this->listData[index][0]; + return static_cast(this->unknown_1784[index].size()); } // OFFSET: 0x00DDF9E0 // FUNCTION: fn_23437 -int SessionMessengerContext::GetList2Size() const { - return static_cast(this->lists[2].size()); +int CSession::GetList2Size() const { + return static_cast(this->unknown_1720.size()); } // OFFSET: 0x00DDF9F0 // FUNCTION: fn_23438 -int SessionMessengerContext::GetList4Size() const { - return static_cast(this->lists[4].size()); +int CSession::GetList4Size() const { + return static_cast(this->unknown_1730.size()); } // OFFSET: 0x00DDFA00 // FUNCTION: fn_23439 -int SessionMessengerContext::GetList1Size() const { - return static_cast(this->lists[1].size()); +int CSession::GetList1Size() const { + return static_cast(this->unknown_1718.size()); } // OFFSET: 0x00DDFA10 // FUNCTION: fn_23440 -int SessionMessengerContext::GetList5Size() const { - return static_cast(this->lists[5].size()); +int CSession::GetList5Size() const { + return static_cast(this->unknown_1738.size()); } // OFFSET: 0x00DD8380 // FUNCTION: fn_23305 -void SessionItemLists::ClearItems1780() { - for (std::list& items : this->items_1780) { +void CSession::ClearItems1784() { + for (std::list& items : this->unknown_1784) { items.clear(); } } // OFFSET: 0x00DD8450 // FUNCTION: fn_23306 -void SessionItemLists::KeepEquipment() { - for (auto entry = this->inventory.begin(); entry != this->inventory.end();) { +void CSession::KeepEquipment() { + for (auto entry = this->m_inventoryItems.begin(); entry != this->m_inventoryItems.end();) { switch (entry->unknown_0000[0]) { case 4: case 5: @@ -5720,7 +5649,7 @@ void SessionItemLists::KeepEquipment() { ++entry; break; default: - entry = this->inventory.erase(entry); + entry = this->m_inventoryItems.erase(entry); break; } } @@ -5730,16 +5659,16 @@ void SessionItemLists::KeepEquipment() { // OFFSET: 0x00DD8540 // FUNCTION: fn_23307 -void SessionItemLists::ClearTradeItems() { - this->items_1720.erase(this->items_1720.begin(), this->items_1720.end()); - this->items_1730.erase(this->items_1730.begin(), this->items_1730.end()); - this->items_1718.erase(this->items_1718.begin(), this->items_1718.end()); +void CSession::ClearTradeItems() { + this->unknown_1720.erase(this->unknown_1720.begin(), this->unknown_1720.end()); + this->unknown_1730.erase(this->unknown_1730.begin(), this->unknown_1730.end()); + this->unknown_1718.erase(this->unknown_1718.begin(), this->unknown_1718.end()); } // OFFSET: 0x00DD8660 // FUNCTION: fn_23310 -void SessionItemLists::RemoveEquipment() { - for (auto entry = this->inventory.begin(); entry != this->inventory.end();) { +void CSession::RemoveEquipment() { + for (auto entry = this->m_inventoryItems.begin(); entry != this->m_inventoryItems.end();) { switch (entry->unknown_0000[0]) { case 4: case 5: @@ -5750,7 +5679,7 @@ void SessionItemLists::RemoveEquipment() { case 13: case 14: case 15: - entry = this->inventory.erase(entry); + entry = this->m_inventoryItems.erase(entry); break; default: ++entry; @@ -6325,7 +6254,7 @@ HANDLE g_embedFontFiles; // OFFSET: 0x00DD9D50 // FUNCTION: fn_23337 -void SessionMessengerContext::sub_DD9D50() { +void CSession::sub_DD9D50() { if (!g_itemInfoMgr->Load()) { const std::uint8_t caption[] = {0x2A, 0x0F, 0x89, 0x4C, 0x03, 0x07}; const std::uint8_t message[] = {0x80, 0x81, 0x3A, 0xE6, 0xC6, 0xBB, 0xDD, 0x4C, 0xE9, 0x93, 0x36, 0xE7, 0xEA, 0xF5, 0xF2, 0x4D, 0xA0, 0x81, 0x5F}; @@ -6360,8 +6289,8 @@ void SessionMessengerContext::sub_DD9D50() { CGameSettingsMgr* settings = Singleton::GetInstance(); static_cast(settings->LoadSettings()); - reinterpret_cast(this)->LoadOptionInfo(); - reinterpret_cast(this)->LoadDamageSkinSettings(); + this->LoadOptionInfo(); + this->LoadDamageSkinSettings(); if (g_serviceType == 0) { InitEmbedFont(); diff --git a/Source/UI/Acceptance/UIChooseSellBuyWnd.cpp b/Source/UI/Acceptance/UIChooseSellBuyWnd.cpp index efbef30e..72b09567 100644 --- a/Source/UI/Acceptance/UIChooseSellBuyWnd.cpp +++ b/Source/UI/Acceptance/UIChooseSellBuyWnd.cpp @@ -3529,9 +3529,6 @@ int UIBookWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intp return 0; } -struct SessionItemLists { - void ClearTradeItems(); -}; // OFFSET: 0x008F8860 // FUNCTION: fn_12332 @@ -3551,7 +3548,7 @@ int UIChooseSellBuyWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, return 0; } - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); } return 0; @@ -5955,10 +5952,6 @@ void UIWhisperWnd::Slot11() { g_windowMgr.UnregisterNamedWindow(std::string(this->m_target.c_str(), this->m_target.size())); } -struct SessionMessengerContext { - int GetList1788(int index) const; - int GetList2Size() const; -}; // OFFSET: 0x008D88F0 // FUNCTION: fn_12130 @@ -5967,7 +5960,7 @@ ITEM_INFO UInCashWnd::ItemAt(int x, int y) { return ITEM_INFO(0); } - const SessionMessengerContext& lists = reinterpret_cast(g_session); + const CSession& lists = g_session; int top = this->m_listTop; if (x < 252) { std::list::iterator it = this->items.begin(); @@ -6843,7 +6836,7 @@ int UIMixAcceptWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std: g_windowMgr.CloseWindow(161); static_cast(g_charViewMode)->SendMsg(266, 0, 0, 0, 0); g_windowMgr.CloseWindow(163); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); } else if (a == 185) { g_windowMgr.CloseWindow(163); } @@ -8833,7 +8826,7 @@ void UInCashWnd::Slot26(int x, int y) { this->m_totalPrice -= item.quantity * item.unknown_0014[1]; this->m_otherItems.clear(); - const SessionMessengerContext& lists = reinterpret_cast(g_session); + const CSession& lists = g_session; const int count = lists.GetList2Size(); for (int index = 0; index < count; ++index) { ITEM_INFO other = g_session.GetItem1720At(index); diff --git a/Source/UI/CashShop/UICashShopWnd.cpp b/Source/UI/CashShop/UICashShopWnd.cpp index 0075edda..2727e99f 100644 --- a/Source/UI/CashShop/UICashShopWnd.cpp +++ b/Source/UI/CashShop/UICashShopWnd.cpp @@ -95,10 +95,6 @@ struct ClientItemLists { void ClearItems1784(int index); }; -struct SessionMessengerContext { - int GetList0Size() const; - int GetList1788(int index) const; -}; struct CashShopReplaceCartItemText { EncryptedName<85, 0x3B915119EFD523EFULL>& operator()() const; @@ -795,7 +791,7 @@ void UICashShopWnd_Banner::CreateButtons() { // FUNCTION: fn_09558 int UICashShopWnd::SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) { ClientItemLists& itemLists = reinterpret_cast(g_session); - const SessionMessengerContext& lists = reinterpret_cast(g_session); + const CSession& lists = g_session; switch (message) { case 0: if (sender == this->unknown_00E0) { diff --git a/Source/UI/Edit/UIEditCtrl.cpp b/Source/UI/Edit/UIEditCtrl.cpp index 74740d2b..de17ab3c 100644 --- a/Source/UI/Edit/UIEditCtrl.cpp +++ b/Source/UI/Edit/UIEditCtrl.cpp @@ -143,20 +143,7 @@ struct ClientItemLists { void ClearItems1760And1748(); }; -struct SessionItemLists { - void ClearTradeItems(); -}; -struct SessionMessengerContext { - int GetList1Size() const; - int GetList0Size() const; - int GetList10Size() const; - int GetList4Size() const; - int GetList5Size() const; - int GetList6Size() const; - int GetList7Size() const; - int GetList8Size() const; -}; namespace { #pragma pack(push, 1) @@ -4621,7 +4608,7 @@ int UIMerchantItemWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, s break; case 23: { this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList6Size(); + const int size = g_session.GetList6Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1740At(i); if (item.unknown_0000[1] != 0) { @@ -4702,7 +4689,7 @@ int UIMerchantMirrorItemWnd::SendMsg(UIWindow* sender, int message, std::intptr_ break; case 23: { this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList8Size(); + const int size = g_session.GetList8Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1750At(i); if (item.unknown_0000[1] != 0) { @@ -4784,7 +4771,7 @@ int UIMerchantMirrorItemWnd::SendMsg(UIWindow* sender, int message, std::intptr_ int UIItemSellWnd2::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intptr_t b, std::intptr_t c, std::intptr_t d) { switch (message) { case 6: { - const int count = reinterpret_cast(&g_session)->GetList4Size(); + const int count = g_session.GetList4Size(); CMode* mode = g_modeMgr.gameMode; if (a == 184) { if (count > 0) { @@ -4792,14 +4779,14 @@ int UIItemSellWnd2::SendMsg(UIWindow* sender, int message, std::intptr_t a, std: mode->SendMsg(result == 187 ? 266 : 267, this->unknown_00FC, 0, 0, 0); g_windowMgr.CloseWindow(160); g_windowMgr.CloseWindow(161); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); return 0; } } else if (a == 185) { mode->SendMsg(267, this->unknown_00FC, 0, 0, 0); g_windowMgr.CloseWindow(160); g_windowMgr.CloseWindow(161); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); return 0; } break; @@ -4845,7 +4832,7 @@ int UIItemSellWnd2::SendMsg(UIWindow* sender, int message, std::intptr_t a, std: } this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList4Size(); + const int size = g_session.GetList4Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1730At(i); if (item.unknown_0000[1] != 0) { @@ -4945,7 +4932,7 @@ int UIMerchantItemPurchaseWnd::SendMsg(UIWindow* sender, int message, std::intpt item.Assign(reinterpret_cast(drag)); ITEM_INFO found; - const int ownedCount = reinterpret_cast(&g_session)->GetList10Size(); + const int ownedCount = g_session.GetList10Size(); int owned = 0; for (int i = 0; i < ownedCount; ++i) { found = g_session.GetItem1760At(i); @@ -4956,7 +4943,7 @@ int UIMerchantItemPurchaseWnd::SendMsg(UIWindow* sender, int message, std::intpt } ITEM_INFO stock; - const int stockCount = reinterpret_cast(&g_session)->GetList7Size(); + const int stockCount = g_session.GetList7Size(); int limit = 0; for (int i = 0; i < stockCount; ++i) { stock = g_session.GetItem1748At(i); @@ -5093,7 +5080,7 @@ int UIMerchantItemPurchaseWnd::SendMsg(UIWindow* sender, int message, std::intpt case 23: { this->items.erase(this->items.begin(), this->items.end()); int sum = 0; - const int count = reinterpret_cast(&g_session)->GetList10Size(); + const int count = g_session.GetList10Size(); for (int i = 0; i < count; ++i) { ITEM_INFO item = g_session.GetItem1760At(i); if (item.unknown_0000[1] != 0) { @@ -5175,7 +5162,7 @@ int UIMerchantItemShopWnd::SendMsg(UIWindow* sender, int message, std::intptr_t break; case 23: { this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList7Size(); + const int size = g_session.GetList7Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1748At(i); if (item.unknown_0000[1] != 0) { @@ -6514,7 +6501,7 @@ int UIItemShopWnd2::SendMsg(UIWindow* sender, int message, std::intptr_t a, std: break; case 23: { this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList1Size(); + const int size = g_session.GetList1Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1718At(i); if (item.unknown_0000[1] != 0) { @@ -6686,7 +6673,7 @@ int UIItemShopWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std:: break; case 23: { this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList1Size(); + const int size = g_session.GetList1Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1718At(i); if (item.unknown_0000[1] != 0) { @@ -7723,7 +7710,7 @@ int UIItemWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std::intp return 0; } this->items.erase(this->items.begin(), this->items.end()); - for (int i = 0; i < reinterpret_cast(&g_session)->GetList0Size(); ++i) { + for (int i = 0; i < g_session.GetList0Size(); ++i) { ITEM_INFO item = g_session.GetInventoryItemAt(i); if (item.unknown_0000[1] == 0) { continue; @@ -7871,7 +7858,7 @@ int UIMerchantItemPurchaseMSGWnd::SendMsg(UIWindow* sender, int message, std::in // FUNCTION: fn_13443 void UIItemWnd::RefreshItems() { this->items.clear(); - for (int i = 0; i < reinterpret_cast(&g_session)->GetList0Size(); ++i) { + for (int i = 0; i < g_session.GetList0Size(); ++i) { ITEM_INFO item = g_session.GetInventoryItemAt(i); if (item.unknown_0074[0] == 1) { this->items.push_back(item); @@ -8012,7 +7999,7 @@ void UIMerchantItemPurchaseMSGWnd::SetPurchase(int value, int amount) { this->unknown_00D0 = amount; int total = 0; - const int count = reinterpret_cast(&g_session)->GetList10Size(); + const int count = g_session.GetList10Size(); for (int i = 0; i < count; ++i) { ITEM_INFO item; item = g_session.GetItem1760At(i); @@ -8662,7 +8649,7 @@ int UIItemSellWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std:: g_windowMgr.CloseWindow(22); g_windowMgr.CloseWindow(24); mode->SendMsg(40, 0, 0, 0, 0); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); return 0; } case 14: @@ -8704,7 +8691,7 @@ int UIItemSellWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std:: case 23: { this->items.erase(this->items.begin(), this->items.end()); int totalPrice = 0; - const int size = reinterpret_cast(&g_session)->GetList4Size(); + const int size = g_session.GetList4Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1730At(i); if (item.unknown_0000[1] != 0) { @@ -8916,7 +8903,7 @@ void UIItemWnd::Paint() { } } - const int count = reinterpret_cast(&g_session)->GetList0Size() + g_session.CountItems17F0() + g_session.CountItems2B50(); + const int count = g_session.GetList0Size() + g_session.CountItems17F0() + g_session.CountItems2B50(); const std::uint32_t color = count >= g_extraInventorySlots + 100 ? 0xFF : 0x232323; this->DrawTextAt(35, this->geometry.height - 15, FormatOwnedString("%d", count).c_str(), 0, 0, 11, color, 0, 0); const int width = this->TextWidth(FormatOwnedString("%d", count).c_str(), 0, 0, 11, 0, 0); @@ -9074,7 +9061,7 @@ int UIItemStoreFindWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, return 0; case 23: { this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList5Size(); + const int size = g_session.GetList5Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1738At(i); if (item.unknown_0000[1] != 0) { diff --git a/Source/UI/Item/UIParaItemShopWnd.cpp b/Source/UI/Item/UIParaItemShopWnd.cpp index 9998cb88..452667a9 100644 --- a/Source/UI/Item/UIParaItemShopWnd.cpp +++ b/Source/UI/Item/UIParaItemShopWnd.cpp @@ -40,14 +40,7 @@ #include #include -struct SessionItemLists { - void ClearTradeItems(); -}; -struct SessionMessengerContext { - int GetList1Size() const; - int GetList2Size() const; -}; namespace { #pragma pack(push, 1) @@ -382,14 +375,14 @@ int UIParaItemPurchaseWnd::SendMsg(UIWindow* sender, int message, std::intptr_t if (a == 184) { ITEM_INFO item = g_session.GetItem1720At(0); mode->SendMsg(item.unknown_0074[3] == 1 ? 263 : 262, 0, 0, 0, 0); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); return 0; } if (a == 185) { mode->SendMsg(292, 0, 0, 0, 0); mode->SendMsg(40, 0, 0, 0, 0); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); return 0; } break; @@ -433,7 +426,7 @@ int UIParaItemPurchaseWnd::SendMsg(UIWindow* sender, int message, std::intptr_t case 23: { this->items.erase(this->items.begin(), this->items.end()); int sum = 0; - const int size = reinterpret_cast(&g_session)->GetList2Size(); + const int size = g_session.GetList2Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1720At(i); if (item.unknown_0000[1] != 0) { @@ -572,7 +565,7 @@ int UIParaItemShopWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, s break; case 23: { this->items.erase(this->items.begin(), this->items.end()); - const int size = reinterpret_cast(&g_session)->GetList1Size(); + const int size = g_session.GetList1Size(); for (int i = 0; i < size; ++i) { ITEM_INFO item = g_session.GetItem1718At(i); if (item.unknown_0000[1] != 0) { @@ -601,7 +594,7 @@ int UIParaResultWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a, std if (a == 184) { mode->SendMsg(292, 0, 0, 0, 0); mode->SendMsg(40, 0, 0, 0, 0); - reinterpret_cast(&g_session)->ClearTradeItems(); + g_session.ClearTradeItems(); return 0; } break; diff --git a/Source/UI/RuneSystem/UIRuneSystemWnd.cpp b/Source/UI/RuneSystem/UIRuneSystemWnd.cpp index 6225facf..33363619 100644 --- a/Source/UI/RuneSystem/UIRuneSystemWnd.cpp +++ b/Source/UI/RuneSystem/UIRuneSystemWnd.cpp @@ -1689,9 +1689,6 @@ void UIRune_Decom::SetItem(int itemId) { } } -struct SessionMessengerContext { - int GetList0Size() const; -}; // OFFSET: 0x008184A0 // FUNCTION: fn_10175 @@ -1737,7 +1734,7 @@ int UIRune_Decom::SendMsg(UIWindow* sender, int message, std::intptr_t argument1 g_windowMgr.CloseWindow(0x16A); if (!g_runeSystemMgr->IsRequestPending() && (!this->parent || this->parent->SendMsg(this, 0x6A, 50, 0, 0, 0) != 0) && this->m_ownedCount) { if (static_cast(g_session.m_weight) > static_cast(g_session.m_maxWeight) * 0.7f || - reinterpret_cast(&g_session)->GetList0Size() + g_session.CountItems17F0() + g_session.CountItems2B50() + 8 >= + g_session.GetList0Size() + g_session.CountItems17F0() + g_session.CountItems2B50() + 8 >= g_session.unknown_7FBC + 100) { g_windowMgr.Confirm(LookupMessage(4064), 0, true, false, 0, "Message", 280, 120, 0); } else { diff --git a/Source/UI/Shop/MerchantShopRefresh.cpp b/Source/UI/Shop/MerchantShopRefresh.cpp index 916c4974..b3c6aef8 100644 --- a/Source/UI/Shop/MerchantShopRefresh.cpp +++ b/Source/UI/Shop/MerchantShopRefresh.cpp @@ -11,9 +11,6 @@ #include #include -struct SessionMessengerContext { - int GetList11Size() const; -}; // OFFSET: 0x00970E60 // FUNCTION: fn_13262 @@ -46,7 +43,7 @@ void UIMerchantShopMakeWnd::Refresh() { edit->Background(background, background, background); } - const int count = reinterpret_cast(&g_session)->GetList11Size(); + const int count = g_session.GetList11Size(); for (int index = 0; index < count; ++index) { const ITEM_INFO item = g_session.GetItem1768At(index); diff --git a/Source/UI/UIBartermarketWnd.cpp b/Source/UI/UIBartermarketWnd.cpp index d4a7c8a0..d72b8d67 100644 --- a/Source/UI/UIBartermarketWnd.cpp +++ b/Source/UI/UIBartermarketWnd.cpp @@ -212,14 +212,11 @@ std::pair UIBarterItemPurchaseWnd::GetBarterItemAt(int x return std::pair(false, BarterMarketItem()); } -struct SessionMessengerContext { - int GetList0Size() const; -}; // OFFSET: 0x00841910 // FUNCTION: fn_10551 int UIBarterItemPurchaseWnd::GetInventoryItemCount(int itemId) { - const int count = reinterpret_cast(&g_session)->GetList0Size(); + const int count = g_session.GetList0Size(); for (int i = 0; i < count; ++i) { ITEM_INFO item = g_session.GetInventoryItemAt(i); if (std::atoi(item.itemId.c_str()) == itemId) { @@ -573,7 +570,7 @@ int UIExpandedBarterItemPurchaseWnd::SendMsg(UIWindow* sender, int message, std: if (!missing && g_session.HasItemCount(chunk->field_0, chunk->field_4) == true) { const int itemId = chunk->field_0; const int refine = chunk->field_4; - const int count = reinterpret_cast(&g_session)->GetList0Size(); + const int count = g_session.GetList0Size(); int available = 0; for (int i = 0; i < count; ++i) { ITEM_INFO item = g_session.GetInventoryItemAt(i); @@ -1150,7 +1147,7 @@ bool UIBarterItemPurchaseWnd::Purchase() { std::map totals; std::list items = *g_barterMarketItemMgr->GetAllItems(); - int count = reinterpret_cast(&g_session)->GetList0Size(); + int count = g_session.GetList0Size(); count += g_session.CountItems17F0(); count += g_session.CountItems2B50(); @@ -1563,7 +1560,7 @@ bool UIExpandedBarterItemPurchaseWnd::Purchase() { std::map totals; std::vector entries = *g_expandedBarterMarketItemMgr->GetEntries(); - int count = reinterpret_cast(&g_session)->GetList0Size(); + int count = g_session.GetList0Size(); count += g_session.CountItems17F0(); count += g_session.CountItems2B50(); @@ -1598,7 +1595,7 @@ bool UIExpandedBarterItemPurchaseWnd::Purchase() { for (std::map::iterator it = totals.begin(); it != totals.end(); ++it) { const int itemId = std::atoi(it->first.c_str()); - const int inventoryCount = reinterpret_cast(&g_session)->GetList0Size(); + const int inventoryCount = g_session.GetList0Size(); int owned = 0; for (int i = 0; i < inventoryCount; ++i) { ITEM_INFO item = g_session.GetInventoryItemAt(i); diff --git a/Source/UI/UIGradeEnchantWnd.cpp b/Source/UI/UIGradeEnchantWnd.cpp index 773e379d..9bc1bfec 100644 --- a/Source/UI/UIGradeEnchantWnd.cpp +++ b/Source/UI/UIGradeEnchantWnd.cpp @@ -633,9 +633,6 @@ void UIGradeEnchantWnd::SetResult(int state, int result) { this->Invalidate(); } -struct SessionMessengerContext { - int GetList0Size() const; -}; // OFFSET: 0x007E7050 // FUNCTION: fn_09748 @@ -670,7 +667,7 @@ void UIGradeEnchantWnd::sub_7E7050() { } if (static_cast(g_session.m_weight) > static_cast(g_session.m_maxWeight) * 0.7f || - reinterpret_cast(&g_session)->GetList0Size() + g_session.CountItems17F0() + + g_session.GetList0Size() + g_session.CountItems17F0() + g_session.CountItems2B50() >= g_session.unknown_7FBC + 100) { this->unknown_011C.push_back(3710);