From 0585e8cc85e0bc478f291289caf780e6d51fe4cb Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 12 Nov 2026 14:51:43 +0000 Subject: [PATCH] Decompile fn_24201 (CSession::BuildShopReplayRecords) Batch #18480 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_24201 CSession::BuildShopReplayRecords: logic confirmed by peer review Peer-reviewed-by: ragnarok-clanker, cremane, bibinir Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Replay/Replay.cpp | 13 +++++++++++-- Source/Client/Replay/Replay.h | 9 ++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Source/Client/Replay/Replay.cpp b/Source/Client/Replay/Replay.cpp index 74825ea06..d5a75f2b6 100644 --- a/Source/Client/Replay/Replay.cpp +++ b/Source/Client/Replay/Replay.cpp @@ -174,7 +174,15 @@ Replay::Replay() : cipherIndex(0), cipherBase(0), cipherKey(0), recordingState(0 this->speed = 1.0f; std::memset(&this->header, 0, sizeof(this->header)); std::memset(&this->header.options, 1, sizeof(this->header.options)); - this->ResetFile(); + const ReplayOptions savedOptions = this->header.options; + std::memset(&this->header, 0, sizeof(this->header)); + this->header.options = savedOptions; + this->header.signature = 0x52414705; + this->header.closingSignature = 0x52414705; + this->records = 0; + this->fileMode = -1; + this->file = nullptr; + this->fileOffset = 0; this->previousTick = timeGetTime(); this->playbackState = 0; this->recordingState = 0; @@ -1285,7 +1293,8 @@ std::vector CSession::BuildShopReplayRecords() { value.padding_0000 = 0; value.shopId = it->second; std::memset(value.name, 0, sizeof(value.name)); - std::memcpy(value.name, it->first.c_str(), (std::min)(it->first.size(), sizeof(value.name))); + const std::size_t length = it->first.size(); + std::memcpy(value.name, it->first.c_str(), length > sizeof(value.name) ? sizeof(value.name) : length); AppendRecord(records, MakeReplayRecord(7502, &value, sizeof(value))); } for (auto shop = this->m_shops.begin(); shop != this->m_shops.end(); ++shop) { diff --git a/Source/Client/Replay/Replay.h b/Source/Client/Replay/Replay.h index 73a60821e..9af7c279a 100644 --- a/Source/Client/Replay/Replay.h +++ b/Source/Client/Replay/Replay.h @@ -20,8 +20,15 @@ struct ReplayCachedPacket { /* 0000 */ bool enabled; /* 0004 */ std::vector bytes; - ReplayCachedPacket() = default; + // INLINED + ReplayCachedPacket() { + this->enabled = false; + } ReplayCachedPacket(const ReplayCachedPacket& other); + // INLINED + ~ReplayCachedPacket() { + this->bytes.clear(); + } }; #pragma pack(push, 1)