summaryrefslogtreecommitdiff
path: root/extractor/grf.gd
diff options
context:
space:
mode:
Diffstat (limited to 'extractor/grf.gd')
-rw-r--r--extractor/grf.gd20
1 files changed, 18 insertions, 2 deletions
diff --git a/extractor/grf.gd b/extractor/grf.gd
index 3739c8c..7e7e93c 100644
--- a/extractor/grf.gd
+++ b/extractor/grf.gd
@@ -140,6 +140,7 @@ class FileEntry:
@warning_ignore("shadowed_variable")
static func from_bytes_with_filename(bytes: PackedByteArray, file_name: String):
+ print(file_name)
var file_entry = FileEntry.new()
file_entry.file_name = file_name
@@ -177,10 +178,10 @@ static func open(path: String):
file_entry_offset + file_name_size,
file_entry_offset + file_name_size + FileEntry.BYTE_LENGTH
),
- grf.file_table.decompressed_record_headers.slice(
+ GRF.decode_string(grf.file_table.decompressed_record_headers.slice(
file_entry_offset,
file_entry_offset + file_name_size
- ).get_string_from_ascii()
+ ))
)
grf.file_entries.append(file_entry)
@@ -201,3 +202,18 @@ func extract(destination: String = "res://data"):
# TODO: write pngs for sprites (and .tres files maybe if necessary)
# TODO: (also maybe write .tres files for action data files(whatever they are))
+
+
+
+static func decode_string(bytes: PackedByteArray):
+ return bytes.get_string_from_ascii()
+ # TODO: check unicode codepoints and parse accordingly
+ var string = bytes.get_string_from_utf32()
+ if string == "":
+ string = bytes.get_string_from_utf16()
+ if string == "":
+ string = bytes.get_string_from_utf8()
+ if string == "":
+ string = bytes.get_string_from_ascii()
+
+ return string