1
0
mirror of synced 2025-01-31 04:03:45 +01:00

A bit of refactoring and debug messages.

This commit is contained in:
Jennifer Taylor 2021-05-29 00:00:15 +00:00
parent ac4b139b08
commit 83457808e7
2 changed files with 17 additions and 8 deletions

View File

@ -497,6 +497,7 @@ class AFPRenderer(VerboseOutput):
if not hasattr(obj, attribute):
print(f"WARNING: Tried to set attribute {attribute} on {obj} but that attribute doesn't exist!")
else:
self.vprint(f"{prefix} Setting attribute {attribute} on {obj} to {set_value}")
setattr(obj, attribute, set_value)
elif action.opcode == AP2Action.CALL_METHOD:
# Grab the method name.
@ -515,6 +516,7 @@ class AFPRenderer(VerboseOutput):
# Look up the python function we're calling.
try:
self.vprint(f"{prefix} Calling method {methname}({', '.join(repr(s) for s in params)}) on {obj}")
meth = getattr(obj, methname)
# Call it, set the return on the stack.
@ -537,6 +539,7 @@ class AFPRenderer(VerboseOutput):
# Look up the python function we're calling.
try:
self.vprint(f"{prefix} Calling global function {funcname}({', '.join(repr(s) for s in params)})")
func = getattr(globalobj, funcname)
# Call it, set the return on the stack.

View File

@ -1437,22 +1437,28 @@ class SWF(TrackedCoverage, VerboseOutput):
# I have no idea what any of this is either, so I am duplicating game logic in the
# hopes that someday it makes sense.
cur_size = 0
for bit in range(32):
if bool(bitmask & (1 << bit)):
unk_flags, unk_size = struct.unpack("<HH", datachunk[(running_pointer + (cur_size * 2)):(running_pointer + (cur_size * 2) + 4)])
unk_flags, unk_size = struct.unpack("<HH", datachunk[running_pointer:(running_pointer + 4)])
self.add_coverage(dataoffset + running_pointer, 4)
running_pointer += 4
cur_size = cur_size + 2 + (
chunk_size = (
# Either 2 or 6, depending on unk_flags & 0x10 set.
(((unk_flags & 0x10) | 0x8) >> 2) *
# Either 1 or 2, depending on unk_flags & 0x1 set.
((unk_flags & 1) + 1) *
unk_size
# Raw size as read from the header above.
unk_size *
# I assume this is some number of shorts, much like many other
# file formats, so this is why all of these counts are doubled.
2
)
self.vprint(f"{prefix} WTF: {hex(unk_flags)}, {unk_size}, {cur_size}")
self.vprint(f"{prefix} WTF: {hex(unk_flags)}, {unk_size}, {chunk_size}")
self.add_coverage(dataoffset + running_pointer, cur_size * 2)
running_pointer += cur_size * 2
# Skip past data.
running_pointer += chunk_size
if flags & 0x1000000000:
# I have no idea what this is, but the two shorts that it pulls out are assigned