diff --git a/Source/Contents/RodexMailStore.h b/Source/Contents/RodexMailStore.h index 70dd07ca..67b5eb20 100644 --- a/Source/Contents/RodexMailStore.h +++ b/Source/Contents/RodexMailStore.h @@ -46,8 +46,13 @@ public: /* 0000 */ bool m_isValid; /* 0004 */ int unknown_0004; - /* 0008 */ int unknown_0008; - /* 000C */ int unknown_000C; + union { + struct { + /* 0008 */ int unknown_0008; + /* 000C */ int unknown_000C; + }; + /* 0008 */ std::int64_t currentMailId; + }; /* 0010 */ unsigned char unknown_0010; /* 0014 */ int unknown_0014; /* 0018 */ int unknown_0018; diff --git a/Source/UI/Window/UIRodexContentsWnd.cpp b/Source/UI/Window/UIRodexContentsWnd.cpp index 6a35b758..e9f7ec86 100644 --- a/Source/UI/Window/UIRodexContentsWnd.cpp +++ b/Source/UI/Window/UIRodexContentsWnd.cpp @@ -1,6 +1,7 @@ #include "UI/Window/UIRodexContentsWnd.h" #include "Client/Input/InputCharset.h" +#include "Client/Mode/CGameMode.h" #include "Client/Mode/ModeMgr.h" #include "Client/Mode/ModeTooltip.h" #include "Client/Session.h" @@ -8,6 +9,9 @@ #include "Contents/Items/ItemDescription.h" #include "Contents/Items/ItemNaming.h" #include "Contents/PlayerNameDictionary.h" +#include "Contents/RodexMailStore.h" +#include "Network/Connection/Connection.h" +#include "Network/Packets/PacketLengths.h" #include "Contents/MessageTable.h" #include "Resource/Bitmap/BitmapResource.h" #include "Resource/ResourceMgr.h" @@ -16,12 +20,31 @@ #include "UI/Buttons/UIBitmapButton.h" #include "UI/Rodex/UIRodexComposeWnd.h" #include "UI/Shop/ItemDrawing.h" +#include "UI/Window/UIWindowMgr.h" +#include "UI/Window/WindowDialogs.h" #include "UI/Window/WindowManagerWindows.h" #include "Utility/Text/FormatString.h" #include "Utility/Text/GroupedInteger.h" +#include #include #include +#include + +namespace { +#pragma pack(push, 1) +struct RodexMailAttachmentRequestPacket { + /* 0000 */ std::uint16_t packetType; + /* 0002 */ std::int64_t mailId; + /* 000A */ std::uint8_t mailType; +}; + +struct RodexMailReportPacket { + /* 0000 */ std::uint16_t packetType; + /* 0002 */ std::int32_t mailId; +}; +#pragma pack(pop) +} // OFFSET: 0x00801CC0 // FUNCTION: fn_10014 @@ -163,6 +186,114 @@ void UIRodexContentsWnd::Slot32(int x, int y) { } } +// OFFSET: 0x008029E0 +// FUNCTION: fn_10025 +int UIRodexContentsWnd::SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) { + if (message == 6) { + switch (argument1) { + case 0xBD: + if (this->m_items.size() != 0) { + if (g_modeMgr.GetGameMode() && static_cast(g_modeMgr.GetGameMode())->IsMenuWindowOpen() == 1) { + break; + } + RodexMailAttachmentRequestPacket packet; + packet.packetType = 0x9F3; + packet.mailId = g_rodexMailStore->currentMailId; + packet.mailType = g_rodexMailStore->unknown_0010; + GetRagConnection().Send(reinterpret_cast(GetRagConnection()).FixedLength(packet.packetType), &packet); + UIBitmapButton* button = this->m_itemButton; + button->SetDisabled(1); + button->Invalidate(); + this->Invalidate(); + } + break; + case 0xBE: + if (this->m_zeny > 0) { + if (g_modeMgr.GetGameMode() && static_cast(g_modeMgr.GetGameMode())->IsMenuWindowOpen() == 1) { + break; + } + RodexMailAttachmentRequestPacket packet; + packet.packetType = 0x9F1; + packet.mailId = g_rodexMailStore->currentMailId; + packet.mailType = g_rodexMailStore->unknown_0010; + GetRagConnection().Send(reinterpret_cast(GetRagConnection()).FixedLength(packet.packetType), &packet); + UIBitmapButton* button = this->m_zenyButton; + button->SetDisabled(1); + button->Invalidate(); + this->Invalidate(); + } + break; + case 0xC9: + g_windowMgr.CloseWindow(265); + g_rodexMailStore->currentMailId = 0; + if (g_windowMgr.unknown_0454) { + reinterpret_cast(g_windowMgr.unknown_0454)->SendMsg(nullptr, 60, 0, 0, 0, 0); + } + break; + case 0xD3: { + RodexMailStore* store = g_rodexMailStore; + std::map* mails; + if (store->unknown_0010 == 0) { + mails = &store->m_mails0; + } else if (store->unknown_0010 == 1) { + mails = &store->m_mails1; + } else { + mails = &store->m_mails2; + } + + std::map::iterator mail = mails->find(store->currentMailId); + if (mail == mails->end()) { + break; + } + + if ((mail->second.unknown_0001 & 6) != 0) { + g_windowMgr.SendNotice(1, reinterpret_cast(LookupMessage(0xA34)), 0x64FFFF, 0, 0, 0); + break; + } + + if (reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(0x164), 2, false, false, 0, "Message", 0x118, 0x78, 0) == 0xBB) { + g_modeMgr.GetGameMode()->SendMsg(0xC4, static_cast(g_rodexMailStore->currentMailId), g_rodexMailStore->unknown_0010, 0, 0); + if (g_windowMgr.unknown_045C != 0) { + g_windowMgr.CloseWindow(265); + } + } + break; + } + case 0x131: + if (this->unknown_010C != 1) { + g_modeMgr.GetGameMode()->SendMsg(0x10C, reinterpret_cast(this->m_title.c_str()), 0, 0, 0); + } + break; + case 0x136: { + RodexMailReportPacket packet; + packet.packetType = 0xB98; + packet.mailId = static_cast(g_rodexMailStore->currentMailId); + GetRagConnection().Send(reinterpret_cast(GetRagConnection()).FixedLength(packet.packetType), &packet); + break; + } + } + } else if (message == 23) { + this->m_items.clear(); + for (int i = 0; i < 5; ++i) { + ITEM_INFO item = g_session.GetItem5C68(i); + if (item.quantity > 0) { + this->m_items.push_back(item); + } + } + this->Invalidate(); + } else if (message == 106) { + if (this->unknown_010C && this->unknown_0108) { + UIBasicButton* button = this->unknown_0108; + button->SetDisabled(1); + button->Invalidate(); + } + } else { + return UIFrameWnd::SendMsg(sender, message, argument1, argument2, argument3, argument4); + } + + return 0; +} + // OFFSET: 0x00803760 // FUNCTION: fn_10027 void UIRodexContentsWnd::SetItemButtonDisabled(unsigned char disabled) { diff --git a/Source/UI/Window/UIRodexContentsWnd.h b/Source/UI/Window/UIRodexContentsWnd.h index 24b4bbcb..d07627bb 100644 --- a/Source/UI/Window/UIRodexContentsWnd.h +++ b/Source/UI/Window/UIRodexContentsWnd.h @@ -21,6 +21,7 @@ public: void Slot25(int x, int y) override; void Slot28(int x, int y) override; void Slot32(int x, int y) override; + int SendMsg(UIWindow* sender, int message, std::intptr_t argument1, std::intptr_t argument2, std::intptr_t argument3, std::intptr_t argument4) override; void SetContentsText(const char* text); ITEM_INFO GetItemAtPoint(int x, int y);