From 74b07ea43a3269f0d92cabf0872c21da60993aad Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Tue, 6 Oct 2026 18:51:32 +0000 Subject: [PATCH] refactor(board): write the stripped URL extension check instead of forcing its strings (grok-focus) (worker a5dca043) --- include/scene/board/iplFocusObject.h | 1 + src/scene/board/iplFocusObject.cpp | 32 ++++++++++++++++------ tools/decomp-assist/grok-focus.attempts.md | 18 ++++++++++++ 3 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 tools/decomp-assist/grok-focus.attempts.md diff --git a/include/scene/board/iplFocusObject.h b/include/scene/board/iplFocusObject.h index 715c487b..05a0939b 100644 --- a/include/scene/board/iplFocusObject.h +++ b/include/scene/board/iplFocusObject.h @@ -180,6 +180,7 @@ namespace ipl { BOOL is_url_end_code(wchar_t ch) const; BOOL is_url_protocol(const wchar_t* url) const; + BOOL is_url_ext(const wchar_t* url) const; int get_url_end(const wchar_t* url) const; BOOL is_buffer_over(const wchar_t* text, u32 textLen) const; diff --git a/src/scene/board/iplFocusObject.cpp b/src/scene/board/iplFocusObject.cpp index fac3302a..6f25f5dd 100644 --- a/src/scene/board/iplFocusObject.cpp +++ b/src/scene/board/iplFocusObject.cpp @@ -1243,14 +1243,30 @@ namespace ipl { return result; } - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".html"); - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".htm"); - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".shtml"); - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".shtm"); - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".cgi"); - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".php"); - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".asp"); - DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".jsp"); + BOOL focus_object::is_url_ext(const wchar_t* url) const { + BOOL result = FALSE; + u32 len = wcslen(url); + const wchar_t* exts[8]; + int i; + + exts[0] = L".html"; + exts[1] = L".htm"; + exts[2] = L".shtml"; + exts[3] = L".shtm"; + exts[4] = L".cgi"; + exts[5] = L".php"; + exts[6] = L".asp"; + exts[7] = L".jsp"; + + for (i = 0; i < 8; i++) { + u32 extLen = wcslen(exts[i]); + if (len >= extLen && wcsncmp(url + (len - extLen), exts[i], extLen) == 0) { + result = TRUE; + break; + } + } + return result; + } int focus_object::get_url_end(const wchar_t* url) const { int i; diff --git a/tools/decomp-assist/grok-focus.attempts.md b/tools/decomp-assist/grok-focus.attempts.md new file mode 100644 index 00000000..0c0a22f9 --- /dev/null +++ b/tools/decomp-assist/grok-focus.attempts.md @@ -0,0 +1,18 @@ +# grok-focus is_url_ext + +Replaced the eight DECOMP_FORCE_ACTIVE wide strings with focus_object::is_url_ext. +The function is not in the target object (linker must strip it). Strings stay in source order. + +Attempt 1: local `const wchar_t* exts[] = { L".html", ... }` loop. +- .rodata 176 -> 208 (MWCC emitted the pointer table). Restored. + +Attempt 2: unrolled wcsncmp tail checks, one local pointer per extension. +- .data/.rodata/.sdata/.sdata2 identical to the force-active object +- 89/89 original functions byte-identical, odiff differing 0 + +Attempt 3: same compares in a loop, pointers assigned one by one (no aggregate initializer). +- .data sha 672d08c07636 matches the force-active build (2164 bytes; orig object is 2168 with 4 trailing zero bytes, unchanged) +- .rodata/.sdata/.sdata2 identical to the original object +- pool IDENTICAL 80/80 +- odiff: 89/89 differing 0 +- no DECOMP_FORCE_ACTIVE left in iplFocusObject.cpp -- 2.49.1