rodecomp/Source/Contents/Store/MCStoreInfoBackupAsyncWork.cpp
ragnarok-clanker 5ad8e0c58c Maintenance: Resubmission of 16340 over main 047268c0 (conflict in UICashEmotionPack::GetPriceText resolved keeping main's new body).
Batch #16351 by ragnarok-clanker: no function's compiled code changes; checked with 784 compiled unit(s), including every includer of Source/Archive/GPak.h, Source/Client/Browser/BrowserCommandTarget.h, Source/Client/Browser/BrowserDocumentUI.h, Source/Client/Browser/BrowserInPlace.h, Source/Client/Browser/WebBrowser.h, Source/Client/Input/Language.h, Source/Client/Input/LanguageTC.h, Source/Client/Input/Mouse.h, Source/Client/Mode/CGameMode.h, Source/Client/Mode/CLoginMode.h, Source/Client/Replay.h, Source/Client/Session.h, Source/Client/Stove/StovePCSDK.h, Source/Contents/AchievementMgr.h, Source/Contents/Actors/CharacterRender.h, Source/Contents/Actors/EffectActors.h, Source/Contents/Actors/GameActor.h, Source/Contents/Actors/GndRiser.h, Source/Contents/Actors/GrannyGameActor.h, Source/Contents/Actors/MousePointer.h, Source/Contents/Actors/Npc.h, Source/Contents/Actors/Pc.h, Source/Contents/Actors/RenderObjectState.h, Source/Contents/Actors/Skill.h, Source/Contents/AdventureGuideMgr.h, Source/Contents/CashEmotionMgr.h, Source/Contents/ClanInfo.h, Source/Contents/Configuration/GameSettingsMgr.h, Source/Contents/EffectResourceSwitcher.h, Source/Contents/Effects/AcidifiedThrow.h, Source/Contents/Effects/ArrowEffect.h, Source/Contents/Effects/AxeBoomerang.h, Source/Contents/Effects/BlastForge.h, Source/Contents/Effects/CharacterParticleBundle.h, Source/Contents/Effects/DummyEffectLauncher.h, Source/Contents/Effects/EZ2STREffectEx.h, Source/Contents/Effects/Effect.h, Source/Contents/Effects/EffectActor.h, Source/Contents/Effects/EffectEmitter.h, Source/Contents/Effects/EffectPrimitiveState.h, Source/Contents/Effects/EffectTypes.h, Source/Contents/Effects/ElectricEffect.h, Source/Contents/Effects/EmitterEffect.h, Source/Contents/Effects/FortuneKissEffect.h, Source/Contents/Effects/MagicFloorEffect.h, Source/Contents/Effects/MandraAttackEffect.h, Source/Contents/Effects/MonsterSkillEffects.h, Source/Contents/Effects/MsgEffect.h, Source/Contents/Effects/Particle.h, Source/Contents/Effects/RagEffectState.h, Source/Contents/Effects/RichManKim.h, Source/Contents/Effects/SpriteParticle.h, Source/Contents/Effects/StarEffect.h, Source/Contents/Effects/WhirlwindEffect.h, Source/Contents/EnchantMgr.h, Source/Contents/FlyingShipRouteInfo.h, Source/Contents/Ground/GroundSpatial.h, Source/Contents/GuildInfo.h, Source/Contents/Hotkeys/InterfaceHotkey.h, Source/Contents/Items/ItemInfo.h, Source/Contents/Items/RuneSystem.h, Source/Contents/MapSkyMgr.h, Source/Contents/Models/ModelActor.h, Source/Contents/Movies/BinkMovie.h, Source/Contents/NavigationManager.h, Source/Contents/Party/PartyBookingMgr.h, Source/Contents/PetEvolutionMgr.h, Source/Contents/RenewQuestMgr.h, Source/Contents/RodexMailStore.h, Source/Contents/Schedule/Schedule.h, Source/Contents/Schedule/ShutDownSchedule.h, Source/Contents/SignBoard/SignBoard.h, Source/Contents/Skills/PlayerSkillBundle.h, Source/Contents/Sound/SoundMgr.h, Source/Contents/SpriteLayerDrawing.h, Source/Contents/Store/MCStoreInfoBackupAsyncWork.h, Source/Contents/UserData/AccountLinkedUserDataLoadAsyncWork.h, Source/Contents/UserData/NormalItemSlots.h, Source/Contents/WorldView/WorldViewData.h, Source/Network/Connection/Connection.h, Source/Render/DX7/DeviceOwnerDX7.h, Source/Render/DX7/DirectDrawEnumeration.h, Source/Render/DX9/DeviceOwnerDX9.h, Source/Render/Primitives/LightmappedPrimitive.h, Source/Render/Primitives/RenderPrimitive.h, Source/Render/Renderer.h, Source/Render/RendererDX7.h, Source/Render/Text/EmbedFont.h, Source/Render/Text/TextContext.h, Source/Render/Textures/Texture.h, Source/Resource/BinkRuntime.h, Source/Resource/GifResource.h, Source/Resource/Models/AnimatedModelResource.h, Source/Resource/Models/GrannyModelResource.h, Source/Resource/Models/ModelMesh.h, Source/Resource/ResourceMgr.h, Source/Resource/World/GroundResource.h, Source/Resource/World/WorldResource.h, Source/Security/NProtectGameGuardMgr.h, Source/Security/ReassemblyPacketMgr.h, Source/UI/Buttons/UIBmpRadioBtn.h, Source/UI/Buttons/UIBmpTextButton2.h, Source/UI/Buttons/UIDescriptRace.h, Source/UI/Buttons/UIItemTagButton.h, Source/UI/Buttons/UITVTextButton.h, Source/UI/Buttons/UITextureButton.h, Source/UI/Chat/UINewChatWnd.h, Source/UI/Chat/UISubChatHisWnd.h, Source/UI/Dialogs/UILoadingWnd.h, Source/UI/Dialogs/UIMiniMapWnd.h, Source/UI/Dialogs/UIPasswordWnd.h, Source/UI/Dialogs/UIRestartWnd.h, Source/UI/Dialogs/UISayDialogWnd.h, Source/UI/Edit/UIEditCtrl.h, Source/UI/Enchant/EnchantUI.h, Source/UI/GameSettings/GameSettingsUI.h, Source/UI/Guild/UIGuildWnd.h, Source/UI/Item/UIItemStoreFindWnd.h, Source/UI/Item/UIItemStoreSubWnd.h, Source/UI/Item/UIItemStoreWnd.h, Source/UI/Items/UIEquipWnd.h, Source/UI/Items/UIExchangeWnd.h, Source/UI/Items/UIItemCollectionWnd.h, Source/UI/Items/UIItemRepairWnd.h, Source/UI/Items/UISwapEquipmentWnd.h, Source/UI/Lists/TableBox.h, Source/UI/Lists/UIListBox.h, Source/UI/Lists/UIListBoxEx.h, Source/UI/Lists/UIListBoxID.h, Source/UI/Lists/UIListBoxTemplate.h, Source/UI/Lists/UITabControl.h, Source/UI/Lists/UITreeView.h, Source/UI/Lists/UIVScrollBar.h, Source/UI/Navigation/UINavigationV4Wnd.h, Source/UI/Navigation/UIPrivateAirplaneWnd.h, Source/UI/Party/UIAdvenPartyBoardWnd.h, Source/UI/Party/UIRequestJoinPartyWnd.h, Source/UI/ProbabilityTable/UIProbabilityTable.h, Source/UI/Quest/UIRenewQuestWnd.h, Source/UI/Rodex/UIRodexComposeWnd.h, Source/UI/RuneSystem/UIRuneSystemWindows.h, Source/UI/RuneSystem/UIRuneSystemWnd.h, Source/UI/Shop/UIMerchantItemMyShopWnd.h, Source/UI/Shop/UIMerchantShopMakeWnd.h, Source/UI/Shop/UIMerchantShopTitle.h, Source/UI/StylingShop/UIStylingShopWnd.h, Source/UI/Text/CreateLineInfo.h, Source/UI/Text/TextMarkup.h, Source/UI/Text/UIString.h, Source/UI/Text/UITextViewer.h, Source/UI/Text/UITransBalloonText.h, Source/UI/UIChangeMaterialWnd.h, Source/UI/UIMacroDetectorWnd.h, Source/UI/UIMacroUserInfoWnd.h, Source/UI/Window/UIAccountLimitedToolWnd.h, Source/UI/Window/UIBalloonOpenBtn.h, Source/UI/Window/UIBasicInfoWnd.h, Source/UI/Window/UIBattleMsgOptionWnd.h, Source/UI/Window/UICollectionSystemWnd.h, Source/UI/Window/UIControl.h, Source/UI/Window/UIHotKeyWnd.h, Source/UI/Window/UIJobListWnd.h, Source/UI/Window/UILoginWnd.h, Source/UI/Window/UIMakeCharWnd.h, Source/UI/Window/UIMerInfoWnd.h, Source/UI/Window/UIMessageBox.h, Source/UI/Window/UIMonsterDisplayWnd.h, Source/UI/Window/UINewMakeCharWnd.h, Source/UI/Window/UINewSkillListWnd.h, Source/UI/Window/UINoticeWnd.h, Source/UI/Window/UIReplayRECControlWnd.h, Source/UI/Window/UIRoMapWnd.h, Source/UI/Window/UISecondCostumeWnd.h, Source/UI/Window/UISeekPartyListWnd.h, Source/UI/Window/UISeekPartyMBWnd.h, Source/UI/Window/UISeekPartyWnd.h, Source/UI/Window/UISerachStoreInfoWnd.h, Source/UI/Window/UIWindow.h, Source/UI/Window/UIWindowMgr.h, Source/UI/Window/WindowId.h, Source/Utility/Async/NAsyncWork.h, Source/Utility/Async/NRecycleObjectPoolMgr.h, Source/Utility/JsonCppLoader.h, Source/Utility/Lexicon/LexiconSerializer.h, Source/Utility/NFileLog.h, Source/Utility/Threading/NThread.h.
2026-11-10 17:38:25 +00:00

216 lines
8.4 KiB
C++

#include "Contents/Store/MCStoreInfoBackup.h"
#include "Contents/Store/MCStoreInfoBackupAsyncWork.h"
#include "Client/Session.h"
#include "Network/Http/CURLPostHander.h"
#include "Network/TextEncoding.h"
#include "Utility/Cipher/XorBytes.h"
#include "Utility/Text/FormatString.h"
#include <cstdio>
#include <windows.h>
#include <timeapi.h>
namespace {
constexpr char loadSource[] = "C:\\repositories\\RagnarokClient\\RagnarokClient\\Contents\\MCStoreBackUpData\\CMCStoreInfoBackupLoadAsyncWork."
"cpp";
constexpr char saveSource[] = "C:\\repositories\\RagnarokClient\\RagnarokClient\\Contents\\MCStoreBackUpData\\CMCStoreInfoBackupSaveAsyncWork."
"cpp";
// INLINED
__forceinline AsyncDiagnostic Diagnostic(bool success, const char* text, const char* file, std::uint32_t line) {
std::string message = text;
return AsyncDiagnostic(&success, &message, file, &line);
}
template <std::size_t Length, std::uint64_t Key>
class EncryptedName {
public:
explicit EncryptedName(const std::uint8_t (&source)[Length]) : m_encrypted(true) {
for (std::uint64_t index = 0; index < Length; ++index) {
this->m_text[index] = source[index];
}
}
~EncryptedName() {
for (std::uint64_t index = 0; index < Length; ++index) {
this->m_text[index] = 0;
}
}
const char* Text() {
if (this->m_encrypted) {
utility::XorBytes(this->m_text, Length, Key);
this->m_encrypted = false;
}
return reinterpret_cast<const char*>(this->m_text);
}
private:
/* 0000 */ std::uint8_t m_text[Length];
bool m_encrypted;
};
// 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();
}
}
// OFFSET: 0x00607B10
// FUNCTION: fn_04241
CMCStoreInfoBackupLoadAsyncWork::CMCStoreInfoBackupLoadAsyncWork()
: NAsyncWork("MerchantStoreInformation_Load"), m_accountId(0), m_characterId(0),
m_diagnostic(false, std::string(DecryptName<0xF535E561137F138DULL>({0xF8, 0x7D, 0x14, 0x7D, 0x16, 0x8A, 0x5B, 0xF5})), loadSource, 28), m_type(0) {
}
// INLINED
CMCStoreInfoBackupLoadAsyncWork::~CMCStoreInfoBackupLoadAsyncWork() = default;
// OFFSET: 0x00608270
// FUNCTION: fn_04244
void CMCStoreInfoBackupLoadAsyncWork::Reset() {
}
// OFFSET: 0x00607FE0
// FUNCTION: fn_04243
void CMCStoreInfoBackupLoadAsyncWork::Bind(
std::string url, std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string token, int type
) {
this->m_group = timeGetTime();
this->m_accountId = accountId;
this->m_characterId = characterId;
this->m_key = 0;
this->m_accountName = accountName;
this->m_url = url;
this->m_token = token;
this->m_response = "";
const std::uint8_t diagnosticSource[] = {0xA4, 0x0F, 0x9A, 0xE7, 0x18, 0x3E, 0x8B, 0xD3};
AsyncDiagnostic diagnostic(false, std::string(DecryptName<0xD3E5516F89F161D1ULL>(diagnosticSource)), loadSource, 55);
this->m_diagnostic.MoveFrom(diagnostic);
this->m_type = type;
}
// OFFSET: 0x00608350
// FUNCTION: fn_04246
bool CMCStoreInfoBackupLoadAsyncWork::Execute() {
char account[64] = {};
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);
char type[64] = {};
StringFormat(type, sizeof(type), _TRUNCATE, "%d", this->m_type);
CCURLPostHander handler(this->m_url);
const std::uint8_t aid[] = {0xB4, 0x6C, 0x17, 0xE9};
handler.AddField(DecryptName<0x2B8725D7E95325F5ULL>(aid), account, 4);
const std::uint8_t gid[] = {0x4A, 0x12, 0x2D, 0x83};
handler.AddField(DecryptName<0x899D11BB83695B0DULL>(gid), character, 4);
const std::uint8_t authToken[] = {0x2A, 0x7E, 0xD1, 0xAD, 0xD3, 0xB2, 0xC6, 0xD8, 0x05, 0x0B};
handler.AddField(DecryptName<0xBDADDD87C5A50B6BULL>(authToken), this->m_token, 4);
const std::uint8_t typeName[] = {0xE9, 0xE4, 0x4B, 0x82, 0x0D};
handler.AddField(DecryptName<0x7989830DE73B9DBDULL>(typeName), type, 4);
const std::uint8_t worldName[] = {0xDE, 0x52, 0x1F, 0x89, 0xC3, 0x4F, 0x46, 0x42, 0xEC, 0x3D};
handler.AddField(DecryptName<0x2F2701A7E56D3D89ULL>(worldName), name, 4);
if (handler.Perform() == 0) {
this->m_response = handler.Response();
const std::uint8_t good[] = {0x42, 0xFE, 0x68, 0xC7, 0xE1};
AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x6B3301E1A3079125ULL>(good), loadSource, 115);
this->m_diagnostic.MoveFrom(diagnostic);
}
return false;
}
// OFFSET: 0x00608280
// FUNCTION: fn_04245
void CMCStoreInfoBackupLoadAsyncWork::Complete() {
g_session.m_storeInfoBackup.CompleteLoad(this->m_diagnostic, this->m_accountId, this->m_characterId, this->m_accountName, this->m_response);
}
// OFFSET: 0x00608D60
// FUNCTION: fn_04247
CMCStoreInfoBackupSaveAsyncWork::CMCStoreInfoBackupSaveAsyncWork()
: NAsyncWork("MerchantStoreInformation_Save"), m_accountId(0), m_characterId(0),
m_diagnostic(false, std::string(DecryptName<0x3FAF85D995034FD7ULL>({0xA2, 0x21, 0x68, 0xFB, 0xAE, 0xEA, 0xC1, 0x3F})), saveSource, 30), m_type(0) {
}
// INLINED
CMCStoreInfoBackupSaveAsyncWork::~CMCStoreInfoBackupSaveAsyncWork() = default;
// OFFSET: 0x00609520
// FUNCTION: fn_04250
void CMCStoreInfoBackupSaveAsyncWork::Reset() {
}
// OFFSET: 0x00609270
// FUNCTION: fn_04249
void CMCStoreInfoBackupSaveAsyncWork::Bind(
std::string url, std::uint32_t accountId, std::uint32_t characterId, std::string accountName, std::string token, std::string data, int type
) {
this->m_group = timeGetTime();
this->m_accountId = accountId;
this->m_characterId = characterId;
this->m_key = 0;
this->m_accountName = accountName;
this->m_url = url;
this->m_token = token;
this->m_data = data;
const std::uint8_t diagnosticSource[] = {0xCC, 0x63, 0x44, 0xCF, 0x34, 0x94, 0x61, 0x49};
AsyncDiagnostic diagnostic(false, std::string(DecryptName<0x490FFB43A12F0DB9ULL>(diagnosticSource)), saveSource, 57);
this->m_diagnostic.MoveFrom(diagnostic);
this->m_type = type;
}
// OFFSET: 0x006095F0
// FUNCTION: fn_04252
bool CMCStoreInfoBackupSaveAsyncWork::Execute() {
char account[64] = {};
StringFormat(account, sizeof(account), _TRUNCATE, "%lu", this->m_accountId);
char character[64] = {};
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);
CCURLPostHander handler(this->m_url);
const std::uint8_t aid[] = {0x48, 0xE0, 0x03, 0x5F};
handler.AddField(DecryptName<0xD3755DD95F47A909ULL>(aid), account, 4);
const std::uint8_t gid[] = {0x2A, 0xAA, 0x01, 0xA3};
handler.AddField(DecryptName<0x31D7C1EDA345E36DULL>(gid), character, 4);
const std::uint8_t authToken[] = {0x2C, 0x16, 0x41, 0x45, 0xF1, 0x6C, 0xE4, 0xBC, 0x03, 0x63};
handler.AddField(DecryptName<0xD98F03A52D35636DULL>(authToken), this->m_token, 4);
const std::uint8_t worldName[] = {0x86, 0x76, 0xEF, 0xE3, 0x0F, 0xC5, 0x6E, 0x62, 0xB4, 0x19};
handler.AddField(DecryptName<0x0F0F8B6B8F9D19D1ULL>(worldName), name, 4);
const std::uint8_t typeName[] = {0x01, 0x84, 0xC5, 0xBE, 0xC7};
handler.AddField(DecryptName<0x3375B1C7DBB5FD55ULL>(typeName), type, 4);
const std::uint8_t dataName[] = {0x7B, 0x50, 0xB9, 0x86, 0xED};
handler.AddField(DecryptName<0x1D6D75EDE7CD311FULL>(dataName), this->m_data, 4);
if (handler.Perform() != 0) {
const std::uint8_t fail[] = {0xC7, 0x5C, 0xF6, 0xBB, 0x63};
AsyncDiagnostic diagnostic = Diagnostic(false, DecryptName<0x59278F63D79F3DA1ULL>(fail), saveSource, 112);
this->m_diagnostic.MoveFrom(diagnostic);
this->m_response = handler.Response();
} else {
const std::uint8_t good[] = {0xD0, 0x68, 0x38, 0xA9, 0x2B};
AsyncDiagnostic diagnostic = Diagnostic(true, DecryptName<0x812BE72BCD5707B7ULL>(good), saveSource, 122);
this->m_diagnostic.MoveFrom(diagnostic);
this->m_response = handler.Response();
}
return false;
}
// OFFSET: 0x00609530
// FUNCTION: fn_04251
void CMCStoreInfoBackupSaveAsyncWork::Complete() {
g_session.m_storeInfoBackup.CompleteSave(this->m_diagnostic, this->m_response);
}
template void std::deque<CMCStoreInfoBackupSaveAsyncWork*>::push_back(CMCStoreInfoBackupSaveAsyncWork*&&);
template void std::deque<CMCStoreInfoBackupLoadAsyncWork*>::push_back(CMCStoreInfoBackupLoadAsyncWork*&&);