Skip to content

Commit

Permalink
Fixed Bug in ADF missing type tracking. Fixed missing mapping for cer…
Browse files Browse the repository at this point in the history
…tain DXGI formats (61-64, typed versions of 60) JC3 loads again but is too aggresive in naming files
  • Loading branch information
kk49 committed May 6, 2020
1 parent 3f8d179 commit f84d6e6
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 60 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#### v0.2.9 ???
* Possible fix for text export issue of GZ savefile
#### v0.2.9 The May Day edition
* Added ability to do basic dump of APEX engine files (like a save file) without processing entire game
* Fixed issue with not tracking missing ADF types
* Fixed processing of JC3 (missing image type info, and ADF type bug, related to missing ADF type tracking bug)
* Fix for text export issue of GZ savefile on at least on windows machine
* Will now attempt to annotate all integer and integer array fields in an ADF file to an equipment or text
* Fixed issue with building ddsc files
* Added user readable name of equipment that uses clothing models
Expand Down
2 changes: 1 addition & 1 deletion deca/db_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ def process_adf_initial(self, node: VfsNode, db: DbWrap):
return True

except AdfTypeMissing as ae:
self._comm.log('Missing Type {:08x} in {} {} {}'.format(
self._comm.log('DBCmd: Missing Type {:08x} in {} {} {}'.format(
ae.type_id, node.v_hash_to_str(), node.v_path, node.p_path))
return False

Expand Down
2 changes: 1 addition & 1 deletion deca/db_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1224,7 +1224,7 @@ def adf_type_map_load(self):
with io.BytesIO(b) as f:
v = pickle.load(f)
adf_map[k] = v
elif miss is not None and miss != 1:
elif miss is not None and miss != 0:
adf_missing.add((k, miss))
else:
raise NotImplemented(f'Unknown type record: {k}, {miss}, {b}')
Expand Down
4 changes: 4 additions & 0 deletions deca/dxgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,10 @@ def process_image_python(image, raw, nx, ny, pixel_format):
26: process_image_26, # DXGI_FORMAT_R11G11B10_FLOAT
28: process_image_28, # DXGI_FORMAT_R8G8B8A8_UNORM
60: process_image_60, # DXGI_FORMAT_R8_TYPELESS
61: process_image_60, # DXGI_FORMAT_R8_UNORM
62: process_image_60, # DXGI_FORMAT_R8_UINT
63: process_image_60, # DXGI_FORMAT_R8_SNORM
64: process_image_60, # DXGI_FORMAT_R8_SINT
71: process_image_71, # DXGI_FORMAT_BC1_UNORM
74: process_image_74, # DXGI_FORMAT_BC2_UNORM
77: process_image_77, # DXGI_FORMAT_BC3_UNORM
Expand Down
4 changes: 4 additions & 0 deletions deca/dxgi_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,10 @@ def __repr__(self):
26: [True, 4],
28: [True, 4],
60: [True, 1],
61: [True, 1],
62: [True, 1],
63: [True, 1],
64: [True, 1],
87: [True, 4],
71: [False, 8],
74: [False, 16],
Expand Down
4 changes: 2 additions & 2 deletions deca/ff_adf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,7 @@ def process_adf_in_exe(self, exepath, node_uid):

except AdfTypeMissing as ae:
self.type_missing.add((ae.type_id, node_uid))
print('Missing Type {:08x} in {} at offset {}'.format(
ae.type_id, exepath, poss))
self._type_map_updated = True

adf_sub_files.append((poss, adf.total_size))

Expand Down Expand Up @@ -1102,6 +1101,7 @@ def read_node(self, vfs: VfsDatabase, node: VfsNode):
adf = self._load_adf(buffer)
except AdfTypeMissing as ae:
self.type_missing.add((ae.type_id, node.uid))
self._type_map_updated = True
raise

return adf
110 changes: 56 additions & 54 deletions deca/ff_determine.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,61 +39,63 @@ def determine_file_type_and_size(f, file_size0):

start_pos = f.tell()
magic = f.read(256)
magic_int = struct.unpack('I', magic[0:4])[0]
magic_int = None
if len(magic) >= 20:
magic_int = struct.unpack('I', magic[0:4])[0]

if b' FDA' == magic[0:4]:
file_type = FTYPE_ADF
elif b'\x00FDA' == magic[0:4]:
file_type = FTYPE_ADF0
elif b'AVTX' == magic[0:4]:
file_type = FTYPE_AVTX
header = DdImageHeader()
header.deserialize_ddsc(magic)
file_sub_type = header.dds_header_dxt10.dxgiFormat
elif b'DDS ' == magic[0:4]:
file_type = FTYPE_DDS
header = DdImageHeader()
header.deserialize_dds(magic)
file_sub_type = header.dds_header_dxt10.dxgiFormat
elif b'AAF' == magic[0:3].upper():
file_type = FTYPE_AAF
f.seek(start_pos)
aafh = load_aaf_header(f)
file_size = aafh.size_u
elif b'SARC' == magic[4:8]:
file_type = FTYPE_SARC
elif b'RTPC' == magic[0:4]:
file_type = FTYPE_RTPC
elif b'CFX' == magic[0:3]:
file_type = FTYPE_GFX
elif b'GFX' == magic[0:3]:
file_type = FTYPE_GFX
elif b'RIFF' == magic[0:4]:
file_type = FTYPE_RIFF
elif b'OggS' == magic[0:4]:
file_type = FTYPE_OGG
elif b'BM6' == magic[0:3]:
file_type = FTYPE_BMP
elif b'BM8' == magic[0:3]:
file_type = FTYPE_BMP
elif b'TAG0' == magic[4:8]:
file_type = FTYPE_TAG0
elif b'FSB5' == magic[16:20]:
file_type = FTYPE_FSB5C
elif b'\x57\xE0\xE0\x57\x10\xC0\xC0\x10' == magic[0:8]:
file_type = FTYPE_H2014
elif b'MDI\x00' == magic[0:4]:
file_type = FTYPE_MDI
elif b'PFX\x00' == magic[0:4]:
file_type = FTYPE_PFX
elif b'\x05\x00\x00\x00RBMDL' == magic[0:9]:
file_type = FTYPE_RBMDL
elif b'KB2' == magic[0:3]:
file_type = FTYPE_BINK_KB2
elif b'BIK' == magic[0:3]:
file_type = FTYPE_BINK_BIK
elif b'GT0C' == magic[0:4]:
file_type = FTYPE_GT0C
if b' FDA' == magic[0:4]:
file_type = FTYPE_ADF
elif b'\x00FDA' == magic[0:4]:
file_type = FTYPE_ADF0
elif b'AVTX' == magic[0:4]:
file_type = FTYPE_AVTX
header = DdImageHeader()
header.deserialize_ddsc(magic)
file_sub_type = header.dds_header_dxt10.dxgiFormat
elif b'DDS ' == magic[0:4]:
file_type = FTYPE_DDS
header = DdImageHeader()
header.deserialize_dds(magic)
file_sub_type = header.dds_header_dxt10.dxgiFormat
elif b'AAF' == magic[0:3].upper():
file_type = FTYPE_AAF
f.seek(start_pos)
aafh = load_aaf_header(f)
file_size = aafh.size_u
elif b'RTPC' == magic[0:4]:
file_type = FTYPE_RTPC
elif b'CFX' == magic[0:3]:
file_type = FTYPE_GFX
elif b'GFX' == magic[0:3]:
file_type = FTYPE_GFX
elif b'RIFF' == magic[0:4]:
file_type = FTYPE_RIFF
elif b'OggS' == magic[0:4]:
file_type = FTYPE_OGG
elif b'BM6' == magic[0:3]:
file_type = FTYPE_BMP
elif b'BM8' == magic[0:3]:
file_type = FTYPE_BMP
elif b'MDI\x00' == magic[0:4]:
file_type = FTYPE_MDI
elif b'PFX\x00' == magic[0:4]:
file_type = FTYPE_PFX
elif b'SARC' == magic[4:8]:
file_type = FTYPE_SARC
elif b'TAG0' == magic[4:8]:
file_type = FTYPE_TAG0
elif b'FSB5' == magic[16:20]:
file_type = FTYPE_FSB5C
elif b'\x57\xE0\xE0\x57\x10\xC0\xC0\x10' == magic[0:8]:
file_type = FTYPE_H2014
elif b'\x05\x00\x00\x00RBMDL' == magic[0:9]:
file_type = FTYPE_RBMDL
elif b'KB2' == magic[0:3]:
file_type = FTYPE_BINK_KB2
elif b'BIK' == magic[0:3]:
file_type = FTYPE_BINK_BIK
elif b'GT0C' == magic[0:4]:
file_type = FTYPE_GT0C

# need to inspect file structure

Expand Down

0 comments on commit f84d6e6

Please sign in to comment.