rodecomp/Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.cpp
ragnarok-clanker 70ab69724e Decompile fn_03447 (CAccountLinkedUserDataLoadAsyncWork::Complete)
Batch #17164 by eAthena: 0 byte-identical, 1 confirmed by peer review.

- fn_03447 CAccountLinkedUserDataLoadAsyncWork::Complete: logic confirmed by peer review

Peer-reviewed-by: alisonrag, kyoshi, br4yan
Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
2026-11-11 14:51:03 +00:00

106 lines
3.9 KiB
C++

#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"
#include "Utility/Text/FormatString.h"
#include "Utility/Cipher/LocalEncryptedName.h"
#include "Utility/Cipher/CryptName.h"
#include <array>
#include <cstdio>
#include <windows.h>
#include <timeapi.h>
extern template std::string& std::string::assign(const char*, std::string::size_type);
namespace {
constexpr char sourceFile[] = "C:"
"\\repositories\\RagnarokClient\\RagnarokClient\\Contents\\AccountLinkedUserData\\CAcco"
"untLinkedUserDataLoadAsyncWork.cpp";
// INLINED
__forceinline AsyncDiagnostic Diagnostic(bool success, const char* text, std::uint32_t line) {
std::string message = text;
return AsyncDiagnostic(&success, &message, sourceFile, &line);
}
// INLINED
template <std::uint64_t Key, std::size_t Length>
const char* DecryptName(const std::uint8_t (&source)[Length]) {
thread_local EncryptedName<Length, Key> name(source);
return name.Text();
}
// INLINED
template <std::uint64_t Key, std::size_t Length>
const char* DecryptName(const std::array<std::uint8_t, Length>& source) {
thread_local EncryptedName<Length, Key> name(source);
return name.Text();
}
}
// OFFSET: 0x005B9E50
// FUNCTION: fn_03440
CAccountLinkedUserDataLoadAsyncWork::CAccountLinkedUserDataLoadAsyncWork()
: NAsyncWork("AccountLinkedUserData_Load"), m_accountId(0),
m_diagnostic(false, std::string(DecryptName<0x59278F63D79F3DA1ULL>({0xD4, 0x53, 0xF4, 0xB9, 0x14, 0xE0, 0x49, 0x59})), sourceFile, 26) {
}
// INLINED
CAccountLinkedUserDataLoadAsyncWork::~CAccountLinkedUserDataLoadAsyncWork() = default;
// OFFSET: 0x005BA820
// FUNCTION: fn_03446
void CAccountLinkedUserDataLoadAsyncWork::Reset() {
}
// OFFSET: 0x005BA5D0
// FUNCTION: fn_03445
void CAccountLinkedUserDataLoadAsyncWork::Bind(std::uint32_t accountId, std::string accountName, std::string url) {
this->m_group = timeGetTime();
this->m_accountId = accountId;
this->m_key = 0;
this->m_accountName = accountName;
this->m_url = url;
this->m_response = "";
const std::uint8_t diagnosticSource[] = {0xC2, 0x69, 0x3C, 0xA3, 0x5C, 0x88, 0x45, 0x81};
AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0x812BE72BCD5707B7ULL>(diagnosticSource), 50);
this->m_diagnostic.MoveFrom(diagnostic);
}
// OFFSET: 0x005BA910
// FUNCTION: fn_03449
bool CAccountLinkedUserDataLoadAsyncWork::Execute() {
char accountId[64] = {};
StringFormat(accountId, sizeof(accountId), _TRUNCATE, "%lu", this->m_accountId);
std::string name = CCURLMgr::GetInstance()->ToUtf8(this->m_accountName);
CCURLPostHander handler(this->m_url);
constexpr std::array<std::uint8_t, 4> aid = CRYPT_NAME("AID", 0xC52FB5FBB94FF917ULL);
handler.AddField(DecryptName<0xC52FB5FBB94FF917ULL>(aid), accountId, 4);
constexpr std::array<std::uint8_t, 10> worldName = CRYPT_NAME("WorldName", 0x93E7A3A1F587CDC5ULL);
handler.AddField(DecryptName<0x93E7A3A1F587CDC5ULL>(worldName), name, 4);
if (handler.Perform() == 0) {
this->m_response = handler.Response();
constexpr std::array<std::uint8_t, 5> good = CRYPT_NAME("good", 0x2FF3C5036D070127ULL);
AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x2FF3C5036D070127ULL>(good), 92);
this->m_diagnostic.MoveFrom(diagnostic);
}
return false;
}
// OFFSET: 0x005BA830
// FUNCTION: fn_03447
void CAccountLinkedUserDataLoadAsyncWork::Complete() {
CAccountLinkedUserDataMgr* manager = g_accountLinkedUserDataMgr;
manager->CompleteLoad(
this->m_diagnostic, this->m_accountId, this->m_accountName, this->m_response
);
}
template void std::deque<CAccountLinkedUserDataLoadAsyncWork*>::push_back(CAccountLinkedUserDataLoadAsyncWork*&&);