diff --git a/Source/Contents/Async/AsyncWorkMgr.cpp b/Source/Contents/Async/AsyncWorkMgr.cpp index a0ae03cf..7177b5ca 100644 --- a/Source/Contents/Async/AsyncWorkMgr.cpp +++ b/Source/Contents/Async/AsyncWorkMgr.cpp @@ -148,14 +148,11 @@ void CAsyncWorkMgr::DownloadEmblem( // OFFSET: 0x00574570 // FUNCTION: fn_02505 -void CAsyncWorkMgr::UploadEmblem( - std::string url, std::uint32_t accountId, std::string token, std::string world, std::uint32_t guildId, std::string path, CEmblemDataMgr& owner, - EmblemUploadContext& context -) { +void CAsyncWorkMgr::UploadEmblem(std::string url, std::uint32_t accountId, std::string token, std::string world, std::uint32_t guildId, std::string path) { NAsyncWorkPtr work(this->m_pools, "Emblem_Upload"); if (work.Get()) { - static_cast(work.Get())->Bind(url, accountId, token, world, guildId, path, owner, context); + static_cast(work.Get())->Bind(url, accountId, token, world, guildId, path); this->Submit(work); } } diff --git a/Source/Contents/Async/AsyncWorkMgr.h b/Source/Contents/Async/AsyncWorkMgr.h index 0c18b927..4454fe23 100644 --- a/Source/Contents/Async/AsyncWorkMgr.h +++ b/Source/Contents/Async/AsyncWorkMgr.h @@ -11,7 +11,6 @@ class CMCStoreInfoBackup; #include "UI/Window/WindowManagerWindows.h" struct AccountConfigLoad; struct CharacterConfigLoad; -struct EmblemUploadContext; struct StoreBackupContext; struct RegisterPartyContext; struct StopRecruitingContext; @@ -36,10 +35,7 @@ public: void DownloadEmblem( std::string url, std::uint32_t accountId, std::string token, std::string world, std::uint32_t guildId, std::uint32_t version, CConnection& connection ); - void UploadEmblem( - std::string url, std::uint32_t accountId, std::string token, std::string world, std::uint32_t guildId, std::string path, CEmblemDataMgr& owner, - EmblemUploadContext& context - ); + void UploadEmblem(std::string url, std::uint32_t accountId, std::string token, std::string world, std::uint32_t guildId, std::string path); void LoadMyParty(std::uint32_t accountId, std::uint32_t characterId, std::string world, std::string url, std::string token, WindowManagerWindows& windows); void LoadPartyInfo( std::uint32_t accountId, std::uint32_t characterId, std::string world, std::string url, std::string token, std::uint32_t queryAccountId, diff --git a/Source/Contents/Emblems/EmblemDataMgr.cpp b/Source/Contents/Emblems/EmblemDataMgr.cpp index 9b176009..c84de911 100644 --- a/Source/Contents/Emblems/EmblemDataMgr.cpp +++ b/Source/Contents/Emblems/EmblemDataMgr.cpp @@ -1,6 +1,7 @@ #include "Contents/UserData/AccountService.h" #include "Contents/Async/AsyncWorkMgr.h" #include "Contents/Emblems/EmblemDataMgr.h" +#include "Client/Session.h" #include @@ -69,16 +70,13 @@ void CEmblemDataMgr::Download( // OFFSET: 0x005EB410 // FUNCTION: fn_03973 -bool CEmblemDataMgr::Upload( - std::uint32_t guildId, std::string path, std::uint32_t accountId, const std::string& accountName, const char* token16, EmblemUploadContext& context, - CAsyncWorkMgr& manager -) { +bool CEmblemDataMgr::Upload(std::uint32_t guildId, std::string path) { if (this->m_uploading) { return false; } - const std::string token(token16, 16); - manager.UploadEmblem(this->m_uploadUrl, accountId, token, accountName, guildId, path, *this, context); + const std::string token(reinterpret_cast(&g_session.unknown_807C[0x08]), 16); + g_asyncWorkMgr->UploadEmblem(this->m_uploadUrl, g_session.m_aid, token, g_session.m_accountName, guildId, path); return true; } diff --git a/Source/Contents/Emblems/EmblemDataMgr.h b/Source/Contents/Emblems/EmblemDataMgr.h index 404c9897..c4954df0 100644 --- a/Source/Contents/Emblems/EmblemDataMgr.h +++ b/Source/Contents/Emblems/EmblemDataMgr.h @@ -8,7 +8,6 @@ class LuaScript; class CConnection; class CAsyncWorkMgr; struct AsyncDiagnostic; -struct EmblemUploadContext; class CEmblemDataMgr { public: @@ -21,11 +20,8 @@ public: std::uint32_t guildId, std::uint32_t version, std::uint32_t accountId, const std::string& accountName, const char* token16, CConnection& connection, CAsyncWorkMgr& manager ); - bool Upload( - std::uint32_t guildId, std::string path, std::uint32_t accountId, const std::string& accountName, const char* token16, EmblemUploadContext& context, - CAsyncWorkMgr& manager - ); - void CompleteUpload(AsyncDiagnostic diagnostic, std::string response, std::uint32_t guildId, EmblemUploadContext& context); + bool Upload(std::uint32_t guildId, std::string path); + void CompleteUpload(AsyncDiagnostic diagnostic, std::string response, std::uint32_t guildId); protected: /* 0004 */ bool m_enabled; diff --git a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp index a82ae4e0..6cd41d7d 100644 --- a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp +++ b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp @@ -20,7 +20,7 @@ namespace { // OFFSET: 0x005EBF50 // FUNCTION: fn_03978 CEmblemDataUploadAsyncWork::CEmblemDataUploadAsyncWork() - : NAsyncWork("Emblem_Upload"), m_accountId(0), m_guildId(0), m_diagnostic(Diagnostic(false, "unknwon", 27)), m_owner(nullptr), m_context(nullptr) { + : NAsyncWork("Emblem_Upload"), m_accountId(0), m_guildId(0), m_diagnostic(Diagnostic(false, "unknwon", 27)) { } // INLINED @@ -33,10 +33,7 @@ void CEmblemDataUploadAsyncWork::Reset() { // OFFSET: 0x005EC450 // FUNCTION: fn_03980 -void CEmblemDataUploadAsyncWork::Bind( - std::string url, std::uint32_t accountId, std::string token, std::string accountName, std::uint32_t guildId, std::string path, CEmblemDataMgr& owner, - EmblemUploadContext& context -) { +void CEmblemDataUploadAsyncWork::Bind(std::string url, std::uint32_t accountId, std::string token, std::string accountName, std::uint32_t guildId, std::string path) { this->m_group = timeGetTime(); this->m_key = 0; this->m_url = url; @@ -47,8 +44,6 @@ void CEmblemDataUploadAsyncWork::Bind( this->m_path = path; AsyncDiagnostic diagnostic = Diagnostic(false, "unknwon", 54); this->m_diagnostic.MoveFrom(diagnostic); - this->m_owner = &owner; - this->m_context = &context; } // OFFSET: 0x005EC7C0 @@ -89,5 +84,5 @@ bool CEmblemDataUploadAsyncWork::Execute() { // OFFSET: 0x005EC700 // FUNCTION: fn_03982 void CEmblemDataUploadAsyncWork::Complete() { - this->m_owner->CompleteUpload(this->m_diagnostic, this->m_response, this->m_guildId, *this->m_context); + g_emblemDataMgr->CompleteUpload(this->m_diagnostic, this->m_response, this->m_guildId); } diff --git a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.h b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.h index 84801f84..208b41ac 100644 --- a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.h +++ b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.h @@ -4,8 +4,6 @@ #include "Utility/Async/AsyncDiagnostic.h" #include "Utility/Async/NAsyncWork.h" -class CEmblemDataMgr; -struct EmblemUploadContext; class CEmblemDataUploadAsyncWork : public NAsyncWork { public: @@ -14,10 +12,7 @@ public: void Reset() override; bool Execute() override; void Complete() override; - void Bind( - std::string url, std::uint32_t accountId, std::string token, std::string accountName, std::uint32_t guildId, std::string path, CEmblemDataMgr& owner, - EmblemUploadContext& context - ); + void Bind(std::string url, std::uint32_t accountId, std::string token, std::string accountName, std::uint32_t guildId, std::string path); protected: /* 0028 */ std::string m_url; @@ -28,12 +23,10 @@ protected: /* 0078 */ std::string m_path; /* 0090 */ std::string m_response; /* 00A8 */ AsyncDiagnostic m_diagnostic; - CEmblemDataMgr* m_owner; - EmblemUploadContext* m_context; }; #if defined(_WIN32) && !defined(_WIN64) -static_assert(sizeof(CEmblemDataUploadAsyncWork) == 232); +static_assert(sizeof(CEmblemDataUploadAsyncWork) == 0xE0); #endif #endif diff --git a/Source/Contents/Emblems/EmblemUpload.cpp b/Source/Contents/Emblems/EmblemUpload.cpp index afce5231..7eb2add5 100644 --- a/Source/Contents/Emblems/EmblemUpload.cpp +++ b/Source/Contents/Emblems/EmblemUpload.cpp @@ -1,9 +1,9 @@ #include "Contents/Emblems/EmblemDataMgr.h" -#include "Contents/Emblems/EmblemUpload.h" #include "Contents/MessageTable.h" #include "Network/Connection/Connection.h" #include "Network/Packets/PacketLengths.h" #include "UI/Window/WindowDialogs.h" +#include "UI/Window/UIWindowMgr.h" #include "Utility/Async/AsyncDiagnostic.h" #include @@ -22,7 +22,7 @@ namespace { // OFFSET: 0x005EBAD0 // FUNCTION: fn_03976 -void CEmblemDataMgr::CompleteUpload(AsyncDiagnostic diagnostic, std::string response, std::uint32_t guildId, EmblemUploadContext& context) { +void CEmblemDataMgr::CompleteUpload(AsyncDiagnostic diagnostic, std::string response, std::uint32_t guildId) { if (!diagnostic.success) { return; } @@ -38,14 +38,14 @@ void CEmblemDataMgr::CompleteUpload(AsyncDiagnostic diagnostic, std::string resp switch (root["Type"].asInt()) { case 1: { EmblemVersionPacket packet{0x0B46, guildId, root["version"].asInt()}; - context.connection.Send(context.lengths.FixedLength(packet.id), &packet); + GetRagConnection().Send(g_packetLengths.FixedLength(packet.id), &packet); break; } case 2: case 3: case 4: { const char* message = LookupMessage(3586); - context.dialogs.Confirm(message, 0, true, false, 0, "Message", 280, 120, 0); + reinterpret_cast(&g_windowMgr)->Confirm(message, 0, true, false, 0, "Message", 280, 120, 0); break; } default: diff --git a/Source/UI/Guild/UIGuildWnd.cpp b/Source/UI/Guild/UIGuildWnd.cpp index 6d0c1e6b..2d50ceef 100644 --- a/Source/UI/Guild/UIGuildWnd.cpp +++ b/Source/UI/Guild/UIGuildWnd.cpp @@ -3018,3 +3018,191 @@ void UIGuildPositionManageWnd::Slot15(int, int) { this->UpdateScroll(); } + +// OFFSET: 0x00961880 +// FUNCTION: fn_13127 +int UIGuildInfoManageWnd::SendMsg(UIWindow* sender, int message, std::intptr_t a1, std::intptr_t a2, std::intptr_t a3, std::intptr_t a4) { + switch (message) { + case 48: { + CMode* gameMode = g_modeMgr.GetGameMode(); + if (this->unknown_00E0[a1].id != 27) { + break; + } + + if (this->m_allyRow != -1) { + int row = 0; + for (std::list::iterator it = g_guildInfo.unknown_00E4.begin(); it != g_guildInfo.unknown_00E4.end(); ++it) { + if (row >= 3) { + break; + } + if (it->unknown_0004 == 0) { + if (row == this->m_allyRow) { + if (it->unknown_0000 != 0) { + gameMode->SendMsg(127, it->unknown_0000, 0, 0, 0); + } + return 0; + } + ++row; + } + } + } else if (this->m_hostileRow != -1) { + int row = 0; + for (std::list::iterator it = g_guildInfo.unknown_00E4.begin(); it != g_guildInfo.unknown_00E4.end(); ++it) { + if (row >= 3) { + break; + } + if (it->unknown_0004 == 1) { + if (row == this->m_hostileRow) { + if (it->unknown_0000 != 0) { + gameMode->SendMsg(127, it->unknown_0000, 1, 0, 0); + } + return 0; + } + ++row; + } + } + } + break; + } + case 49: + this->unknown_00E0.erase(this->unknown_00E0.begin(), this->unknown_00E0.end()); + if (g_windowMgr.unknown_0210 != 0) { + this->m_frameContext->windows.CloseWindow(18); + } + if (g_guildInfo.unknown_00B4 != 0) { + this->unknown_00E0.push_back(GuildWndNameEntry{LookupMessage(351), 27}); + } + if (!this->unknown_00E0.empty()) { + UIWindow* menu = this->m_frameContext->windows.EnsureWindow(18); + for (std::size_t index = 0; index < this->unknown_00E0.size(); ++index) { + menu->SendMsg(nullptr, 31, reinterpret_cast(this->unknown_00E0[index].name.c_str()), 0, 0, 0); + } + menu->SendMsg(nullptr, 83, 60, 0, 0, 0); + menu->SendMsg(nullptr, 30, 0, 0, 0, 0); + + int x = std::max(1, g_mouse.x + 1); + int maxX = g_renderer->viewport.width - menu->geometry.width; + if (x > maxX) { + x = maxX; + } + int y = std::max(1, g_mouse.y + 1); + int maxY = g_renderer->viewport.height - menu->geometry.height; + if (y > maxY) { + y = maxY; + } + menu->Move(x, y); + return 0; + } + break; + case 6: + switch (a1) { + case 201: + this->m_frameContext->windows.CloseWindow(59); + return 0; + case 278: { + if (g_windowMgr.unknown_0214 != 0) { + this->m_frameContext->windows.CloseWindow(26); + } + this->unknown_00D8.clear(); + char directory[256]; + std::sprintf(directory, "%s\\emblem\\", g_applicationDirectory); + EnumerateFileNames(this->unknown_00D8, directory, "*.bmp"); + EnumerateFileNames(this->unknown_00D8, directory, "*.gif"); + const int count = static_cast(this->unknown_00D8.size()); + if (count == 0) { + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(3037), 0, true, false, 0, "Caution", 280, 120, 0); + return 0; + } + + UIWindow* menu = this->m_frameContext->windows.EnsureWindow(26); + for (std::list::iterator it = this->unknown_00D8.begin(); it != this->unknown_00D8.end(); ++it) { + menu->SendMsg(nullptr, 31, reinterpret_cast(it->c_str()), 0, 0, 0); + } + menu->SendMsg(nullptr, 40, 0, 0, 0, 0); + menu->Resize(160, std::min(count * 16, 160)); + menu->SendMsg(nullptr, 83, 60, 0, 0, 0); + int x = this->geometry.width - 163; + int y = 86; + this->ToScreen(x, y); + menu->Move(x + 1, y + 1); + return 0; + } + case 449: + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(2564), 0, false, false, 0, "Message", 280, 120, 0); + this->m_frameContext->windows.EnsureWindow(215); + return 0; + } + break; + case 13: + break; + case 39: { + if (this->unknown_00D8.size() == 0) { + break; + } + + std::string name; + int index = 0; + for (std::list::iterator it = this->unknown_00D8.begin(); it != this->unknown_00D8.end(); ++it) { + if (a1 == index) { + name = it->c_str(); + break; + } + ++index; + } + + if (name.size() != 0) { + std::string path = FormatOwnedString("..\\..\\emblem\\%s", name.c_str()); + CBitmapRes* bitmap = static_cast(ResourceMgr::Instance().Load(Resolve(path.c_str()))); + if (!bitmap) { + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(3587), 0, true, false, 0, "Message", 280, 120, 0); + return 0; + } + + if (bitmap->image.width == 24 && bitmap->image.height == 24) { + CFile file; + if (file.Open(FormatOwnedString("..\\emblem\\%s", name.c_str()).c_str(), 0, true, false) == true) { + if (g_guildMgr->m_timeout < file.GetSize()) { + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(3587), 0, true, false, 0, "Message", 280, 120, 0); + } else { + std::string uploadPath = FormatOwnedString("emblem\\%s", name.c_str()); + if (!g_emblemDataMgr->Upload(this->m_guildId, uploadPath)) { + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(3586), 0, true, false, 0, "Message", 280, 120, 0); + } + } + } + } else { + reinterpret_cast(&g_windowMgr)->Confirm(LookupMessage(3587), 0, true, false, 0, "Message", 280, 120, 0); + } + } + return 0; + } + case 60: + this->m_guildId = g_guildInfo.m_guildId; + if (g_guildInfo.unknown_00B4 != 0) { + this->m_editButton->Move(this->geometry.width - this->m_editButton->geometry.width - 8, 69); + this->m_disbandButton->Move(this->geometry.width - this->m_disbandButton->geometry.width - 15, this->geometry.height - this->m_disbandButton->geometry.height - 5); + } else { + this->m_editButton->Move(-200, -200); + this->m_disbandButton->Move(-200, -200); + } + this->RefreshAgitList(); + this->InvalidateChildren(); + return 0; + case 162: + if (this->m_agitMenu) { + this->m_agitMenu->Move(a1, a2); + this->m_agitMenu->Show(1); + this->m_agitMenu->m_agitIndex = this->m_agitList->selected; + this->Invalidate(); + return 0; + } + break; + case 163: + this->HideAgitMenu(); + break; + default: + return UIGuildWnd::SendMsg(sender, message, a1, a2, a3, a4); + } + + return 0; +} diff --git a/Source/UI/Guild/UIGuildWnd.h b/Source/UI/Guild/UIGuildWnd.h index c2d96dba..cc72a032 100644 --- a/Source/UI/Guild/UIGuildWnd.h +++ b/Source/UI/Guild/UIGuildWnd.h @@ -3,11 +3,15 @@ #include "UI/Window/UIFrameWnd.h" +#include "Client/Application/Launcher.h" #include "Client/Input/Mouse.h" +#include "Contents/Emblems/EmblemDataMgr.h" #include "Contents/ForbiddenWords.h" #include "Contents/GuildInfo.h" #include "Contents/PlayerNameDictionary.h" #include "Contents/Skills/SkillInfo.h" +#include "File/File.h" +#include "File/FileEnumeration.h" #include "Render/DeviceContext/DeviceContext.h" #include "Render/Renderer.h" #include "Render/Textures/SpriteAtlas.h" @@ -110,6 +114,7 @@ public: void Slot25(int x, int y) override; void Slot32(int x, int y) override; void Slot33(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; protected: void RefreshAgitList();