summaryrefslogtreecommitdiff
path: root/extractor/grf.gd
blob: 27dcab0165b254d21edce82a5cf7cc3d0b4eca27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class_name GRF


class Header:
	static var byte_length: int = 46
	
	## Byte Length: 15
	## Master of Magic
	var signature: String
	
	## Byte Length: 15
	var encryption: PackedByteArray
	
	## Byte Type: u32
	## Byte Length: 4
	var file_table_offset: int
	
	## Byte Type: u32
	## Byte Length: 4
	var reserved_files: int
	
	## Byte Type: u32
	## Byte Length: 4
	var file_count: int
	
	## Byte Type: u32
	## Byte Length: 4
	var version: int
	
	
	static func from_file(file: FileAccess):
		var header = Header.new()
		header.signature = file.get_buffer(15).get_string_from_utf8()
		header.encryption = file.get_buffer(15)
		header.file_table_offset = file.get_buffer(4).decode_u32(0)
		header.reserved_files = file.get_buffer(4).decode_u32(0)
		header.file_count = file.get_buffer(4).decode_u32(0)
		header.version = file.get_buffer(4).decode_u32(0)
		
		return header