-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive_het_table.go
53 lines (41 loc) · 1.41 KB
/
archive_het_table.go
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
41
42
43
44
45
46
47
48
49
50
51
52
53
package mpq
import (
"fmt"
"github.com/Gophercraft/mpq/info"
)
func (archive *Archive) contains_het_table() bool {
return archive.header.BetTablePos64 != 0
}
// The header of the HET table
func (archive *Archive) HetTableHeader() (header *info.HetTableHeader) {
return &archive.het_table.header
}
// The number of entries in the HET table
func (archive *Archive) HetTableCount() (count uint32) {
count = archive.het_table.header.TotalEntryCount
return
}
// Return the name hash 1 value at an index in the HET table
func (archive *Archive) HetTableNameHash1Index(het_table_index uint32) (name_hash_1 uint8, err error) {
if het_table_index >= archive.HetTableCount() {
err = fmt.Errorf("mpq: het table index out of bounds")
return
}
name_hash_1 = archive.het_table.name_hashes[het_table_index]
return
}
// Return the BET table index of a HET table entry index
func (archive *Archive) HetTableIndexBetTableIndex(het_table_index uint32) (bet_table_index uint32, err error) {
if het_table_index >= archive.HetTableCount() {
err = fmt.Errorf("mpq: het table index out of bounds")
return
}
index_bit_length := uint64(archive.het_table.header.IndexSizeTotal)
var bet_table_index_64 uint64
bet_table_index_64, err = archive.het_table.bet_indices.Uint(index_bit_length*uint64(het_table_index), uint8(archive.het_table.header.IndexSize))
if err != nil {
return
}
bet_table_index = uint32(bet_table_index_64)
return
}