summaryrefslogtreecommitdiff
path: root/extractor/grf.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-11 12:55:08 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-11 12:55:08 +0100
commite3c185e05823e30eccd7728ceda2ee57cc66fd4d (patch)
tree96cced31157175bb0a3620b0e3b8d99122f298ac /extractor/grf.gd
parent688790b5dc0ea8f51a99e42a00c7510b9bd87aa6 (diff)
next commit
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