Skip to content

Commit

Permalink
Proper commenting and standards
Browse files Browse the repository at this point in the history
  • Loading branch information
Galaco committed Nov 9, 2018
1 parent 3e574ae commit bb9e0d0
Show file tree
Hide file tree
Showing 69 changed files with 418 additions and 235 deletions.
36 changes: 18 additions & 18 deletions lump.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ import (
"log"
)

const LUMP_ENTITIES = 0
const LUMP_PLANES = 1
const LUMP_TEXDATA = 2
const LUMP_VERTEXES = 3
const LUMP_VISIBILITY = 4
const LUMP_NODES = 5
const LUMP_TEXINFO = 6
const LUMP_FACES = 7
const LUMP_ENTITIES = 0 // Entity keyvalue data stored as string
const LUMP_PLANES = 1 // bsp planes
const LUMP_TEXDATA = 2 // texture data used by bsp faces
const LUMP_VERTEXES = 3 // vertex data
const LUMP_VISIBILITY = 4 // vvis calculated visibility pvs & pas information
const LUMP_NODES = 5 // bsp node tree entries
const LUMP_TEXINFO = 6 // face texture information
const LUMP_FACES = 7 // bsp faces
const LUMP_LIGHTING = 8
const LUMP_OCCLUSION = 9
const LUMP_LEAFS = 10
const LUMP_FACEIDS = 11 // contents is normally stripped out
const LUMP_EDGES = 12
const LUMP_SURFEDGES = 13
const LUMP_MODELS = 14
const LUMP_FACEIDS = 11 // contents is normally stripped out by compiler
const LUMP_EDGES = 12 // face edges. v1->v2, vertex order may be reversed
const LUMP_SURFEDGES = 13 //
const LUMP_MODELS = 14 // models are root bsp nodes. m[0] = worldspawn. m[0+n] are brush entity data
const LUMP_WORLDLIGHTS = 15
const LUMP_LEAFFACES = 16
const LUMP_LEAFBRUSHES = 17
const LUMP_LEAFFACES = 16 // faces that separate leaves.
const LUMP_LEAFBRUSHES = 17 // brushes that define a leaf volume
const LUMP_BRUSHES = 18
const LUMP_BRUSHSIDES = 19
const LUMP_AREAS = 20
Expand All @@ -49,16 +49,16 @@ const LUMP_VERTNORMALINDICES = 31
const LUMP_DISP_LIGHTMAP_ALPHAS = 32 // contents is normally stripped out
const LUMP_DISP_VERTS = 33
const LUMP_DISP_LIGHTMAP_SAMPLE_POSITIONS = 34
const LUMP_GAME_LUMP = 35
const LUMP_GAME_LUMP = 35 // game specific data. includes staticprop data
const LUMP_LEAFWATERDATA = 36
const LUMP_PRIMITIVES = 37
const LUMP_PRIMVERTS = 38
const LUMP_PRIMINDICES = 39
const LUMP_PAKFILE = 40
const LUMP_PAKFILE = 40 // uncompressed zip of packed custom content
const LUMP_CLIPPORTALVERTS = 41
const LUMP_CUBEMAPS = 42
const LUMP_TEXDATA_STRING_DATA = 43
const LUMP_TEXDATA_STRING_TABLE = 44
const LUMP_TEXDATA_STRING_DATA = 43 // raw string data of material paths
const LUMP_TEXDATA_STRING_TABLE = 44 // references entries in the string data lump
const LUMP_OVERLAYS = 45
const LUMP_LEAFMINDISTTOWATER = 46
const LUMP_FACE_MACRO_TEXTURE_INFO = 47
Expand Down
7 changes: 4 additions & 3 deletions lumps/area.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"unsafe"
)

/**
Lump 20: Areas
*/
// Lump 20: Areas
type Area struct {
LumpGeneric
data []primitives.Area
}

// Import this lump from raw byte data
func (lump *Area) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
if length == 0 {
Expand All @@ -30,10 +29,12 @@ func (lump *Area) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
}

// Get internal format structure data
func (lump *Area) GetData() []primitives.Area {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *Area) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
7 changes: 4 additions & 3 deletions lumps/areaportal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"unsafe"
)

/**
Lump 21: Areaportals
*/
// Lump 21: Areaportals
type AreaPortal struct {
LumpGeneric
data []primitives.AreaPortal
}

// Import this lump from raw byte data
func (lump *AreaPortal) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
if length == 0 {
Expand All @@ -28,10 +27,12 @@ func (lump *AreaPortal) FromBytes(raw []byte, length int32) {
}
}

// Get internal format structure data
func (lump *AreaPortal) GetData() []primitives.AreaPortal {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *AreaPortal) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
7 changes: 4 additions & 3 deletions lumps/brush.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"unsafe"
)

/**
Lump 18: Brush
*/
// Lump 18: Brush
type Brush struct {
LumpGeneric
data []primitives.Brush
}

// Import this lump from raw byte data
func (lump *Brush) FromBytes(raw []byte, length int32) {
lump.data = make([]primitives.Brush, length/int32(unsafe.Sizeof(primitives.Brush{})))
err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data)
Expand All @@ -25,10 +24,12 @@ func (lump *Brush) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
}

// Get internal format structure data
func (lump *Brush) GetData() []primitives.Brush {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *Brush) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
7 changes: 4 additions & 3 deletions lumps/brushside.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"unsafe"
)

