From 02b89a2af656d4f8bef58ccb2eb21abd92d06ef5 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Thu, 12 Nov 2026 03:25:13 +0000 Subject: [PATCH] Decompile fn_19337 (ReplayFileList::Open) Batch #17777 by eAthena: 0 byte-identical, 1 confirmed by peer review. - fn_19337 ReplayFileList::Open: logic confirmed by peer review Peer-reviewed-by: Yommy, alisonrag, cremane Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Client/Replay/Replay.cpp | 37 ++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/Source/Client/Replay/Replay.cpp b/Source/Client/Replay/Replay.cpp index 3fc22d803..339358c14 100644 --- a/Source/Client/Replay/Replay.cpp +++ b/Source/Client/Replay/Replay.cpp @@ -756,40 +756,43 @@ int ReplayFileList::Open(int mode, int argument1, int argument2) { std::memset(this->path, 0, sizeof(this->path)); std::memcpy(this->path, name.data(), name.size()); - this->replay->fileMode = 0x20; - this->replay->file = std::fopen(this->path, "rb"); + Replay* replay = this->replay; + replay->fileMode = 0x20; + replay->file = std::fopen(this->path, "rb"); - if (this->replay->file) { - std::fseek(this->replay->file, 100, SEEK_SET); - std::memset(&this->replay->header, 0, 0xC); - std::fread(&this->replay->header, 0xC, 1, this->replay->file); + if (replay->file) { + std::fseek(replay->file, 100, SEEK_SET); + std::memset(&replay->header, 0, 0xC); + std::fread(&replay->header, 0xC, 1, replay->file); - if (this->replay->header.signature == 0x52414705u || this->replay->header.signature == 0x51404605u) { + if (replay->header.signature == 0x52414705u || replay->header.signature == 0x51404605u) { for (int index = 0; index <= 0x1A; ++index) { ReplaySection section = {}; - std::fread(§ion, sizeof(section), 1, this->replay->file); + std::fread(§ion, sizeof(section), 1, replay->file); - if (section.id > 0x1A) { + if (section.id < 0 || section.id > 0x1A) { break; } - this->replay->sections[section.id] = section; + replay->sections[section.id].id = section.id; + replay->sections[section.id].bytes = section.bytes; + replay->sections[section.id].fileOffset = section.fileOffset; } - if (this->replay->ParseMetadata(this->replay->ReadSection(2)) != 0xFFFFFFFFu) { + if (replay->ParseMetadata(replay->ReadSection(2)) != 0xFFFFFFFFu) { return 1; } - std::memset(&this->replay->header, 0, sizeof(this->replay->header)); + std::memset(&replay->header, 0, sizeof(replay->header)); } - if (this->replay->file) { - std::fclose(this->replay->file); - this->replay->file = nullptr; + if (replay->file) { + std::fclose(replay->file); + replay->file = nullptr; } - std::memset(&this->replay->header, 0, sizeof(this->replay->header)); - std::memset(this->replay->sections, 0, sizeof(this->replay->sections)); + std::memset(&replay->header, 0, sizeof(replay->header)); + std::memset(replay->sections, 0, sizeof(replay->sections)); } return 0;