diff --git a/Source/Contents/EntryQueueMgr.cpp b/Source/Contents/EntryQueueMgr.cpp index 416b4a7b..3a5fac2e 100644 --- a/Source/Contents/EntryQueueMgr.cpp +++ b/Source/Contents/EntryQueueMgr.cpp @@ -4,10 +4,12 @@ #include "Contents/Sound/SoundMgr.h" #include "Network/Connection/Connection.h" #include "Network/Packets/PacketLengths.h" +#include "UI/EntryQueue/UIEntryQueueWnd.h" #include "UI/Window/UIWindowMgr.h" #include "UI/Window/WindowDialogs.h" #include +#include struct EntryQueueAdmissionPacket { /* 0000 */ std::uint16_t id; @@ -112,6 +114,96 @@ void CEntryQueueMgr::SetCharacterName(const EntryQueueName& name) { this->characterName = name; } +// OFFSET: 0x00BA2310 +// FUNCTION: fn_19667 +void CEntryQueueMgr::OnApplyResult(const EntryQueueApplyResult* packet) { + int message; + switch (packet->result) { + case 1: { + if (!g_windowMgr.CloseWindow(209)) { + g_windowMgr.EnsureWindow(209); + } + + strcpy_s(this->queueName.text, sizeof(this->queueName.text), packet->queueName); + g_soundMgr->PlayWave("se_btg_request.wav", 0.0f, 0.0f, 0.0f, 250, 40, 1.0f, 0); + + std::string text("["); + if (this->current) { + text += this->current->displayName; + } + text += "]"; + text += LookupMessage(0x833); + g_windowMgr.SendNotice(1, reinterpret_cast(text.c_str()), 0x4763FF, 0, 0, 0); + this->ready = 1; + return; + } + case 2: + message = 0x834; + break; + case 3: + message = 0x835; + break; + case 4: + message = 0x836; + break; + case 5: + message = 0x837; + break; + case 6: + message = 0x838; + break; + case 7: + message = 0x839; + break; + case 8: + message = 0x83A; + break; + case 9: + message = 0x83C; + break; + case 10: + message = 0x83B; + break; + case 15: + message = 0x83D; + break; + default: + return; + } + + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(message), 0, false, false, 0, "Message", 0x118, 0x78, 0); +} + +// OFFSET: 0x00BA2660 +// FUNCTION: fn_19668 +void CEntryQueueMgr::OnCancelResult(const EntryQueueNotice* notice) { + switch (notice->result) { + case 1: + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(0x83E), 0, false, false, 0, "Message", 0x118, 0x78, 0); + g_windowMgr.CloseWindow(209); + this->ready = 0; + break; + case 3: + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(0x83F), 0, false, false, 0, "Message", 0x118, 0x78, 0); + break; + case 11: + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(0x840), 0, false, false, 0, "Message", 0x118, 0x78, 0); + break; + case 14: + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(0x841), 0, false, false, 0, "Message", 0x118, 0x78, 0); + g_windowMgr.CloseWindow(209); + this->ready = 0; + break; + } + + std::string text("["); + text += this->current->displayName; + text += "]"; + text += LookupMessage(0x842); + g_windowMgr.SendNotice(1, reinterpret_cast(text.c_str()), 0xFF, 0, 0, 0); + this->current = nullptr; +} + // OFFSET: 0x00BA28B0 // FUNCTION: fn_19669 void CEntryQueueMgr::ResetCurrent(int unused) { @@ -124,6 +216,52 @@ void CEntryQueueMgr::ResetCurrent(int unused) { void CEntryQueueMgr::IgnorePacket(const unsigned char* packet) { } +// OFFSET: 0x00BA28D0 +// FUNCTION: fn_19671 +void CEntryQueueMgr::OnStatus(const EntryQueueStatus* packet) { + this->ready = 1; + UIWindow* window = g_windowMgr.LookupWindow(209); + if (!window && !g_windowMgr.CloseWindow(209)) { + window = g_windowMgr.EnsureWindow(209); + } + + if (!this->current) { + for (auto it = g_entryQueueList.begin(); it != g_entryQueueList.end(); ++it) { + if (std::string(it->second->name) == std::string(packet->queueName)) { + this->current = it->second; + break; + } + } + } + + if (window && this->current) { + static_cast(window)->SetInfo( + packet->queueName, this->current->unknown_0210 + this->current->unknown_020C, packet->ranking + ); + } + + g_windowMgr.CloseWindow(157); +} + +// OFFSET: 0x00BA2C70 +// FUNCTION: fn_19672 +void CEntryQueueMgr::OnReady(const EntryQueueReady* packet) { + strcpy_s(this->queueName.text, sizeof(this->queueName.text), packet->queueName); + strcpy_s(this->characterName.text, sizeof(this->characterName.text), packet->characterName); + if (g_windowMgr.CloseWindow(210)) { + return; + } + + g_windowMgr.EnsureWindow(210); + g_soundMgr->PlayWave("se_btg_ready.wav", 0.0f, 0.0f, 0.0f, 250, 40, 1.0f, 0); + + std::string text("["); + text += this->current->displayName; + text += "]"; + text += LookupMessage(0x843); + g_windowMgr.SendNotice(1, reinterpret_cast(text.c_str()), 0x4763FF, 0, 0, 0); +} + // OFFSET: 0x00BA2E50 // FUNCTION: fn_19673 void CEntryQueueMgr::OnResultNotice(const EntryQueueNotice* notice) { diff --git a/Source/Contents/EntryQueueMgr.h b/Source/Contents/EntryQueueMgr.h index cfb69ef1..a4309f13 100644 --- a/Source/Contents/EntryQueueMgr.h +++ b/Source/Contents/EntryQueueMgr.h @@ -39,6 +39,26 @@ struct EntryQueueNotice { /* 0002 */ std::uint8_t result; }; +#pragma pack(push, 1) +struct EntryQueueApplyResult { + /* 0000 */ std::uint16_t id; + /* 0002 */ std::uint8_t result; + /* 0003 */ char queueName[24]; +}; + +struct EntryQueueStatus { + /* 0000 */ std::uint16_t id; + /* 0002 */ char queueName[24]; + /* 001A */ int ranking; +}; + +struct EntryQueueReady { + /* 0000 */ std::uint16_t id; + /* 0002 */ char queueName[24]; + /* 001A */ char characterName[24]; +}; +#pragma pack(pop) + class CEntryQueueMgr { public: virtual ~CEntryQueueMgr(); @@ -49,8 +69,12 @@ public: void SendRankingRequest(); void SetQueueName(const EntryQueueName& name); void SetCharacterName(const EntryQueueName& name); + void OnApplyResult(const EntryQueueApplyResult* packet); + void OnCancelResult(const EntryQueueNotice* notice); void ResetCurrent(int unused); void IgnorePacket(const unsigned char* packet); + void OnStatus(const EntryQueueStatus* packet); + void OnReady(const EntryQueueReady* packet); void OnResultNotice(const EntryQueueNotice* notice); void OnNotify(const EntryQueueNotice* notice); @@ -67,6 +91,8 @@ void DestroyEntryQueueMgr(); #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(EntryQueueInfo) == 0x738); +static_assert(offsetof(EntryQueueStatus, ranking) == 0x1A); +static_assert(sizeof(EntryQueueReady) == 0x32); static_assert(offsetof(EntryQueueInfo, unknown_020C) == 0x20C); static_assert(offsetof(EntryQueueInfo, unknown_021C) == 0x21C); static_assert(offsetof(EntryQueueInfo, unknown_0634) == 0x634); diff --git a/Source/UI/Window/UIWindowMgr.h b/Source/UI/Window/UIWindowMgr.h index 3b6512a0..cc95fea9 100644 --- a/Source/UI/Window/UIWindowMgr.h +++ b/Source/UI/Window/UIWindowMgr.h @@ -461,7 +461,7 @@ public: void ForgetWindowReferences(UIWindow* removed); void DismissTransient(); void ClearWindow01B8(); - void CloseWindow(int id); + bool CloseWindow(int id); void CloseWindowExcept251(int id); void RecordWindowPacket(int argument); void Nullsub370();