-
Notifications
You must be signed in to change notification settings - Fork 4
/
bsp.go
47 lines (39 loc) · 1.04 KB
/
bsp.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
package bsp
import "github.com/galaco/bsp/lumps"
// Bsp is the root .bsp filetype container.
// Consists of a 1036byte header and 64 lump blocks.
type Bsp struct {
header Header
lumps [64]Lump
}
// Header is the Bsp header. Contains format and lump layout data.
// Do not trust lump information between import and export
type Header struct {
Id int32
Version int32
Lumps [64]HeaderLump
Revision int32
}
// HeaderLump contains layout information for a given lump, stored in the Header.
type HeaderLump struct {
Offset int32
Length int32
Version int32
Id [4]byte
}
// Header gets the header for a bsp.
func (bsp *Bsp) Header() *Header {
return &bsp.header
}
// Lump gets the lump for a given id.
func (bsp *Bsp) Lump(index LumpId) lumps.ILump {
return bsp.RawLump(index).Contents()
}
// RawLump gets the lump for a given id.
func (bsp *Bsp) RawLump(index LumpId) *Lump {
return &bsp.lumps[int(index)]
}
// SetLump sets the lump data for a given id.
func (bsp *Bsp) SetLump(index LumpId, lump Lump) {
bsp.lumps[int(index)] = lump
}