Skip to content

Commit 04c4ee3

Browse files
committed
Add debug flag for pointer correctness
1 parent 1914ea5 commit 04c4ee3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Assets/Lua/Doom/dsda-data.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ local dsda = {
88
hexen = {},
99
}
1010

11+
-- Read the high word of every pointer and check that it matches the expected base address (for debugging)
12+
dsda.check_pointers = false
13+
1114

1215

1316
-- Constants ---
@@ -45,6 +48,9 @@ end
4548

4649
-- Returns the lower 4 bytes of an 8 byte pointer
4750
function dsda.read_ptr(addr, domain)
51+
if dsda.check_pointers and read_u32(addr + 4, domain) ~= WBX_POINTER_HI then
52+
error(string.format("Invalid pointer 0x%016X at %s 0x%X", dsda.read_s64_le(addr, domain), domain, addr))
53+
end
4854
return read_u32(addr, domain)
4955
end
5056

0 commit comments

Comments
 (0)