Skip to content

Commit

Permalink
Code comments, corrected TexDataStringData casing
Browse files Browse the repository at this point in the history
  • Loading branch information
Galaco committed Mar 19, 2019
1 parent f38e8f9 commit 1eed777
Show file tree
Hide file tree
Showing 64 changed files with 506 additions and 507 deletions.
171 changes: 85 additions & 86 deletions bspFlags.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,142 +3,141 @@ package bsp
const (
CONTENTS_EMPTY = 0 // No contents

CONTENTS_SOLID = 0x1 // an eye is never valid in a solid
CONTENTS_WINDOW = 0x2 // translucent, but not watery (glass)
CONTENTS_AUX = 0x4
CONTENTS_GRATE = 0x8 // alpha-tested "grate" textures. Bullets/sight pass through, but solids don't
CONTENTS_SLIME = 0x10
CONTENTS_WATER = 0x20
CONTENTS_BLOCKLOS = 0x40 // block AI line of sight
CONTENTS_OPAQUE = 0x80 // things that cannot be seen through (may be non-solid though)
CONTENTS_SOLID = 0x1 // an eye is never valid in a solid
CONTENTS_WINDOW = 0x2 // translucent, but not watery (glass)
CONTENTS_AUX = 0x4
CONTENTS_GRATE = 0x8 // alpha-tested "grate" textures. Bullets/sight pass through, but solids don't
CONTENTS_SLIME = 0x10
CONTENTS_WATER = 0x20
CONTENTS_BLOCKLOS = 0x40 // block AI line of sight
CONTENTS_OPAQUE = 0x80 // things that cannot be seen through (may be non-solid though)
LAST_VISIBLE_CONTENTS = 0x80

ALL_VISIBLE_CONTENTS = LAST_VISIBLE_CONTENTS | (LAST_VISIBLE_CONTENTS - 1)

CONTENTS_TESTFOGVOLUME = 0x100
CONTENTS_UNUSED = 0x200
CONTENTS_UNUSED = 0x200

// unused
// NOTE: If it's visible, grab from the top + update LAST_VISIBLE_CONTENTS
// if not visible, then grab from the bottom.
// unused
// NOTE: If it's visible, grab from the top + update LAST_VISIBLE_CONTENTS
// if not visible, then grab from the bottom.
CONTENTS_UNUSED6 = 0x400

CONTENTS_TEAM1 = 0x800 // per team contents used to differentiate collisions
CONTENTS_TEAM2 = 0x1000 // between players and objects on different teams

// ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW
// ignore CONTENTS_OPAQUE on surfaces that have SURF_NODRAW
CONTENTS_IGNORE_NODRAW_OPAQUE = 0x2000

// hits entities which are MOVETYPE_PUSH (doors, plats, etc.)
// hits entities which are MOVETYPE_PUSH (doors, plats, etc.)
CONTENTS_MOVEABLE = 0x4000

// remaining contents are non-visible, and don't eat brushes
// remaining contents are non-visible, and don't eat brushes
CONTENTS_AREAPORTAL = 0x8000

CONTENTS_PLAYERCLIP = 0x10000
CONTENTS_PLAYERCLIP = 0x10000
CONTENTS_MONSTERCLIP = 0x20000

// currents can be added to any other contents, and may be mixed
CONTENTS_CURRENT_0 = 0x40000
CONTENTS_CURRENT_90 = 0x80000
CONTENTS_CURRENT_180 = 0x100000
CONTENTS_CURRENT_270 = 0x200000
CONTENTS_CURRENT_UP = 0x400000
// currents can be added to any other contents, and may be mixed
CONTENTS_CURRENT_0 = 0x40000
CONTENTS_CURRENT_90 = 0x80000
CONTENTS_CURRENT_180 = 0x100000
CONTENTS_CURRENT_270 = 0x200000
CONTENTS_CURRENT_UP = 0x400000
CONTENTS_CURRENT_DOWN = 0x800000

CONTENTS_ORIGIN = 0x1000000 // removed before bsping an entity

CONTENTS_MONSTER = 0x2000000 // should never be on a brush, only in game
CONTENTS_DEBRIS = 0x4000000
CONTENTS_DETAIL = 0x8000000 // brushes to be added after vis leafs
CONTENTS_MONSTER = 0x2000000 // should never be on a brush, only in game
CONTENTS_DEBRIS = 0x4000000
CONTENTS_DETAIL = 0x8000000 // brushes to be added after vis leafs
CONTENTS_TRANSLUCENT = 0x10000000 // auto set if any surface has trans
CONTENTS_LADDER = 0x20000000
CONTENTS_HITBOX = 0x40000000 // use accurate hitboxes on trace

// NOTE: These are stored in a short in the engine now. Don't use more than 16 bits
SURF_LIGHT = 0x0001 // value will hold the light strength
SURF_SKY2D = 0x0002 // don't draw, indicates we should skylight + draw 2d sky but not draw the 3D skybox
SURF_SKY = 0x0004 // don't draw, but add to skybox
SURF_WARP = 0x0008 // turbulent water warp
SURF_TRANS = 0x0010
CONTENTS_LADDER = 0x20000000
CONTENTS_HITBOX = 0x40000000 // use accurate hitboxes on trace

// NOTE: These are stored in a short in the engine now. Don't use more than 16 bits
SURF_LIGHT = 0x0001 // value will hold the light strength
SURF_SKY2D = 0x0002 // don't draw, indicates we should skylight + draw 2d sky but not draw the 3D skybox
SURF_SKY = 0x0004 // don't draw, but add to skybox
SURF_WARP = 0x0008 // turbulent water warp
SURF_TRANS = 0x0010
SURF_NOPORTAL = 0x0020 // the surface can not have a portal placed on it
SURF_TRIGGER = 0x0040 // FIXME: This is an xbox hack to work around elimination of trigger surfaces, which breaks occluders
SURF_NODRAW = 0x0080 // don't bother referencing the texture
SURF_TRIGGER = 0x0040 // FIXME: This is an xbox hack to work around elimination of trigger surfaces, which breaks occluders
SURF_NODRAW = 0x0080 // don't bother referencing the texture

SURF_HINT = 0x0100 // make a primary bsp splitter

SURF_SKIP = 0x0200 // completely ignore, allowing non-closed brushes
SURF_NOLIGHT = 0x0400 // Don't calculate light
SURF_SKIP = 0x0200 // completely ignore, allowing non-closed brushes
SURF_NOLIGHT = 0x0400 // Don't calculate light
SURF_BUMPLIGHT = 0x0800 // calculate three lightmaps for the surface for bumpmapping
SURF_NOSHADOWS = 0x1000 // Don't receive shadows
SURF_NODECALS = 0x2000 // Don't receive decals
SURF_NOCHOP = 0x4000 // Don't subdivide patches on this surface
SURF_HITBOX = 0x8000 // surface is part of a hitbox
SURF_NODECALS = 0x2000 // Don't receive decals
SURF_NOCHOP = 0x4000 // Don't subdivide patches on this surface
SURF_HITBOX = 0x8000 // surface is part of a hitbox

// -----------------------------------------------------
// spatial content masks - used for spatial queries (traceline,etc.)
// -----------------------------------------------------
MASK_ALL = (0xFFFFFFFF)
// -----------------------------------------------------
// spatial content masks - used for spatial queries (traceline,etc.)
// -----------------------------------------------------
MASK_ALL = (0xFFFFFFFF)

// everything that is normally solid
MASK_SOLID = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE)
// everything that is normally solid
MASK_SOLID = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE)

