Skip to content

Commit

Permalink
Fixed #40. Fixed issue with displaying adf files with optional types
Browse files Browse the repository at this point in the history
  • Loading branch information
kk49 committed May 5, 2019
1 parent 36cf3b5 commit 4d1b592
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions deca/ff_adf.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,8 @@ def dump_type(type_id, type_map, offset=0):
def adf_type_id_to_str(type_id, type_map):
if type_id in prim_type_names:
return prim_type_names[type_id]
if type_id == 0xdefe88ed:
return 'OPTIONAL'

type_def = type_map[type_id]

Expand Down Expand Up @@ -395,7 +397,10 @@ def adf_format(v, type_map, indent=0):

value_info = s
s = ''
if type_def.metatype is None or type_def.metatype == MetaType.Primative:
if v.type_id == 0xdefe88ed:
s = s + ' ' * indent + '# {}\n'.format(value_info)
s = s + adf_format(v.value, type_map, indent)
elif type_def.metatype is None or type_def.metatype == MetaType.Primative:
s = s + ' ' * indent + '{} # {}\n'.format(v.value, value_info)
elif type_def.metatype == MetaType.Structure:
s = s + ' ' * indent + '# ' + value_info + '\n'
Expand Down Expand Up @@ -507,7 +512,7 @@ def read_instance(f, type_id, map_typdef, map_stringhash, table_name, abs_offset
f.seek(v0[0])
v = read_instance(f, v0[2], map_typdef, map_stringhash, table_name, abs_offset, found_strings=found_strings)
f.seek(opos)
v = AdfValue(v, v0[2], dpos + abs_offset, v0[0] + abs_offset)
v = AdfValue(v, type_id, dpos + abs_offset, v0[0] + abs_offset)
elif type_id == 0x178842fe: # gdc/global.gdcc
# TODO this should probably be it's own file type and the adf should be considered a wrapper
v = []
Expand Down
6 changes: 3 additions & 3 deletions deca/ff_vfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -925,10 +925,10 @@ def find_vpath_by_assoc(self, vpath_map):

assoc_strings = {}
for k, v in vpath_map.nodes.items():
file_ext = k.decode('utf-8').split('.', 1)
if len(file_ext) == 2:
file_ext = os.path.splitext(k.decode('utf-8'))
if len(file_ext[0]) > 0 and len(file_ext[1]) > 0:
file = file_ext[0]
ext = '.' + file_ext[1]
ext = file_ext[1]
for pe in pair_exts:
if ext in pe:
for pk, pv in pe.items():
Expand Down

0 comments on commit 4d1b592

Please sign in to comment.