diff --git a/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp b/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp index c281fa193..c2cdc9823 100644 --- a/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp +++ b/Source/Contents/Emblems/EmblemDataDownloadAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/Emblems/EmblemDataDownloadAsyncWork.h" #include "Contents/Emblems/EmblemDataMgr.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -97,7 +98,7 @@ bool CEmblemDataDownloadAsyncWork::Execute() { StringFormat(guild, sizeof(guild), _TRUNCATE, "%lu", this->m_guildId); char version[10] = {}; StringFormat(version, sizeof(version), _TRUNCATE, "%lu", this->m_version); - std::string name = ToUtf8(this->m_accountName); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName); CCURLPostHander handler(this->m_url); handler.AddField(DecryptName<0x59278F63D79F3DA1ULL>({0xE0, 0x74, 0xDB, 0xD7}), account, 4); diff --git a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp index acfa91c2c..536dcbbca 100644 --- a/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp +++ b/Source/Contents/Emblems/EmblemDataUploadAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/Emblems/EmblemDataMgr.h" #include "Contents/Emblems/EmblemDataUploadAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -13,9 +14,10 @@ namespace { constexpr char sourceFile[] = "C:\\repositories\\RagnarokClient\\RagnarokClient\\Contents\\Emblem\\CEmblemDataUploadAsyncWork.cpp"; // INLINED - __forceinline AsyncDiagnostic Diagnostic(bool success, const char* text, std::uint32_t line) { + __forceinline void Report(AsyncDiagnostic& target, bool success, const char* text, std::uint32_t line) { std::string message = text; - return AsyncDiagnostic(&success, &message, sourceFile, &line); + AsyncDiagnostic diagnostic(&success, &message, sourceFile, &line); + target.MoveFrom(diagnostic); } template @@ -89,18 +91,19 @@ void CEmblemDataUploadAsyncWork::Bind(std::string url, std::uint32_t accountId, // OFFSET: 0x005EC7C0 // FUNCTION: fn_03983 bool CEmblemDataUploadAsyncWork::Execute() { - char account[64] = {}, guild[64] = {}; + char account[64] = {}; StringFormat(account, sizeof(account), _TRUNCATE, "%lu", this->m_accountId); + char guild[64] = {}; StringFormat(guild, sizeof(guild), _TRUNCATE, "%lu", this->m_guildId); - std::string name = ToUtf8(this->m_accountName); - std::string path = ToUtf8(this->m_path); + std::string name = g_curlMgr->ToUtf8(this->m_accountName); + std::string path = g_curlMgr->ToUtf8(this->m_path); std::string extension = this->m_path.substr(this->m_path.size() - 3, this->m_path.size()); for (char& value : extension) { value = static_cast(std::toupper(static_cast(value))); } - std::string imageType = ToUtf8(extension); + std::string imageType = g_curlMgr->ToUtf8(extension); CCURLPostHander handler(this->m_url); const std::uint8_t aid[] = {0xF6, 0x4E, 0x13, 0xCD}; handler.AddField(DecryptName<0x812BE72BCD5707B7ULL>(aid), account, 4); @@ -116,14 +119,12 @@ bool CEmblemDataUploadAsyncWork::Execute() { handler.AddField(DecryptName<0xD98F03A52D35636DULL>(img), path, 10); if (handler.Perform() == 0) { - this->m_response = FromUtf8(handler.Response()); + this->m_response = g_curlMgr->FromUtf8(handler.Response()); const std::uint8_t good[] = {0x0A, 0x8C, 0x2A, 0xC7, 0xED}; - AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x31D7C1EDA345E36DULL>(good), 100); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, true, DecryptName<0x31D7C1EDA345E36DULL>(good), 100); } else { const std::uint8_t fail[] = {0x6F, 0xC8, 0x2E, 0x33, 0xD9}; - AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0xD3755DD95F47A909ULL>(fail), 109); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, false, DecryptName<0xD3755DD95F47A909ULL>(fail), 109); } return false; diff --git a/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp b/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp index 981663a11..0ec8cc0dc 100644 --- a/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp +++ b/Source/Contents/Party/ChangePartyMasterAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/Party/AdventurerAgencyMgr.h" #include "Contents/Party/ChangePartyMasterAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -18,6 +19,13 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } + // INLINED + __forceinline void Report(AsyncDiagnostic& target, bool success, const char* text, std::uint32_t line) { + std::string message = text; + AsyncDiagnostic diagnostic(&success, &message, sourceFile, &line); + target.MoveFrom(diagnostic); + } + template class EncryptedName { public: @@ -103,9 +111,9 @@ bool CChangePartyMasterAsyncWork::Execute() { StringFormat(targetAccount, sizeof(targetAccount), _TRUNCATE, "%lu", this->m_targetAccountId); char targetCharacter[64] = {}; StringFormat(targetCharacter, sizeof(targetCharacter), _TRUNCATE, "%lu", this->m_targetCharacterId); - std::string world = ToUtf8(this->m_worldName); - std::string name = ToUtf8(this->m_characterName); - std::string targetName = ToUtf8(this->m_targetName); + std::string world = CCURLMgr::GetInstance()->ToUtf8(this->m_worldName); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_characterName); + std::string targetName = CCURLMgr::GetInstance()->ToUtf8(this->m_targetName); CCURLPostHander handler(this->m_url); handler.AddField(DecryptName<0x3375B1C7DBB5FD55ULL>({0x14, 0xB4, 0xF1, 0xDB}), account, 4); handler.AddField(DecryptName<0x1D6D75EDE7CD311FULL>({0x58, 0x78, 0x89, 0xE7}), character, 4); @@ -117,12 +125,10 @@ bool CChangePartyMasterAsyncWork::Execute() { handler.AddField(DecryptName<0x0F0F8B6B8F9D19D1ULL>({0x90, 0x6C, 0xE9, 0xE7, 0x3F, 0xE4, 0x64, 0x6A, 0xBF, 0x19}), this->m_token, 4); if (handler.Perform() != 0) { - AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0x91651D81F559F971ULL>({0x17, 0x98, 0x30, 0x99, 0x81}), 113); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, false, DecryptName<0x91651D81F559F971ULL>({0x17, 0x98, 0x30, 0x99, 0x81}), 113); } else { - this->m_response = FromUtf8(handler.Response()); - AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x73D1674B61DF7B0BULL>({0x78, 0x0E, 0xBC, 0x02, 0x2E, 0x14, 0xA2, 0x73}), 122); - this->m_diagnostic.MoveFrom(diagnostic); + this->m_response = CCURLMgr::GetInstance()->FromUtf8(handler.Response()); + Report(this->m_diagnostic, true, DecryptName<0x73D1674B61DF7B0BULL>({0x78, 0x0E, 0xBC, 0x02, 0x2E, 0x14, 0xA2, 0x73}), 122); } return false; diff --git a/Source/Contents/Party/LoadMyPartyAsyncWork.cpp b/Source/Contents/Party/LoadMyPartyAsyncWork.cpp index 2b44faac1..18d6a19d0 100644 --- a/Source/Contents/Party/LoadMyPartyAsyncWork.cpp +++ b/Source/Contents/Party/LoadMyPartyAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/Party/AdventurerAgencyMgr.h" #include "Contents/Party/LoadMyPartyAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -18,6 +19,13 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } + // INLINED + __forceinline void Report(AsyncDiagnostic& target, bool success, const char* text, std::uint32_t line) { + std::string message = text; + AsyncDiagnostic diagnostic(&success, &message, sourceFile, &line); + target.MoveFrom(diagnostic); + } + template class EncryptedName { public: @@ -96,7 +104,7 @@ bool CLoadMyPartyAsyncWork::Execute() { char character[64] = {}; StringFormat(account, sizeof(account), _TRUNCATE, "%lu", this->m_accountId); StringFormat(character, sizeof(character), _TRUNCATE, "%lu", this->m_characterId); - const std::string world = ToUtf8(this->m_world); + const std::string world = CCURLMgr::GetInstance()->ToUtf8(this->m_world); CCURLPostHander handler(this->m_url); handler.AddField(DecryptName<0x3375B1C7DBB5FD55ULL>({0x14, 0xB4, 0xF1, 0xDB}), account, 4); handler.AddField(DecryptName<0x1D6D75EDE7CD311FULL>({0x58, 0x78, 0x89, 0xE7}), character, 4); @@ -104,12 +112,10 @@ bool CLoadMyPartyAsyncWork::Execute() { handler.AddField(DecryptName<0x812BE72BCD5707B7ULL>({0xF6, 0x72, 0x23, 0xA5, 0x7F, 0x88, 0x40, 0xE4, 0xD9, 0x07}), this->m_token, 4); if (handler.Perform() != 0) { - AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0xD3755DD95F47A909ULL>({0x6F, 0xC8, 0x2E, 0x33, 0xD9}), 92); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, false, DecryptName<0xD3755DD95F47A909ULL>({0x6F, 0xC8, 0x2E, 0x33, 0xD9}), 92); } else { - this->m_response = FromUtf8(handler.Response()); - AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x31D7C1EDA345E36DULL>({0x1E, 0x96, 0x26, 0xC0, 0x88, 0xB2, 0xA4, 0x31}), 101); - this->m_diagnostic.MoveFrom(diagnostic); + this->m_response = CCURLMgr::GetInstance()->FromUtf8(handler.Response()); + Report(this->m_diagnostic, true, DecryptName<0x31D7C1EDA345E36DULL>({0x1E, 0x96, 0x26, 0xC0, 0x88, 0xB2, 0xA4, 0x31}), 101); } return false; diff --git a/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp b/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp index f72039874..6758911d3 100644 --- a/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp +++ b/Source/Contents/Party/LoadPartyInfoAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/Party/AdventurerAgencyMgr.h" #include "Contents/Party/LoadPartyInfoAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -93,7 +94,7 @@ bool CLoadPartyInfoAsyncWork::Execute() { StringFormat(account, sizeof(account), _TRUNCATE, "%lu", this->m_accountId); char character[64] = {}; StringFormat(character, sizeof(character), _TRUNCATE, "%lu", this->m_characterId); - std::string world = ToUtf8(this->m_world); + std::string world = CCURLMgr::GetInstance()->ToUtf8(this->m_world); char query[64] = {}; StringFormat(query, sizeof(query), _TRUNCATE, "%lu", this->m_queryAccountId); CCURLPostHander handler(this->m_url); @@ -104,7 +105,7 @@ bool CLoadPartyInfoAsyncWork::Execute() { handler.AddField(DecryptName<0xD3755DD95F47A909ULL>({0x58, 0xDC, 0x22, 0x2D, 0xA0, 0x1C, 0x3C, 0x97, 0x09}), query, 4); if (handler.Perform() == 0) { - this->m_response = FromUtf8(handler.Response()); + this->m_response = CCURLMgr::GetInstance()->FromUtf8(handler.Response()); AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x31D7C1EDA345E36DULL>({0x1E, 0x96, 0x26, 0xC0, 0x88, 0xB2, 0xA4, 0x31}), 97); this->m_diagnostic.MoveFrom(diagnostic); } diff --git a/Source/Contents/Party/LoadPartyListAsyncWork.cpp b/Source/Contents/Party/LoadPartyListAsyncWork.cpp index 963dd75dc..45a4090cd 100644 --- a/Source/Contents/Party/LoadPartyListAsyncWork.cpp +++ b/Source/Contents/Party/LoadPartyListAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/Party/AdventurerAgencyMgr.h" #include "Contents/Party/LoadPartyListAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -101,7 +102,7 @@ bool CLoadPartyListAsyncWork::Execute() { StringFormat(character, sizeof(character), _TRUNCATE, "%lu", this->m_characterId); char page[10] = {}; StringFormat(page, sizeof(page), _TRUNCATE, "%d", this->m_page); - const std::string world = ToUtf8(this->m_world); + const std::string world = CCURLMgr::GetInstance()->ToUtf8(this->m_world); CCURLPostHander handler(this->m_url); const std::uint8_t gid[] = {0xCE, 0x74, 0x29, 0xE5}; handler.AddField(DecryptName<0x2F2701A7E56D3D89ULL>(gid), character, 4); @@ -160,7 +161,7 @@ bool CLoadPartyListAsyncWork::Execute() { } if (!this->m_filter.memo.empty()) { - std::string memo = ToUtf8(this->m_filter.memo); + std::string memo = CCURLMgr::GetInstance()->ToUtf8(this->m_filter.memo); const std::uint8_t memoName[] = {0xB0, 0x34, 0xD8, 0x36, 0x01}; handler.AddField(DecryptName<0xBD3F430159B551FDULL>(memoName), memo, 4); } @@ -172,7 +173,7 @@ bool CLoadPartyListAsyncWork::Execute() { } if (handler.Perform() == 0) { - this->m_response = FromUtf8(handler.Response()); + this->m_response = CCURLMgr::GetInstance()->FromUtf8(handler.Response()); const std::uint8_t success[] = {0xE4, 0x04, 0xC4, 0xDE, 0x04, 0x50, 0xF0, 0x5B}; AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x5B832361BDA77197ULL>(success), 138); this->m_diagnostic.MoveFrom(diagnostic); diff --git a/Source/Contents/Party/RegisterPartyAsyncWork.cpp b/Source/Contents/Party/RegisterPartyAsyncWork.cpp index dcc7f93f5..eef2e2ced 100644 --- a/Source/Contents/Party/RegisterPartyAsyncWork.cpp +++ b/Source/Contents/Party/RegisterPartyAsyncWork.cpp @@ -1,6 +1,7 @@ #include "Client/Session.h" #include "Contents/Party/AdventurerAgencyMgr.h" #include "Contents/Party/RegisterPartyAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -96,9 +97,9 @@ bool CRegisterPartyAsyncWork::Execute() { StringFormat(maximum, sizeof(maximum), _TRUNCATE, "%d", this->m_info.maximumLevel); char type[10] = {}; StringFormat(type, sizeof(type), _TRUNCATE, "%d", this->m_info.type); - const std::string world = ToUtf8(this->m_world); - const std::string name = ToUtf8(std::string(g_session.DecodePlayerName())); - const std::string memo = ToUtf8(this->m_info.memo); + const std::string world = CCURLMgr::GetInstance()->ToUtf8(this->m_world); + const std::string name = CCURLMgr::GetInstance()->ToUtf8(std::string(g_session.DecodePlayerName())); + const std::string memo = CCURLMgr::GetInstance()->ToUtf8(this->m_info.memo); CCURLPostHander handler(this->m_url); handler.AddField(DecryptName<0x2F2701A7E56D3D89ULL>({0xC8, 0x74, 0x29, 0xE5}), account, 4); handler.AddField(DecryptName<0x6B3301E1A3079125ULL>({0x62, 0xD8, 0x43, 0xA3}), character, 4); @@ -130,7 +131,7 @@ bool CRegisterPartyAsyncWork::Execute() { AsyncDiagnostic diagnostic(false, std::string(DecryptName<0xEB3D4FAB0FC183DBULL>({0xBD, 0xE2, 0xA8, 0x63, 0xAB})), sourceFile, 118); this->m_diagnostic.MoveFrom(diagnostic); } else { - this->m_response = FromUtf8(handler.Response()); + this->m_response = CCURLMgr::GetInstance()->FromUtf8(handler.Response()); AsyncDiagnostic diagnostic(true, std::string(DecryptName<0x8F3F2FA959977F9FULL>({0xEC, 0x0A, 0xF4, 0x3A, 0xCC, 0x5C, 0x4C, 0x8F})), sourceFile, 127); this->m_diagnostic.MoveFrom(diagnostic); } diff --git a/Source/Contents/Party/StopRecruitingAsyncWork.cpp b/Source/Contents/Party/StopRecruitingAsyncWork.cpp index ed0ba0284..ec965cb22 100644 --- a/Source/Contents/Party/StopRecruitingAsyncWork.cpp +++ b/Source/Contents/Party/StopRecruitingAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/Party/AdventurerAgencyMgr.h" #include "Contents/Party/StopRecruitingAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -18,6 +19,13 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } + // INLINED + __forceinline void Report(AsyncDiagnostic& target, bool success, const char* text, std::uint32_t line) { + std::string message = text; + AsyncDiagnostic diagnostic(&success, &message, sourceFile, &line); + target.MoveFrom(diagnostic); + } + template class EncryptedName { public: @@ -91,7 +99,7 @@ bool CStopRecruitingAsyncWork::Execute() { StringFormat(account, sizeof(account), _TRUNCATE, "%lu", this->m_accountId); char master[64] = {}; StringFormat(master, sizeof(master), _TRUNCATE, "%lu", this->m_masterAccountId); - const std::string world = ToUtf8(this->m_world); + const std::string world = CCURLMgr::GetInstance()->ToUtf8(this->m_world); CCURLPostHander handler(this->m_url); handler.AddField(DecryptName<0x050505679903579BULL>({0xDA, 0x1E, 0x47, 0x99}), account, 4); handler.AddField(DecryptName<0xDD3913D5D7F97BE1ULL>({0xB6, 0x14, 0x8B, 0xBB, 0xB1, 0x5D, 0x58, 0xB0, 0x84, 0x7B}), world, 4); @@ -99,12 +107,10 @@ bool CStopRecruitingAsyncWork::Execute() { handler.AddField(DecryptName<0x83EFBFBB37EDBDBDULL>({0xF0, 0xDC, 0x9E, 0x43, 0xDE, 0xCD, 0xAE, 0xCA, 0xF9, 0xBD}), master, 4); if (handler.Perform() != 0) { - AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0x39FF7FB50DEB998FULL>({0xE9, 0xF8, 0x82, 0x61, 0xB5}), 92); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, false, DecryptName<0x39FF7FB50DEB998FULL>({0xE9, 0xF8, 0x82, 0x61, 0xB5}), 92); } else { - this->m_response = FromUtf8(handler.Response()); - AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x2FE993D1DDE1F197ULL>({0xE4, 0x84, 0x82, 0xBE, 0xB4, 0xE0, 0x9A, 0x2F}), 101); - this->m_diagnostic.MoveFrom(diagnostic); + this->m_response = CCURLMgr::GetInstance()->FromUtf8(handler.Response()); + Report(this->m_diagnostic, true, DecryptName<0x2FE993D1DDE1F197ULL>({0xE4, 0x84, 0x82, 0xBE, 0xB4, 0xE0, 0x9A, 0x2F}), 101); } return false; diff --git a/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp b/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp index 62fdb1799..a63cec98d 100644 --- a/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp +++ b/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp @@ -1,6 +1,7 @@ #include "Contents/Store/MCStoreInfoBackup.h" #include "Contents/Store/MCStoreInfoBackupAsyncWork.h" #include "Client/Session.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -115,7 +116,7 @@ bool CMCStoreInfoBackupLoadAsyncWork::Execute() { StringFormat(account, sizeof(account), _TRUNCATE, "%lu", this->m_accountId); char character[64] = {}; StringFormat(character, sizeof(character), _TRUNCATE, "%lu", this->m_characterId); - std::string name = ToUtf8(this->m_accountName); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName); char type[64] = {}; StringFormat(type, sizeof(type), _TRUNCATE, "%d", this->m_type); @@ -190,7 +191,7 @@ bool CMCStoreInfoBackupSaveAsyncWork::Execute() { StringFormat(character, sizeof(character), _TRUNCATE, "%lu", this->m_characterId); char type[64] = {}; StringFormat(type, sizeof(type), _TRUNCATE, "%d", this->m_type); - std::string name = ToUtf8(this->m_accountName); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName); CCURLPostHander handler(this->m_url); const std::array aid = {0x48, 0xE0, 0x03, 0x5F}; diff --git a/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp b/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp index 0c7a9d7f4..5985ba236 100644 --- a/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp +++ b/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/UserData/AccountLinkedUserDataLoadAsyncWork.h" #include "Contents/UserData/AccountLinkedUserDataMgr.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -93,7 +94,7 @@ bool CAccountLinkedUserDataLoadAsyncWork::Execute() { char accountId[64] = {}; StringFormat(accountId, sizeof(accountId), _TRUNCATE, "%lu", this->m_accountId); - std::string name = ToUtf8(this->m_accountName); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName); CCURLPostHander handler(this->m_url); const std::uint8_t aid[] = {0x56, 0xB0, 0x0B, 0xB9}; handler.AddField(DecryptName<0xC52FB5FBB94FF917ULL>(aid), accountId, 4); diff --git a/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp b/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp index 437801609..01eb1262b 100644 --- a/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp +++ b/Source/Contents/UserData/AccountLinkedUserDataSaveAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/UserData/AccountLinkedUserDataMgr.h" #include "Contents/UserData/AccountLinkedUserDataSaveAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -20,6 +21,13 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } + // INLINED + __forceinline void Report(AsyncDiagnostic& target, bool success, const char* text, std::uint32_t line) { + std::string message = text; + AsyncDiagnostic diagnostic(&success, &message, sourceFile, &line); + target.MoveFrom(diagnostic); + } + template class EncryptedName { public: @@ -92,7 +100,7 @@ void CAccountLinkedUserDataSaveAsyncWork::Bind(std::uint32_t accountId, std::str bool CAccountLinkedUserDataSaveAsyncWork::Execute() { char accountId[64] = {}; StringFormat(accountId, sizeof(accountId), _TRUNCATE, "%lu", this->m_accountId); - std::string name = ToUtf8(this->m_accountName); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName); CCURLPostHander handler(this->m_url); const std::uint8_t aid[] = {0x56, 0xB0, 0x0B, 0xB9}; handler.AddField(DecryptName<0xC52FB5FBB94FF917ULL>(aid), accountId, 4); @@ -105,12 +113,10 @@ bool CAccountLinkedUserDataSaveAsyncWork::Execute() { if (handler.Perform() != 0) { const std::uint8_t error[] = {0x17, 0x98, 0x30, 0x99, 0x81}; - AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0x91651D81F559F971ULL>(error), 102); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, false, DecryptName<0x91651D81F559F971ULL>(error), 102); } else { const std::uint8_t good[] = {0x6C, 0x14, 0xB0, 0x05, 0x4B}; - AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x73D1674B61DF7B0BULL>(good), 106); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, true, DecryptName<0x73D1674B61DF7B0BULL>(good), 106); } return false; diff --git a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp index 3464ecf39..96100b2d6 100644 --- a/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp +++ b/Source/Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/UserData/CharacterLinkedUserDataLoadAsyncWork.h" #include "Contents/UserData/CharacterLinkedUserDataMgr.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -98,7 +99,7 @@ bool CCharacterLinkedUserDataLoadAsyncWork::Execute() { char characterId[64] = {}; StringFormat(characterId, sizeof(characterId), _TRUNCATE, "%lu", this->m_characterId); - std::string name = ToUtf8(this->m_accountName); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName); CCURLPostHander handler(this->m_url); handler.AddField(DecryptName<0x1D6D75EDE7CD311FULL>({0x5E, 0x78, 0x89, 0xE7}), accountId, 4); handler.AddField(DecryptName<0x3375B1C7DBB5FD55ULL>({0x12, 0xB4, 0xF1, 0xDB}), characterId, 4); @@ -106,7 +107,7 @@ bool CCharacterLinkedUserDataLoadAsyncWork::Execute() { handler.AddField(DecryptName<0x59278F63D79F3DA1ULL>({0xF6, 0x52, 0xED, 0xBB, 0x07, 0xC1, 0x46, 0x34, 0xC4, 0x3D}), name, 4); if (handler.Perform() == 0) { - this->m_response = FromUtf8(handler.Response()); + this->m_response = CCURLMgr::GetInstance()->FromUtf8(handler.Response()); AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x31D7C1EDA345E36DULL>({0x0A, 0x8C, 0x2A, 0xC7, 0xED}), 103); this->m_diagnostic.MoveFrom(diagnostic); } diff --git a/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp b/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp index a06006daf..5705350f2 100644 --- a/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp +++ b/Source/Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.cpp @@ -1,5 +1,6 @@ #include "Contents/UserData/CharacterLinkedUserDataMgr.h" #include "Contents/UserData/CharacterLinkedUserDataSaveAsyncWork.h" +#include "Network/Http/CURLMgr.h" #include "Network/Http/CURLPostHander.h" #include "Network/TextEncoding.h" #include "Utility/Cipher/XorBytes.h" @@ -20,6 +21,13 @@ namespace { return AsyncDiagnostic(&success, &message, sourceFile, &line); } + // INLINED + __forceinline void Report(AsyncDiagnostic& target, bool success, const char* text, std::uint32_t line) { + std::string message = text; + AsyncDiagnostic diagnostic(&success, &message, sourceFile, &line); + target.MoveFrom(diagnostic); + } + template class EncryptedName { public: @@ -96,8 +104,8 @@ bool CCharacterLinkedUserDataSaveAsyncWork::Execute() { StringFormat(accountId, sizeof(accountId), _TRUNCATE, "%lu", this->m_accountId); char characterId[64] = {}; StringFormat(characterId, sizeof(characterId), _TRUNCATE, "%lu", this->m_characterId); - std::string name = ToUtf8(this->m_accountName); - std::string data = ToUtf8(this->m_data); + std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName); + std::string data = CCURLMgr::GetInstance()->ToUtf8(this->m_data); CCURLPostHander handler(this->m_url); handler.AddField(DecryptName<0x59278F63D79F3DA1ULL>({0xE0, 0x74, 0xDB, 0xD7}), accountId, 4); handler.AddField(DecryptName<0x812BE72BCD5707B7ULL>({0xF0, 0x4E, 0x13, 0xCD}), characterId, 4); @@ -106,11 +114,9 @@ bool CCharacterLinkedUserDataSaveAsyncWork::Execute() { handler.AddField(DecryptName<0xD98F03A52D35636DULL>({0x09, 0x02, 0x41, 0x4C, 0xA5}), data, 4); if (handler.Perform() != 0) { - AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0x0F0F8B6B8F9D19D1ULL>({0xB7, 0x78, 0xF4, 0xE3, 0x6B}), 98); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, false, DecryptName<0x0F0F8B6B8F9D19D1ULL>({0xB7, 0x78, 0xF4, 0xE3, 0x6B}), 98); } else { - AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0xD3755DD95F47A909ULL>({0x6E, 0xC6, 0x28, 0x3B, 0xD9}), 102); - this->m_diagnostic.MoveFrom(diagnostic); + Report(this->m_diagnostic, true, DecryptName<0xD3755DD95F47A909ULL>({0x6E, 0xC6, 0x28, 0x3B, 0xD9}), 102); } return false; diff --git a/Source/Network/Http/CURLMgr.h b/Source/Network/Http/CURLMgr.h index 51f402a3f..9ef001a41 100644 --- a/Source/Network/Http/CURLMgr.h +++ b/Source/Network/Http/CURLMgr.h @@ -2,6 +2,7 @@ #define RAGNAROK_SOURCE_NETWORK_HTTP_CURLMGR_H #include +#include #include struct curl_slist; @@ -13,6 +14,9 @@ public: virtual ~CCURLMgr(); static bool Initialize(); static void Shutdown(); + static CCURLMgr* GetInstance(); + std::string ToUtf8(std::string text); + std::string FromUtf8(std::string text); /* 0004 */ int(__cdecl* globalInit)(long); /* 0008 */ void(__cdecl* globalCleanup)(); @@ -31,6 +35,11 @@ public: extern CCURLMgr* g_curlMgr; +// INLINED +inline CCURLMgr* CCURLMgr::GetInstance() { + return g_curlMgr; +} + #if defined(_WIN32) && !defined(_WIN64) static_assert(sizeof(CCURLMgr) == 56); static_assert(offsetof(CCURLMgr, globalInit) == 0x0004); diff --git a/Source/Network/TextEncoding.cpp b/Source/Network/TextEncoding.cpp index 61aaa6824..51df72686 100644 --- a/Source/Network/TextEncoding.cpp +++ b/Source/Network/TextEncoding.cpp @@ -1,3 +1,4 @@ +#include "Network/Http/CURLMgr.h" #include "Network/TextEncoding.h" #include "Utility/StackAlloc.h" @@ -17,7 +18,7 @@ UINT g_textCodePage; // OFFSET: 0x005E8FE0 // FUNCTION: fn_03951 -std::string ToUtf8(std::string text) { +std::string CCURLMgr::ToUtf8(std::string text) { std::string result; int wideLength = MultiByteToWideChar(g_textCodePage, 0, text.c_str(), lstrlenA(text.c_str()), nullptr, 0); BSTR wide = SysAllocStringLen(nullptr, wideLength); @@ -43,7 +44,7 @@ std::string ToUtf8(std::string text) { // OFFSET: 0x005E9440 // FUNCTION: fn_03954 -std::string FromUtf8(std::string text) { +std::string CCURLMgr::FromUtf8(std::string text) { std::string result; int wideLength = MultiByteToWideChar(CP_UTF8, 0, text.c_str(), lstrlenA(text.c_str()) + 1, nullptr, 0); BSTR wide = SysAllocStringLen(nullptr, wideLength); diff --git a/Source/Network/TextEncoding.h b/Source/Network/TextEncoding.h index 8c58720fc..13d4c9a3b 100644 --- a/Source/Network/TextEncoding.h +++ b/Source/Network/TextEncoding.h @@ -7,9 +7,6 @@ extern UINT g_textCodePage; -std::string ToUtf8(std::string text); -std::string FromUtf8(std::string text); - std::string FromUtf8(const std::string& text, UINT codePage); std::string ToUtf8(const std::string& text, UINT codePage);