// everything that blocks player movement
MASK_PLAYERSOLID = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE)
// everything that blocks player movement
MASK_PLAYERSOLID = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE)

// blocks npc movement
MASK_NPCSOLID = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE)
// blocks npc movement
MASK_NPCSOLID = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTERCLIP | CONTENTS_WINDOW | CONTENTS_MONSTER | CONTENTS_GRATE)

// water physics in these contents
// water physics in these contents
MASK_WATER = (CONTENTS_WATER | CONTENTS_MOVEABLE | CONTENTS_SLIME)

// everything that blocks lighting
MASK_OPAQUE = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_OPAQUE)
// everything that blocks lighting
MASK_OPAQUE = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_OPAQUE)

// everything that blocks lighting, but with monsters added.
MASK_OPAQUE_AND_NPCS = (MASK_OPAQUE | CONTENTS_MONSTER)
// everything that blocks lighting, but with monsters added.
MASK_OPAQUE_AND_NPCS = (MASK_OPAQUE | CONTENTS_MONSTER)

// everything that blocks line of sight for AI
MASK_BLOCKLOS = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_BLOCKLOS)
// everything that blocks line of sight for AI
MASK_BLOCKLOS = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_BLOCKLOS)

// everything that blocks line of sight for AI plus NPCs
MASK_BLOCKLOS_AND_NPCS = (MASK_BLOCKLOS | CONTENTS_MONSTER)
// everything that blocks line of sight for AI plus NPCs
MASK_BLOCKLOS_AND_NPCS = (MASK_BLOCKLOS | CONTENTS_MONSTER)

