summaryrefslogtreecommitdiff
path: root/src/factories/bk64/ModelFactory.cpp
diff options
context:
space:
mode:
authorJeod <47716344+JeodC@users.noreply.github.com>2026-07-21 07:51:22 -0400
committerLywx <kiritodev01@gmail.com>2026-07-21 10:28:15 -0600
commit6e9ee0aaffb6f338551d9fc8fd447e1fe5a03603 (patch)
tree1e7326617ccc92d5d92bebf006d614c8e094354e /src/factories/bk64/ModelFactory.cpp
parent4c8ef537bffe99e55e2087a4f938f1ddb35de815 (diff)
BK: Add romhack guards for extraction and soundfontctl factory
Diffstat (limited to 'src/factories/bk64/ModelFactory.cpp')
-rw-r--r--src/factories/bk64/ModelFactory.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/factories/bk64/ModelFactory.cpp b/src/factories/bk64/ModelFactory.cpp
index 71977bc..b0b3f6d 100644
--- a/src/factories/bk64/ModelFactory.cpp
+++ b/src/factories/bk64/ModelFactory.cpp
@@ -700,7 +700,16 @@ std::optional<std::shared_ptr<IParsedData>> ModelFactory::parse(std::vector<uint
// catches the sequential sub-lists; an intra-buffer G_DL can jump to some arbitrary
// offset that no G_ENDDL precedes.
if (opCode == GBI(G_DL) && SEGMENT_NUMBER(w1) == 3) {
- dlOffsets.emplace(SEGMENT_OFFSET(w1));
+ // Some jump targets may be garbage; only split on ones that land
+ // inside the DL section on a command boundary, or the resulting GFX asset
+ // parses off the end of the file.
+ uint32_t target = SEGMENT_OFFSET(w1);
+ if (target < dlCount * GFX_CMD_SIZE && (target % GFX_CMD_SIZE) == 0) {
+ dlOffsets.emplace(target);
+ } else {
+ SPDLOG_WARN("[BKModel] {} G_DL target 0x{:X} outside DL section (size 0x{:X}); skipping split",
+ symbol, target, dlCount * GFX_CMD_SIZE);
+ }
}
}
}