Skip to content

Commit

Permalink
Add RPYC2 decompilation code to un.rpyc. Since ren'py maintains backw…
Browse files Browse the repository at this point in the history
…ards compatibility with the old rpyc format no further changes should be necessary
  • Loading branch information
CensoredUsername committed Aug 19, 2015
1 parent fec0d15 commit 02d0c8d
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion un.rpyc/unrpyc-compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,21 @@ def __setstate__(self, state):

def read_ast_from_file(in_file):
# .rpyc files are just zlib compressed pickles of a tuple of some data and the actual AST of the file
raw_contents = in_file.read().decode('zlib')
raw_contents = in_file.read()
if raw_contents.startswith("RENPY RPC2"):
# parse the archive structure
position = 10
chunks = {}
while True:
slot, start, length = struct.unpack("III", raw_contents[position: position + 12])
if slot == 0:
break
position += 12

chunks[slot] = raw_contents[start: start + length]

raw_contents = chunks[1]
raw_contents = raw_contents.decode('zlib')
data, stmts = magic.safe_loads(raw_contents, factory, ("_ast",))
return stmts

Expand Down

0 comments on commit 02d0c8d

Please sign in to comment.