// everything that blocks line of sight for players
MASK_VISIBLE = (MASK_OPAQUE | CONTENTS_IGNORE_NODRAW_OPAQUE)
// everything that blocks line of sight for players
MASK_VISIBLE = (MASK_OPAQUE | CONTENTS_IGNORE_NODRAW_OPAQUE)

// everything that blocks line of sight for players, but with monsters added.
MASK_VISIBLE_AND_NPCS = (MASK_OPAQUE_AND_NPCS | CONTENTS_IGNORE_NODRAW_OPAQUE)
// everything that blocks line of sight for players, but with monsters added.
MASK_VISIBLE_AND_NPCS = (MASK_OPAQUE_AND_NPCS | CONTENTS_IGNORE_NODRAW_OPAQUE)

// bullets see these as solid
MASK_SHOT = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_HITBOX)
// bullets see these as solid
MASK_SHOT = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_HITBOX)

// non-raycasted weapons see this as solid (includes grates)
MASK_SHOT_HULL = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_GRATE)
// non-raycasted weapons see this as solid (includes grates)
MASK_SHOT_HULL = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_MONSTER | CONTENTS_WINDOW | CONTENTS_DEBRIS | CONTENTS_GRATE)

// hits solids (not grates) and passes through everything else
MASK_SHOT_PORTAL = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER)
// hits solids (not grates) and passes through everything else
MASK_SHOT_PORTAL = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTER)

// everything normally solid, except monsters (world+brush only)
MASK_SOLID_BRUSHONLY = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_GRATE)
// everything normally solid, except monsters (world+brush only)
MASK_SOLID_BRUSHONLY = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_GRATE)

// everything normally solid for player movement, except monsters (world+brush only)
MASK_PLAYERSOLID_BRUSHONLY = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_PLAYERCLIP | CONTENTS_GRATE)
// everything normally solid for player movement, except monsters (world+brush only)
MASK_PLAYERSOLID_BRUSHONLY = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_PLAYERCLIP | CONTENTS_GRATE)

// everything normally solid for npc movement, except monsters (world+brush only)
MASK_NPCSOLID_BRUSHONLY = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE)
// everything normally solid for npc movement, except monsters (world+brush only)
MASK_NPCSOLID_BRUSHONLY = (CONTENTS_SOLID | CONTENTS_MOVEABLE | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE)

// just the world, used for route rebuilding
MASK_NPCWORLDSTATIC = (CONTENTS_SOLID | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE)
// just the world, used for route rebuilding
MASK_NPCWORLDSTATIC = (CONTENTS_SOLID | CONTENTS_WINDOW | CONTENTS_MONSTERCLIP | CONTENTS_GRATE)

