Skip to content

Commit

Permalink
fix some texture convert failed case
Browse files Browse the repository at this point in the history
  • Loading branch information
redsuns-chan committed Aug 4, 2022
1 parent f690921 commit 000fa58
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sdgo-texture-extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def extract_texture(file_name):
fhex = f.read(file_size).hex().upper()

# remove zoa header
if fhex.startswith("5A4F41544558310000000000"):
fhex = fhex.replace("5A4F41544558310000000000", "")
if fhex.startswith("5A4F415445583100"):
fhex = fhex[24:]

# detect type
if fhex.startswith("424D"):
Expand All @@ -23,8 +23,10 @@ def extract_texture(file_name):
found_type = "png"
elif fhex.endswith("54525545564953494F4E2D5846494C452E00"):
found_type = "tga"
else: # if cannot find any recognized header, assume the file is dds, may need to improve this logic
elif fhex.startswith("44445320"): # if cannot find any recognized header, assume the file is dds, may need to improve this logic
found_type = "dds"
else:
found_type = "tga"
new_file = open(target_path + file_name.replace(".txr", "." + found_type), "wb")
new_file.write(bytes.fromhex(fhex))
f.close()
Expand Down

0 comments on commit 000fa58

Please sign in to comment.