add updated Rolling ROLL_P.WAD extraction utility
This commit is contained in:
parent
88cd7adf23
commit
280965d81b
|
@ -92,40 +92,34 @@ class WadEntry: # a wad file entry
|
|||
|
||||
self.children = []
|
||||
|
||||
def read_directory_children(self):
|
||||
last_ofs = self.next_link
|
||||
self._file.seek(last_ofs, os.SEEK_SET)
|
||||
|
||||
# Bit of a bug right now but it seems to work.
|
||||
def read_children(self):
|
||||
ofs = self.next_link
|
||||
|
||||
#print(f'seeking to {ofs:x}')
|
||||
self._file.seek(ofs, os.SEEK_SET)
|
||||
|
||||
# read all of the children nodes
|
||||
entry = WadEntry(self._file)
|
||||
entry.parent = self
|
||||
|
||||
while True:
|
||||
#print(entry.name, entry.type, "parent:", entry.parent.name)
|
||||
# let child directory read its children
|
||||
if entry.type == WadEntryType.DIRECTORY:
|
||||
#print(entry.name, "reading children")
|
||||
entry.read_children()
|
||||
#print(entry.name, entry.type, "parent dir:", entry.parent.name)
|
||||
|
||||
if entry.type == WadEntryType.DIRECTORY and entry.next_link != 0:
|
||||
entry.read_directory_children()
|
||||
|
||||
if entry.next_file != 0:
|
||||
#print(f'seeking to {entry.next_file:x} (loop)')
|
||||
self._file.seek(entry.next_file, os.SEEK_SET)
|
||||
|
||||
if entry.next_file == 0 and entry.next_link == 0:
|
||||
self.children.append(entry)
|
||||
|
||||
if entry.next_file == 0:
|
||||
#print("done reading", self.name)
|
||||
self._file.seek(ofs, os.SEEK_SET)
|
||||
self.children.append(entry)
|
||||
self._file.seek(last_ofs, os.SEEK_SET)
|
||||
return
|
||||
else:
|
||||
self.children.append(entry)
|
||||
|
||||
entry = WadEntry(self._file)
|
||||
entry.parent = self
|
||||
|
||||
|
||||
def dump(self, pathObj):
|
||||
self._file.seek(blocks_to_bytes(self.block_offset), os.SEEK_SET)
|
||||
path = str(pathObj)
|
||||
|
@ -153,7 +147,7 @@ rootPath.mkdir(exist_ok=True)
|
|||
with open(sys.argv[1], "rb") as file:
|
||||
header = WadHeader(file)
|
||||
root = WadEntry(file)
|
||||
root.read_children()
|
||||
root.read_directory_children()
|
||||
|
||||
for tup in root.walk(rootPath):
|
||||
if tup[1].type == WadEntryType.FILE:
|
||||
|
|
Loading…
Reference in New Issue