// These are things that can split areaportals
MASK_SPLITAREAPORTAL = (CONTENTS_WATER | CONTENTS_SLIME)
// These are things that can split areaportals
MASK_SPLITAREAPORTAL = (CONTENTS_WATER | CONTENTS_SLIME)

// UNDONE: This is untested, any moving water
MASK_CURRENT = (CONTENTS_CURRENT_0 | CONTENTS_CURRENT_90 | CONTENTS_CURRENT_180 | CONTENTS_CURRENT_270 | CONTENTS_CURRENT_UP | CONTENTS_CURRENT_DOWN)
// UNDONE: This is untested, any moving water
MASK_CURRENT = (CONTENTS_CURRENT_0 | CONTENTS_CURRENT_90 | CONTENTS_CURRENT_180 | CONTENTS_CURRENT_270 | CONTENTS_CURRENT_UP | CONTENTS_CURRENT_DOWN)

// everything that blocks corpse movement
// UNDONE: Not used yet / may be deleted
MASK_DEADSOLID = (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_GRATE)
// everything that blocks corpse movement
// UNDONE: Not used yet / may be deleted
MASK_DEADSOLID = (CONTENTS_SOLID | CONTENTS_PLAYERCLIP | CONTENTS_WINDOW | CONTENTS_GRATE)
)

2 changes: 1 addition & 1 deletion bsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestLumpExports(t *testing.T) {
for lumpIndex < 64 {
lump := file.GetLump(LumpId(lumpIndex))
rawLump := file.GetLumpRaw(LumpId(lumpIndex))
lumpBytes,err := lump.Marshall()
lumpBytes, err := lump.Marshall()
if err != nil {
t.Error(err)
}
Expand Down
1 change: 0 additions & 1 deletion flags/constants.go
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
package flags

2 changes: 1 addition & 1 deletion internal/versions/v20.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func Getv20Lump(index int) (lumps.ILump, error) {
case 42:
ret = &lumps.Cubemap{}
case 43:
ret = &lumps.TexdataStringData{}
ret = &lumps.TexDataStringData{}
case 44:
ret = &lumps.TexDataStringTable{}
case 45:
Expand Down
8 changes: 4 additions & 4 deletions internal/versions/versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@ import (
)

func TestGetLumpForVersion(t *testing.T) {
l,err := GetLumpForVersion(987, 1)
l, err := GetLumpForVersion(987, 1)
if err != nil {
t.Error(err)
}
if reflect.TypeOf(l) != reflect.TypeOf(&lumps.Unimplemented{}) {
t.Error("Lump type mismatch.")
}

l,err = GetLumpForVersion(19, 4)
l, err = GetLumpForVersion(19, 4)
if err != nil {
t.Error(err)
}
if reflect.TypeOf(l) != reflect.TypeOf(&lumps.Visibility{}) {
t.Error("Lump type mismatch.")
}

l,err = GetLumpForVersion(20, 4)
l, err = GetLumpForVersion(20, 4)
if err != nil {
t.Error(err)
}
if reflect.TypeOf(l) != reflect.TypeOf(&lumps.Visibility{}) {
t.Error("Lump type mismatch.")
}

l,err = GetLumpForVersion(21, 4)
l, err = GetLumpForVersion(21, 4)
if err != nil {
t.Error(err)
}
Expand Down
3 changes: 1 addition & 2 deletions lump.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package bsp

import (
"github.com/galaco/bsp/lumps"
"github.com/galaco/bsp/internal/versions"
"github.com/galaco/bsp/lumps"
"log"
)


// Container for a lump. Also includes metadata about the lump.
// N.B. Some information mirrors the header's lump descriptor, but header information should not be trusted after
// import completion.
Expand Down
Loading

0 comments on commit 1eed777

Please sign in to comment.