From f66874c19f6857a5d29e2340160fed5871bd7c37 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Mon, 26 Oct 2026 21:49:26 +0000 Subject: [PATCH] Decompile fn_17634 (LexiconBoundary::Matches) Batch #834 by ragnarok-clanker: 0 byte-identical, 1 confirmed by peer review. - fn_17634 LexiconBoundary::Matches: logic confirmed by peer review Reviewed-by: ragnarok-clanker Adds to the build: Source/Utility/LexiconBoundary.cpp --- Source/Utility/LexiconBoundary.cpp | 38 ++++++++++++++++++++++++++++++ Source/Utility/LexiconBoundary.h | 13 ++++++++++ compile.json | 1 + 3 files changed, 52 insertions(+) create mode 100644 Source/Utility/LexiconBoundary.cpp create mode 100644 Source/Utility/LexiconBoundary.h diff --git a/Source/Utility/LexiconBoundary.cpp b/Source/Utility/LexiconBoundary.cpp new file mode 100644 index 0000000..9d5b746 --- /dev/null +++ b/Source/Utility/LexiconBoundary.cpp @@ -0,0 +1,38 @@ +#include "Utility/LexiconBoundary.h" + +// FUNCTION: fn_17634 +bool LexiconBoundary::Matches(unsigned char previous, unsigned char current, unsigned char options) const { + if (previous == 0xDD) { + return true; + } + + if ((this->flags[previous] & 1) != 0 && (this->flags[current] & 0x2100) != 0) { + return true; + } + + if (current == 32) { + return true; + } + + if (previous == 32) { + return false; + } + + const std::uint32_t before = this->flags[previous]; + const std::uint32_t after = this->flags[current]; + if ((options & 2) != 0) { + return ((before & 0x470) != 0) == ((after & 0x470) != 0) && + (((before & 0x1000) != 0 && (after & 1) != 0) || ((before & 0x470) != 0 && (after & 0x470) != 0) || + ((before & 2) != 0 && (after & 2) != 0)); + } + + if ((after & 0x10) != 0 && (before & 0x10) == 0) { + return false; + } + + if ((after & 0x60) != 0 || (before & 0x10) != 0 || ((before & 0x1000) != 0 && (after & 1) != 0)) { + return true; + } + + return ((before & 0x400) != 0 && (after & 0x10002) != 0) || (after & 0x400) != 0; +} diff --git a/Source/Utility/LexiconBoundary.h b/Source/Utility/LexiconBoundary.h new file mode 100644 index 0000000..fd56eac --- /dev/null +++ b/Source/Utility/LexiconBoundary.h @@ -0,0 +1,13 @@ +#ifndef RAGNAROK_SOURCE_UTILITY_LEXICONBOUNDARY_H +#define RAGNAROK_SOURCE_UTILITY_LEXICONBOUNDARY_H + +#include + +struct LexiconBoundary { + /* 0000 */ std::uint32_t unknown_0000; + /* 0004 */ std::uint32_t flags[256]; + + bool Matches(unsigned char previous, unsigned char current, unsigned char options) const; +}; + +#endif diff --git a/compile.json b/compile.json index b079dcb..25040fc 100644 --- a/compile.json +++ b/compile.json @@ -582,6 +582,7 @@ "Source/Utility/Async/NRecycleObjectPoolMgr.cpp": 0, "Source/Utility/Base64.cpp": 0, "Source/Utility/GuidParse.cpp": 0, + "Source/Utility/LexiconBoundary.cpp": 0, "Source/Utility/MD5.cpp": 0, "Source/Utility/Math/AffineLookAt.cpp": 0, "Source/Utility/Math/AffineMatrix.cpp": 0,