/**
Lump 19: BrushSide
*/
// Lump 19: BrushSide
type BrushSide struct {
LumpGeneric
data []primitives.BrushSide // MAX_MAP_BRUSHSIDES = 65536
}

// Import this lump from raw byte data
func (lump *BrushSide) FromBytes(raw []byte, length int32) {
lump.data = make([]primitives.BrushSide, length/int32(unsafe.Sizeof(primitives.BrushSide{})))
err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data)
Expand All @@ -25,10 +24,12 @@ func (lump *BrushSide) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
}

// Get internal format structure data
func (lump *BrushSide) GetData() []primitives.BrushSide {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *BrushSide) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
8 changes: 4 additions & 4 deletions lumps/clipportalverts.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import (
"unsafe"
)

/**
Lump 41: ClipPortalVerts
*/

// Lump 41: ClipPortalVerts
type ClipPortalVerts struct {
LumpGeneric
data []mgl32.Vec3
}

// Import this lump from raw byte data
func (lump *ClipPortalVerts) FromBytes(raw []byte, length int32) {
lump.data = make([]mgl32.Vec3, length/int32(unsafe.Sizeof(mgl32.Vec3{})))
err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data)
Expand All @@ -26,10 +24,12 @@ func (lump *ClipPortalVerts) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
}

// Get internal format structure data
func (lump *ClipPortalVerts) GetData() []mgl32.Vec3 {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *ClipPortalVerts) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
7 changes: 4 additions & 3 deletions lumps/cubemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"unsafe"
)

/**
Lump 42: Cubemaps
*/
// Lump 42: Cubemaps
type Cubemap struct {
LumpGeneric
data []primitives.CubemapSample
}

// Import this lump from raw byte data
func (lump *Cubemap) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
if length == 0 {
Expand All @@ -28,10 +27,12 @@ func (lump *Cubemap) FromBytes(raw []byte, length int32) {
}
}

// Get internal format structure data
func (lump *Cubemap) GetData() []primitives.CubemapSample {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *Cubemap) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
8 changes: 4 additions & 4 deletions lumps/dispinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import (
"unsafe"
)

/**
Lump 26: DispInfo
*/

// Lump 26: DispInfo
type DispInfo struct {
LumpGeneric
data []primitives.DispInfo
}

// Import this lump from raw byte data
func (lump *DispInfo) FromBytes(raw []byte, length int32) {
lump.data = make([]primitives.DispInfo, length/int32(unsafe.Sizeof(primitives.DispInfo{})))
err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data)
Expand All @@ -26,10 +24,12 @@ func (lump *DispInfo) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
}

// Get internal format structure data
func (lump *DispInfo) GetData() []primitives.DispInfo {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *DispInfo) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
8 changes: 5 additions & 3 deletions lumps/displightmapsampleposition.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
package lumps

/**
Lump 34: DispLightmapSamplePosition
*/
// Lump 34: DispLightmapSamplePosition
// NOTE: This does NOT have a mapped format yet, and is readable as []byte only
type DispLightmapSamplePosition struct {
LumpGeneric
data []byte
}

// Import this lump from raw byte data
func (lump *DispLightmapSamplePosition) FromBytes(raw []byte, length int32) {
lump.data = raw
lump.LumpInfo.SetLength(length)
}

// Get internal format structure data
func (lump *DispLightmapSamplePosition) GetData() []byte {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *DispLightmapSamplePosition) ToBytes() []byte {
return lump.data
}
7 changes: 4 additions & 3 deletions lumps/disptris.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"unsafe"
)

/**
Lump 48: DispTris
*/
// Lump 48: DispTris
type DispTris struct {
LumpGeneric
data []primitives.DispTri
}

// Import this lump from raw byte data
func (lump *DispTris) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
if length == 0 {
Expand All @@ -29,10 +28,12 @@ func (lump *DispTris) FromBytes(raw []byte, length int32) {
}
}

// Get internal format structure data
func (lump *DispTris) GetData() []primitives.DispTri {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *DispTris) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
7 changes: 4 additions & 3 deletions lumps/dispvert.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import (
"unsafe"
)

/**
Lump 33: DispVert
*/
// Lump 33: DispVert
type DispVert struct {
LumpGeneric
data []primitives.DispVert
}

// Import this lump from raw byte data
func (lump *DispVert) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
if length == 0 {
Expand All @@ -29,10 +28,12 @@ func (lump *DispVert) FromBytes(raw []byte, length int32) {
}
}

// Get internal format structure data
func (lump *DispVert) GetData() []primitives.DispVert {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *DispVert) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
7 changes: 4 additions & 3 deletions lumps/edge.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import (
"log"
)

/**
Lump 12: Edge
*/
// Lump 12: Edge
type Edge struct {
LumpGeneric
data [][2]uint16 // MAX_MAP_EDGES = 256000
}

// Import this lump from raw byte data
func (lump *Edge) FromBytes(raw []byte, length int32) {
lump.data = make([][2]uint16, length/4)
err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data)
Expand All @@ -23,10 +22,12 @@ func (lump *Edge) FromBytes(raw []byte, length int32) {
lump.LumpInfo.SetLength(length)
}

// Get internal format structure data
func (lump *Edge) GetData() [][2]uint16 {
return lump.data
}

// Dump this lump back to raw byte data
func (lump *Edge) ToBytes() []byte {
var buf bytes.Buffer
binary.Write(&buf, binary.LittleEndian, lump.data)
Expand Down
Loading

0 comments on commit bb9e0d0

Please sign in to comment.