Assembler: fix bug writing FIXUP_DATADATA items
commit3c9e14a3a5323a1ec1e86f9e2c229e8c8d9c63b8
authorrofl0r <rofl0r@users.noreply.github.com>
Sat, 13 Jul 2019 22:59:46 +0000 (13 23:59 +0100)
committerrofl0r <rofl0r@users.noreply.github.com>
Sat, 13 Jul 2019 22:59:46 +0000 (13 23:59 +0100)
tree0ec7fb50bd7764e99c69bf162dc3d100b5d50a78
parente4a24a6d54cdce763c611ea9a0e3fa5c4914931d
Assembler: fix bug writing FIXUP_DATADATA items

sourceline 34 of "1213_ep1.exe"'s globalscript does a StrCopy()
to a .data - allocated array (the variable used with the .data + 60
fixup is basically a pointer there).

this caused a crash in the first room (room 1) directly after the intro
cutscene, after the BOSS finishes talking.

examining this bug (using the -f flag of agsdisas to print the fixup
section) i found that FIXUP_DATADATA items, unlike all others,
need to be right at the start of the fixup section (sorted too, but
in front of the others).

the sort function now takes care of this peculiarity.

to debug this, i added code to the engine to print sourceline
(look for SCMD_LINENUM in cc_instance.cpp) statements to stderr,
and the following patch to Engine/ac/string.h, to detect where
the error is coming from.
looking at sourceline 34 in the .s file then revealed the access to
a datadata fixup.

+#define STRIFY(X) STRIFY_REAL(X)
+#define STRIFY_REAL(X) # X
 // Check that a supplied buffer from a text script function was not null
-#define VALIDATE_STRING(strin) if ((unsigned long)strin <= 4096) quit("!String argument was null: make sure you pass a string, not an int, as a buffer")
+#define VALIDATE_STRING(strin) if ((unsigned long)strin <= 4096) quit(__FILE__ ":" STRIFY(__LINE__) " !String argument was null: make sure you pass a string, not an int, as a buffer")
Assembler.c