From a8bc364a2b59855dfd11f158650051fce298637b Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 3 Nov 2024 17:38:27 +1000 Subject: [PATCH] Cheats: Fix importing hash-formatted codes --- src/core/cheats.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/cheats.cpp b/src/core/cheats.cpp index c4492be25..1e4657285 100644 --- a/src/core/cheats.cpp +++ b/src/core/cheats.cpp @@ -1666,8 +1666,10 @@ bool Cheats::ImportEPSXeFile(CodeInfoList* dst, const std::string_view file_cont return false; } - current_code.body = - std::string_view(file_contents).substr(current_code.file_offset_body_start, current_code.file_offset_end); + current_code.body = std::string_view(file_contents) + .substr(current_code.file_offset_body_start, + current_code.file_offset_end - current_code.file_offset_body_start); + StringUtil::StripWhitespace(¤t_code.body); AppendCheatToList(dst, std::move(current_code)); return true; @@ -1699,7 +1701,7 @@ bool Cheats::ImportEPSXeFile(CodeInfoList* dst, const std::string_view file_cont // new code. current_code = CodeInfo(); current_code.name = linev.substr(1); - current_code.file_offset_start = static_cast(reader.GetCurrentLineOffset()); + current_code.file_offset_start = static_cast(reader.GetCurrentOffset()); current_code.file_offset_end = current_code.file_offset_start; current_code.file_offset_body_start = current_code.file_offset_start; current_code.type = CodeType::Gameshark;