rodecomp/Source/Contents/Emblems/EmblemDataMgr.cpp
ragnarok-clanker a00597cea9 Maintenance: CRYPT_NAME pass 2 (replaces returned 17152 and 17203): CryptName.h builds the text with consteval + index_sequence so a
Batch #17228 by ragnarok-clanker: no function's compiled code changes; checked with 46 compiled unit(s), including every includer of Source/Utility/Cipher/CryptName.h.
2026-11-11 15:28:55 +00:00

97 lines
2.8 KiB
C++

#include "Contents/UserData/AccountService.h"
#include "Contents/Async/AsyncWorkMgr.h"
#include "Contents/Emblems/EmblemDataMgr.h"
#include "Client/Session/Session.h"
#include "Network/Connection/Connection.h"
#include "Utility/Cipher/CryptName.h"
#include "Utility/Cipher/EncryptedName.h"
#include <cstddef>
#include <cstdint>
#include <new>
extern template std::string& std::string::assign(const char*, std::string::size_type);
// STATIC: 0x013898D4
// GLOBAL: gl_24355
CEmblemDataMgr* g_emblemDataMgr;
// INLINED
CEmblemDataMgr::CEmblemDataMgr() : m_enabled(true), m_uploading(false) {
}
// INLINED
CEmblemDataMgr::~CEmblemDataMgr() = default;
// OFFSET: 0x005EB150
// FUNCTION: fn_03970
bool CEmblemDataMgr::Initialize() {
if (g_emblemDataMgr) {
return false;
}
g_emblemDataMgr = new (std::nothrow) CEmblemDataMgr;
if (!g_emblemDataMgr) {
return false;
}
if (!g_emblemDataMgr->m_enabled) {
delete g_emblemDataMgr;
g_emblemDataMgr = nullptr;
return false;
}
return true;
}
// OFFSET: 0x005EB240
// FUNCTION: fn_03971
void CEmblemDataMgr::Shutdown() {
if (g_emblemDataMgr) {
delete g_emblemDataMgr;
g_emblemDataMgr = nullptr;
}
}
// OFFSET: 0x005EB580
// FUNCTION: fn_03974
void CEmblemDataMgr::RefreshUrls(LuaScript& settings, LuaScript& tables, const char* host, const char* port, const char* overrideKey) {
const std::string base = ResolveAccountServiceBase(settings, tables, host, port, overrideKey);
if (!base.empty()) {
{
constexpr std::array<std::uint8_t, 15> sourceArray = CRYPT_NAME("/emblem/upload", 0x2FF3C5036D070127ULL);
const std::uint8_t (&source)[15] = sourceArray._Elems;
thread_local EncryptedName<sizeof(source), 0x2FF3C5036D070127ULL> name(source);
this->m_uploadUrl = base + name.Text();
}
{
const std::uint8_t source[] = {0xEA, 0xA8, 0xEA, 0x97, 0xCD, 0xC6, 0x8A, 0xBC, 0xA1, 0xA2, 0xF0, 0x9B, 0xCD, 0xCC, 0x86, 0xF7, 0xC5};
thread_local EncryptedName<sizeof(source), 0x93E7A3A1F587CDC5ULL> name(source);
this->m_downloadUrl = base + name.Text();
}
}
}
// OFFSET: 0x005EB260
// FUNCTION: fn_03972
void CEmblemDataMgr::Download(std::uint32_t guildId, std::uint32_t version) {
const std::string token(reinterpret_cast<const char*>(&g_session.webServiceLoginData[0x08]), 16);
g_asyncWorkMgr->DownloadEmblem(this->m_downloadUrl, g_session.m_aid, token, g_session.m_accountName, guildId, version);
}
// OFFSET: 0x005EB410
// FUNCTION: fn_03973
bool CEmblemDataMgr::Upload(std::uint32_t guildId, std::string path) {
if (this->m_uploading == true) {
return false;
}
std::string token;
token.assign(reinterpret_cast<const char*>(&g_session.webServiceLoginData[0x08]), 16);
g_asyncWorkMgr->UploadEmblem(this->m_uploadUrl, g_session.m_aid, token, g_session.m_accountName, guildId, path);
return true;
}