From 1eed7779acef8bd12c5e58f42f0c90f7f2cd03cb Mon Sep 17 00:00:00 2001 From: Galaco Date: Tue, 19 Mar 2019 14:53:35 +0000 Subject: [PATCH] Code comments, corrected TexDataStringData casing --- bspFlags.go | 171 ++++++++++++++-------------- bsp_test.go | 2 +- flags/constants.go | 1 - internal/versions/v20.go | 2 +- internal/versions/versions_test.go | 8 +- lump.go | 3 +- lumpFlags.go | 150 ++++++++++++------------ lump_test.go | 2 +- lumps/area.go | 12 +- lumps/areaportal.go | 12 +- lumps/brush.go | 12 +- lumps/brushside.go | 12 +- lumps/clipportalverts.go | 12 +- lumps/cubemap.go | 12 +- lumps/dispinfo.go | 12 +- lumps/displightmapsampleposition.go | 12 +- lumps/disptris.go | 12 +- lumps/dispvert.go | 12 +- lumps/edge.go | 12 +- lumps/entdata.go | 10 +- lumps/face.go | 12 +- lumps/facehdr.go | 12 +- lumps/faceid.go | 12 +- lumps/facemacrotextureinfo.go | 12 +- lumps/game.go | 20 ++-- lumps/interface.go | 3 +- lumps/leaf.go | 21 ++-- lumps/leafambientindex.go | 12 +- lumps/leafambientindexhdr.go | 12 +- lumps/leafambientlighting.go | 12 +- lumps/leafambientlightinghdr.go | 12 +- lumps/leafbrush.go | 12 +- lumps/leafface.go | 10 +- lumps/leafmindisttowater.go | 12 +- lumps/leafwaterdata.go | 12 +- lumps/lighting.go | 12 +- lumps/lump.go | 2 +- lumps/mapflags.go | 12 +- lumps/model.go | 12 +- lumps/node.go | 12 +- lumps/occlusion.go | 12 +- lumps/overlay.go | 12 +- lumps/overlayfade.go | 12 +- lumps/pakfile.go | 10 +- lumps/physcollide.go | 24 ++-- lumps/physdisp.go | 10 +- lumps/planes.go | 12 +- lumps/primindice.go | 12 +- lumps/primitive.go | 12 +- lumps/primvert.go | 12 +- lumps/surfedge.go | 12 +- lumps/texdata.go | 12 +- lumps/texdatastringdata.go | 18 +-- lumps/texdatastringtable.go | 12 +- lumps/texinfo.go | 12 +- lumps/unimplemented.go | 12 +- lumps/vertex.go | 12 +- lumps/vertnormal.go | 12 +- lumps/vertnormalindice.go | 12 +- lumps/visibility.go | 12 +- lumps/worldlight.go | 12 +- lumps/worldlighthdr.go | 12 +- reader.go | 2 +- writer.go | 16 +-- 64 files changed, 506 insertions(+), 507 deletions(-) diff --git a/bspFlags.go b/bspFlags.go index e58f100..d4c6018 100644 --- a/bspFlags.go +++ b/bspFlags.go @@ -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) ) - diff --git a/bsp_test.go b/bsp_test.go index b2138bd..b57e2d8 100644 --- a/bsp_test.go +++ b/bsp_test.go @@ -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) } diff --git a/flags/constants.go b/flags/constants.go index 45466ba..0cfcbd5 100644 --- a/flags/constants.go +++ b/flags/constants.go @@ -1,2 +1 @@ package flags - diff --git a/internal/versions/v20.go b/internal/versions/v20.go index b6f04cb..0446a58 100644 --- a/internal/versions/v20.go +++ b/internal/versions/v20.go @@ -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: diff --git a/internal/versions/versions_test.go b/internal/versions/versions_test.go index 09ca5b8..1fbed32 100644 --- a/internal/versions/versions_test.go +++ b/internal/versions/versions_test.go @@ -7,7 +7,7 @@ import ( ) func TestGetLumpForVersion(t *testing.T) { - l,err := GetLumpForVersion(987, 1) + l, err := GetLumpForVersion(987, 1) if err != nil { t.Error(err) } @@ -15,7 +15,7 @@ func TestGetLumpForVersion(t *testing.T) { t.Error("Lump type mismatch.") } - l,err = GetLumpForVersion(19, 4) + l, err = GetLumpForVersion(19, 4) if err != nil { t.Error(err) } @@ -23,7 +23,7 @@ func TestGetLumpForVersion(t *testing.T) { t.Error("Lump type mismatch.") } - l,err = GetLumpForVersion(20, 4) + l, err = GetLumpForVersion(20, 4) if err != nil { t.Error(err) } @@ -31,7 +31,7 @@ func TestGetLumpForVersion(t *testing.T) { t.Error("Lump type mismatch.") } - l,err = GetLumpForVersion(21, 4) + l, err = GetLumpForVersion(21, 4) if err != nil { t.Error(err) } diff --git a/lump.go b/lump.go index ed704a5..840bd38 100644 --- a/lump.go +++ b/lump.go @@ -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. diff --git a/lumpFlags.go b/lumpFlags.go index 6f5fb5c..12fb11f 100644 --- a/lumpFlags.go +++ b/lumpFlags.go @@ -6,153 +6,153 @@ type LumpId int // Lump Identifiers const ( // LumpEntities is Entity keyvalue data stored as string - LumpEntities = LumpId(0) + LumpEntities = LumpId(0) // LumpPlanes is bsp planes - LumpPlanes = LumpId(1) + LumpPlanes = LumpId(1) // LumpTexData is texture data used by bsp faces - LumpTexData = LumpId(2) + LumpTexData = LumpId(2) // LumpVertexes is vertex data - LumpVertexes = LumpId(3) + LumpVertexes = LumpId(3) // LumpVisibility is vvis calculated visibility pvs & pas information - LumpVisibility = LumpId(4) + LumpVisibility = LumpId(4) // LumpNodes is bsp node tree entries - LumpNodes = LumpId(5) + LumpNodes = LumpId(5) // LumpTexInfo is face texture information - LumpTexInfo = LumpId(6) + LumpTexInfo = LumpId(6) // LumpFaces is bsp faces - LumpFaces = LumpId(7) + LumpFaces = LumpId(7) // LumpLighting - LumpLighting = LumpId(8) + LumpLighting = LumpId(8) // LumpOcclusion - LumpOcclusion = LumpId(9) + LumpOcclusion = LumpId(9) // LumpLeafs - LumpLeafs = LumpId(10) + LumpLeafs = LumpId(10) // LumpFaceIds is contents is normally stripped out by compiler - LumpFaceIds = LumpId(11) + LumpFaceIds = LumpId(11) // LumpEdges is face edges. v1->v2, vertex order may be reversed - LumpEdges = LumpId(12) + LumpEdges = LumpId(12) // LumpSurfEdges - LumpSurfEdges = LumpId(13) + LumpSurfEdges = LumpId(13) // LumpModels is models are root bsp nodes. m[0] = worldspawn. m[0+n] are brush entity data - LumpModels = LumpId(14) + LumpModels = LumpId(14) // LumpWorldLights - LumpWorldLights = LumpId(15) + LumpWorldLights = LumpId(15) // LumpLeafFaces is faces that separate leaves. - LumpLeafFaces = LumpId(16) + LumpLeafFaces = LumpId(16) // LumpLeafBrushes is brushes that define a leaf volume - LumpLeafBrushes = LumpId(17) + LumpLeafBrushes = LumpId(17) // LumpBrushes - LumpBrushes = LumpId(18) + LumpBrushes = LumpId(18) // LumpBrushSides - LumpBrushSides = LumpId(19) + LumpBrushSides = LumpId(19) // LumpAreas - LumpAreas = LumpId(20) + LumpAreas = LumpId(20) // LumpAreaPortals - LumpAreaPortals = LumpId(21) + LumpAreaPortals = LumpId(21) // LumpPortals - LumpPortals = LumpId(22) + LumpPortals = LumpId(22) // LumpUnused0 - LumpUnused0 = LumpId(22) + LumpUnused0 = LumpId(22) // LumpPropCollision - LumpPropCollision = LumpId(22) + LumpPropCollision = LumpId(22) // LumpClusters - LumpClusters = LumpId(23) + LumpClusters = LumpId(23) // LumpUnused1 - LumpUnused1 = LumpId(23) + LumpUnused1 = LumpId(23) // LumpPropHulls - LumpPropHulls = LumpId(23) + LumpPropHulls = LumpId(23) // LumpPortalVerts - LumpPortalVerts = LumpId(24) + LumpPortalVerts = LumpId(24) // LumpUnused2 - LumpUnused2 = LumpId(24) + LumpUnused2 = LumpId(24) // LumpPropHullVerts - LumpPropHullVerts = LumpId(24) + LumpPropHullVerts = LumpId(24) // LumpClusterPortals - LumpClusterPortals = LumpId(25) + LumpClusterPortals = LumpId(25) // LumpUnused3 - LumpUnused3 = LumpId(25) + LumpUnused3 = LumpId(25) // LumpPropTris - LumpPropTris = LumpId(25) + LumpPropTris = LumpId(25) // LumpDispInfo - LumpDispInfo = LumpId(26) + LumpDispInfo = LumpId(26) // LumpOriginalFaces - LumpOriginalFaces = LumpId(27) + LumpOriginalFaces = LumpId(27) // LumpPhysDisp - LumpPhysDisp = LumpId(28) + LumpPhysDisp = LumpId(28) // LumpPhysCollide - LumpPhysCollide = LumpId(29) + LumpPhysCollide = LumpId(29) // LumpVertNormals - LumpVertNormals = LumpId(30) + LumpVertNormals = LumpId(30) // LumpVertNormalIndices - LumpVertNormalIndices = LumpId(31) + LumpVertNormalIndices = LumpId(31) // LumpDispLightmapAlphas is contents is normally stripped out - LumpDispLightmapAlphas = LumpId(32) + LumpDispLightmapAlphas = LumpId(32) // LumpDispVerts - LumpDispVerts = LumpId(33) + LumpDispVerts = LumpId(33) // LumpDispLightmapSamplePositions LumpDispLightmapSamplePositions = LumpId(34) // LumpGame is game specific data. includes staticprop data - LumpGame = LumpId(35) + LumpGame = LumpId(35) // LumpLeafWaterData - LumpLeafWaterData = LumpId(36) + LumpLeafWaterData = LumpId(36) // LumpPrimitives - LumpPrimitives = LumpId(37) + LumpPrimitives = LumpId(37) // LumpPrimVerts - LumpPrimVerts = LumpId(38) + LumpPrimVerts = LumpId(38) // LumpPrimIndices - LumpPrimIndices = LumpId(39) + LumpPrimIndices = LumpId(39) // LumpPakfile is uncompressed zip of packed custom content - LumpPakfile = LumpId(40) + LumpPakfile = LumpId(40) // LumpClipPortalVerts - LumpClipPortalVerts = LumpId(41) + LumpClipPortalVerts = LumpId(41) // LumpCubemaps - LumpCubemaps = LumpId(42) + LumpCubemaps = LumpId(42) // LumpTexDataStringData is raw string data of material paths - LumpTexDataStringData = LumpId(43) + LumpTexDataStringData = LumpId(43) // LumpTexDataStringTable references entries in the string data lump - LumpTexDataStringTable = LumpId(44) + LumpTexDataStringTable = LumpId(44) // LumpOverlays - LumpOverlays = LumpId(45) + LumpOverlays = LumpId(45) // LumpLeafMinDistToWater - LumpLeafMinDistToWater = LumpId(46) + LumpLeafMinDistToWater = LumpId(46) // LumpFaceMacroTextureInfo - LumpFaceMacroTextureInfo = LumpId(47) + LumpFaceMacroTextureInfo = LumpId(47) // LumpDispTris - LumpDispTris = LumpId(48) + LumpDispTris = LumpId(48) // LumpPhysCollideSurface is deprecated - LumpPhysCollideSurface = LumpId(49) + LumpPhysCollideSurface = LumpId(49) // LumpPropBlob - LumpPropBlob = LumpId(49) + LumpPropBlob = LumpId(49) // LumpWaterOverlays - LumpWaterOverlays = LumpId(50) + LumpWaterOverlays = LumpId(50) // LumpLightmapPages - LumpLightmapPages = LumpId(51) + LumpLightmapPages = LumpId(51) // LumpLeafAmbientIndexHDR - LumpLeafAmbientIndexHDR = LumpId(51) + LumpLeafAmbientIndexHDR = LumpId(51) // LumpLightmapPagesInfo - LumpLightmapPagesInfo = LumpId(52) + LumpLightmapPagesInfo = LumpId(52) // LumpLeafAmbientIndex - LumpLeafAmbientIndex = LumpId(52) + LumpLeafAmbientIndex = LumpId(52) // LumpLightingHDR - LumpLightingHDR = LumpId(53) + LumpLightingHDR = LumpId(53) // LumpWorldLightsHDR - LumpWorldLightsHDR = LumpId(54) + LumpWorldLightsHDR = LumpId(54) // LumpLeafAmbientLightingHDR - LumpLeafAmbientLightingHDR = LumpId(55) + LumpLeafAmbientLightingHDR = LumpId(55) // LumpLeafAmbientLighting - LumpLeafAmbientLighting = LumpId(56) + LumpLeafAmbientLighting = LumpId(56) // LumpXZipPakfile is deprecated, and xbox specific - LumpXZipPakfile = LumpId(57) + LumpXZipPakfile = LumpId(57) // LumpFacesHDR - LumpFacesHDR = LumpId(58) + LumpFacesHDR = LumpId(58) // LumpMapFlags - LumpMapFlags = LumpId(59) + LumpMapFlags = LumpId(59) // LumpOverlayFades - LumpOverlayFades = LumpId(60) + LumpOverlayFades = LumpId(60) // LumpOverlaySystemLevels - LumpOverlaySystemLevels = LumpId(61) + LumpOverlaySystemLevels = LumpId(61) // LumpPhysLevel - LumpPhysLevel = LumpId(62) + LumpPhysLevel = LumpId(62) // LumpDispMultiBlend - LumpDispMultiBlend = LumpId(63) -) \ No newline at end of file + LumpDispMultiBlend = LumpId(63) +) diff --git a/lump_test.go b/lump_test.go index 10de796..2f5d6aa 100644 --- a/lump_test.go +++ b/lump_test.go @@ -61,7 +61,7 @@ func getExpectedLump(index int) lumps.ILump { &lumps.Pakfile{}, &lumps.ClipPortalVerts{}, &lumps.Cubemap{}, - &lumps.TexdataStringData{}, + &lumps.TexDataStringData{}, &lumps.TexDataStringTable{}, &lumps.Overlay{}, &lumps.LeafMinDistToWater{}, diff --git a/lumps/area.go b/lumps/area.go index cbc95a5..3aabaaa 100644 --- a/lumps/area.go +++ b/lumps/area.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 20: Areas +// Area is Lump 20: Areas type Area struct { LumpGeneric data []primitives.Area } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Area) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -29,14 +29,14 @@ func (lump *Area) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Area) GetData() []primitives.Area { return lump.data } -// Dump this lump back to raw byte data -func (lump *Area) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Area) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/areaportal.go b/lumps/areaportal.go index 4e44287..7433f84 100644 --- a/lumps/areaportal.go +++ b/lumps/areaportal.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 21: Areaportals +// AreaPortal is Lump 21: Areaportals type AreaPortal struct { LumpGeneric data []primitives.AreaPortal } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *AreaPortal) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *AreaPortal) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *AreaPortal) GetData() []primitives.AreaPortal { return lump.data } -// Dump this lump back to raw byte data -func (lump *AreaPortal) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *AreaPortal) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/brush.go b/lumps/brush.go index 3894496..2cd521f 100644 --- a/lumps/brush.go +++ b/lumps/brush.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 18: Brush +// Brush is Lump 18: Brush type Brush struct { LumpGeneric data []primitives.Brush } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Brush) Unmarshall(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) @@ -24,14 +24,14 @@ func (lump *Brush) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Brush) GetData() []primitives.Brush { return lump.data } -// Dump this lump back to raw byte data -func (lump *Brush) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Brush) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/brushside.go b/lumps/brushside.go index c88abb9..511495a 100644 --- a/lumps/brushside.go +++ b/lumps/brushside.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 19: BrushSide +// BrushSide is Lump 19: BrushSide type BrushSide struct { LumpGeneric data []primitives.BrushSide // MAX_MAP_BRUSHSIDES = 65536 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *BrushSide) Unmarshall(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) @@ -24,14 +24,14 @@ func (lump *BrushSide) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *BrushSide) GetData() []primitives.BrushSide { return lump.data } -// Dump this lump back to raw byte data -func (lump *BrushSide) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *BrushSide) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/clipportalverts.go b/lumps/clipportalverts.go index 6d09273..50be21f 100644 --- a/lumps/clipportalverts.go +++ b/lumps/clipportalverts.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 41: ClipPortalVerts +// ClipPortalVerts is Lump 41: ClipPortalVerts type ClipPortalVerts struct { LumpGeneric data []mgl32.Vec3 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *ClipPortalVerts) Unmarshall(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) @@ -24,14 +24,14 @@ func (lump *ClipPortalVerts) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *ClipPortalVerts) GetData() []mgl32.Vec3 { return lump.data } -// Dump this lump back to raw byte data -func (lump *ClipPortalVerts) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *ClipPortalVerts) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/cubemap.go b/lumps/cubemap.go index 986f3cd..93d01d9 100644 --- a/lumps/cubemap.go +++ b/lumps/cubemap.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 42: Cubemaps +// Cubemap is Lump 42: Cubemaps type Cubemap struct { LumpGeneric data []primitives.CubemapSample } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Cubemap) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *Cubemap) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Cubemap) GetData() []primitives.CubemapSample { return lump.data } -// Dump this lump back to raw byte data -func (lump *Cubemap) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Cubemap) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/dispinfo.go b/lumps/dispinfo.go index 7fd7cc0..9134357 100644 --- a/lumps/dispinfo.go +++ b/lumps/dispinfo.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 26: DispInfo +// DispInfo is Lump 26: DispInfo type DispInfo struct { LumpGeneric data []primitives.DispInfo } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *DispInfo) Unmarshall(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) @@ -24,14 +24,14 @@ func (lump *DispInfo) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *DispInfo) GetData() []primitives.DispInfo { return lump.data } -// Dump this lump back to raw byte data -func (lump *DispInfo) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *DispInfo) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/displightmapsampleposition.go b/lumps/displightmapsampleposition.go index 0a5ac5b..245bd8b 100644 --- a/lumps/displightmapsampleposition.go +++ b/lumps/displightmapsampleposition.go @@ -1,24 +1,24 @@ package lumps -// Lump 34: DispLightmapSamplePosition +// DispLightmapSamplePosition is 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 +// Unmarshall Imports this lump from raw byte data func (lump *DispLightmapSamplePosition) Unmarshall(raw []byte, length int32) { lump.data = raw lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *DispLightmapSamplePosition) GetData() []byte { return lump.data } -// Dump this lump back to raw byte data -func (lump *DispLightmapSamplePosition) Marshall() ([]byte,error) { - return lump.data,nil +// Marshall dumps this lump back to raw byte data +func (lump *DispLightmapSamplePosition) Marshall() ([]byte, error) { + return lump.data, nil } diff --git a/lumps/disptris.go b/lumps/disptris.go index 4b0ddc6..b4c958f 100644 --- a/lumps/disptris.go +++ b/lumps/disptris.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 48: DispTris +// DispTris is Lump 48: DispTris type DispTris struct { LumpGeneric data []primitives.DispTri } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *DispTris) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *DispTris) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *DispTris) GetData() []primitives.DispTri { return lump.data } -// Dump this lump back to raw byte data -func (lump *DispTris) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *DispTris) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/dispvert.go b/lumps/dispvert.go index 6200ea6..32067aa 100644 --- a/lumps/dispvert.go +++ b/lumps/dispvert.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 33: DispVert +// DispVert is Lump 33: DispVert type DispVert struct { LumpGeneric data []primitives.DispVert } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *DispVert) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *DispVert) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *DispVert) GetData() []primitives.DispVert { return lump.data } -// Dump this lump back to raw byte data -func (lump *DispVert) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *DispVert) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/edge.go b/lumps/edge.go index f042b57..4b365bf 100644 --- a/lumps/edge.go +++ b/lumps/edge.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 12: Edge +// Edge is Lump 12: Edge type Edge struct { LumpGeneric data [][2]uint16 // MAX_MAP_EDGES = 256000 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Edge) Unmarshall(raw []byte, length int32) { lump.data = make([][2]uint16, length/4) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -22,14 +22,14 @@ func (lump *Edge) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Edge) GetData() [][2]uint16 { return lump.data } -// Dump this lump back to raw byte data -func (lump *Edge) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Edge) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/entdata.go b/lumps/entdata.go index 0eeb19e..0e53a16 100644 --- a/lumps/entdata.go +++ b/lumps/entdata.go @@ -1,23 +1,23 @@ package lumps -// Lump 0: Entdata +// EntData is Lump 0: Entdata type EntData struct { LumpGeneric data string } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *EntData) Unmarshall(raw []byte, length int32) { lump.data = string(raw) lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *EntData) GetData() string { return lump.data } -// Dump this lump back to raw byte data -func (lump *EntData) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *EntData) Marshall() ([]byte, error) { return []byte(lump.data), nil } diff --git a/lumps/face.go b/lumps/face.go index 0fae427..5444579 100644 --- a/lumps/face.go +++ b/lumps/face.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 7: Face +// Face is Lump 7: Face type Face struct { LumpGeneric data []primitives.Face } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Face) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.Face, length/int32(unsafe.Sizeof(primitives.Face{}))) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -24,14 +24,14 @@ func (lump *Face) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Face) GetData() []primitives.Face { return lump.data } -// Dump this lump back to raw byte data -func (lump *Face) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Face) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/facehdr.go b/lumps/facehdr.go index 0611ed0..188112f 100644 --- a/lumps/facehdr.go +++ b/lumps/facehdr.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 58: FaceHDR +// FaceHDR is Lump 58: FaceHDR type FaceHDR struct { LumpGeneric data []primitives.Face } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *FaceHDR) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.Face, length/int32(unsafe.Sizeof(primitives.Face{}))) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -24,14 +24,14 @@ func (lump *FaceHDR) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *FaceHDR) GetData() []primitives.Face { return lump.data } -// Dump this lump back to raw byte data -func (lump *FaceHDR) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *FaceHDR) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/faceid.go b/lumps/faceid.go index 798bedf..bce82f7 100644 --- a/lumps/faceid.go +++ b/lumps/faceid.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 11: FaceIds +// FaceId is Lump 11: FaceIds type FaceId struct { LumpGeneric data []primitives.FaceId } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *FaceId) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *FaceId) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *FaceId) GetData() []primitives.FaceId { return lump.data } -// Dump this lump back to raw byte data -func (lump *FaceId) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *FaceId) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/facemacrotextureinfo.go b/lumps/facemacrotextureinfo.go index 7564256..cb8eea7 100644 --- a/lumps/facemacrotextureinfo.go +++ b/lumps/facemacrotextureinfo.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 47: FaceMacroTextureInfo +// FaceMacroTextureInfo is Lump 47: FaceMacroTextureInfo type FaceMacroTextureInfo struct { LumpGeneric data []primitives.FaceMacroTextureInfo } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *FaceMacroTextureInfo) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *FaceMacroTextureInfo) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *FaceMacroTextureInfo) GetData() []primitives.FaceMacroTextureInfo { return lump.data } -// Dump this lump back to raw byte data -func (lump *FaceMacroTextureInfo) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *FaceMacroTextureInfo) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/game.go b/lumps/game.go index 0ee561a..94d3d1e 100644 --- a/lumps/game.go +++ b/lumps/game.go @@ -9,7 +9,7 @@ import ( "unsafe" ) -// Lump 35. +// Game is Lump 35. // @TODO NOTE: This really needs per-game implementations to be completely useful, // otherwise we only get staticprop data from it type Game struct { @@ -20,7 +20,7 @@ type Game struct { areOffsetsCorrected bool } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Game) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) @@ -56,32 +56,32 @@ func (lump *Game) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Game) GetData() *Game { return lump } -// Dump this lump back to raw byte data -func (lump *Game) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Game) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.Header.LumpCount) if err != nil { - return nil,err + return nil, err } for _, lumpHeader := range lump.Header.GameLumps { if err = binary.Write(&buf, binary.LittleEndian, lumpHeader); err != nil { - return nil,err + return nil, err } } for _, l := range lump.GameLumps { if err = binary.Write(&buf, binary.LittleEndian, l.Length); err != nil { - return nil,err + return nil, err } if err = binary.Write(&buf, binary.LittleEndian, l.Data); err != nil { - return nil,err + return nil, err } } - return buf.Bytes(),err + return buf.Bytes(), err } // This update the lumps offsets to be relative to the lump, rather diff --git a/lumps/interface.go b/lumps/interface.go index 4217178..4a16cea 100644 --- a/lumps/interface.go +++ b/lumps/interface.go @@ -7,6 +7,5 @@ type ILump interface { Unmarshall([]byte, int32) // Marshall Exports lump structure back to []byte. - Marshall() ([]byte,error) + Marshall() ([]byte, error) } - diff --git a/lumps/leaf.go b/lumps/leaf.go index 5a9dbeb..ba5ed6e 100644 --- a/lumps/leaf.go +++ b/lumps/leaf.go @@ -8,15 +8,18 @@ import ( "unsafe" ) -// Lump 10: Leaf -const MAX_MAP_LEAFS = 65536 +const ( + // MaxMapLeafs is the maximum number of leafs the engine can handle + MaxMapLeafs = 65536 +) +// Leaf is Lump 10: Leaf type Leaf struct { LumpGeneric data []primitives.Leaf } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Leaf) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.Leaf, length/int32(unsafe.Sizeof(primitives.Leaf{}))) structSize := int(unsafe.Sizeof(primitives.Leaf{})) @@ -28,21 +31,21 @@ func (lump *Leaf) Unmarshall(raw []byte, length int32) { log.Fatal(err) } i++ - if i > MAX_MAP_LEAFS { - log.Fatalf("Leaf count overflows maximum allowed size of %d\n", MAX_MAP_LEAFS) + if i > MaxMapLeafs { + log.Fatalf("Leaf count overflows maximum allowed size of %d\n", MaxMapLeafs) } } lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Leaf) GetData() []primitives.Leaf { return lump.data } -// Dump this lump back to raw byte data -func (lump *Leaf) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Leaf) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/leafambientindex.go b/lumps/leafambientindex.go index a8bb208..ede11b6 100644 --- a/lumps/leafambientindex.go +++ b/lumps/leafambientindex.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 52: Leaf Ambient Index +// LeafAmbientIndex is Lump 52: Leaf Ambient Index type LeafAmbientIndex struct { LumpGeneric data []primitives.LeafAmbientIndex } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafAmbientIndex) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *LeafAmbientIndex) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafAmbientIndex) GetData() []primitives.LeafAmbientIndex { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafAmbientIndex) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafAmbientIndex) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/leafambientindexhdr.go b/lumps/leafambientindexhdr.go index 37e1af8..ee5eb94 100644 --- a/lumps/leafambientindexhdr.go +++ b/lumps/leafambientindexhdr.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 51: Leaf Ambient Index HDR +// LeafAmbientIndexHDR is Lump 51: Leaf Ambient Index HDR type LeafAmbientIndexHDR struct { LumpGeneric data []primitives.LeafAmbientIndex } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafAmbientIndexHDR) Unmarshall(raw []byte, length int32) { if length == 0 { return @@ -27,14 +27,14 @@ func (lump *LeafAmbientIndexHDR) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafAmbientIndexHDR) GetData() []primitives.LeafAmbientIndex { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafAmbientIndexHDR) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafAmbientIndexHDR) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/leafambientlighting.go b/lumps/leafambientlighting.go index 85c174a..9762e7c 100644 --- a/lumps/leafambientlighting.go +++ b/lumps/leafambientlighting.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 56: LeafAmbientLighting +// LeafAmbientLighting is Lump 56: LeafAmbientLighting type LeafAmbientLighting struct { LumpGeneric data []primitives.LeafAmbientLighting } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafAmbientLighting) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *LeafAmbientLighting) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafAmbientLighting) GetData() []primitives.LeafAmbientLighting { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafAmbientLighting) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafAmbientLighting) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/leafambientlightinghdr.go b/lumps/leafambientlightinghdr.go index b233713..1e9fc03 100644 --- a/lumps/leafambientlightinghdr.go +++ b/lumps/leafambientlightinghdr.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 55: LeafAmbientLightingHDR +// LeafAmbientLightingHDR is Lump 55: LeafAmbientLightingHDR type LeafAmbientLightingHDR struct { LumpGeneric data []primitives.LeafAmbientLighting } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafAmbientLightingHDR) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *LeafAmbientLightingHDR) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafAmbientLightingHDR) GetData() []primitives.LeafAmbientLighting { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafAmbientLightingHDR) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafAmbientLightingHDR) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/leafbrush.go b/lumps/leafbrush.go index 59b6dac..b641a82 100644 --- a/lumps/leafbrush.go +++ b/lumps/leafbrush.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 17: LeafBrush +// LeafBrush is Lump 17: LeafBrush type LeafBrush struct { LumpGeneric data []uint16 // MAX_MAP_LEAFBRUSHES = 65536 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafBrush) Unmarshall(raw []byte, length int32) { lump.data = make([]uint16, length/2) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -22,14 +22,14 @@ func (lump *LeafBrush) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafBrush) GetData() []uint16 { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafBrush) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafBrush) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/leafface.go b/lumps/leafface.go index 4e4eb94..d943fbc 100644 --- a/lumps/leafface.go +++ b/lumps/leafface.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 16: LeafFace +// LeafFace is Lump 16: LeafFace type LeafFace struct { LumpGeneric data []uint16 // MAX_MAP_LEAFFACES = 65536 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafFace) Unmarshall(raw []byte, length int32) { lump.data = make([]uint16, length/2) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -22,13 +22,13 @@ func (lump *LeafFace) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafFace) GetData() []uint16 { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafFace) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafFace) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) return buf.Bytes(), err diff --git a/lumps/leafmindisttowater.go b/lumps/leafmindisttowater.go index 10f1e96..2f69e9a 100644 --- a/lumps/leafmindisttowater.go +++ b/lumps/leafmindisttowater.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 46: LeafMinDistToWater +// LeafMinDistToWater is Lump 46: LeafMinDistToWater type LeafMinDistToWater struct { LumpGeneric data []uint16 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafMinDistToWater) Unmarshall(raw []byte, length int32) { lump.data = make([]uint16, length/int32(2)) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -22,14 +22,14 @@ func (lump *LeafMinDistToWater) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafMinDistToWater) GetData() []uint16 { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafMinDistToWater) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafMinDistToWater) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/leafwaterdata.go b/lumps/leafwaterdata.go index 6f1af52..92b0e5e 100644 --- a/lumps/leafwaterdata.go +++ b/lumps/leafwaterdata.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 36: leafwaterdata +// LeafWaterData is Lump 36: leafwaterdata type LeafWaterData struct { LumpGeneric data []primitives.LeafWaterData } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *LeafWaterData) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *LeafWaterData) Unmarshall(raw []byte, length int32) { } -// Get internal format structure data +// GetData gets internal format structure data func (lump *LeafWaterData) GetData() []primitives.LeafWaterData { return lump.data } -// Dump this lump back to raw byte data -func (lump *LeafWaterData) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *LeafWaterData) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/lighting.go b/lumps/lighting.go index 90fffb1..48e3721 100644 --- a/lumps/lighting.go +++ b/lumps/lighting.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 8: Lighting +// Lighting is Lump 8: Lighting type Lighting struct { LumpGeneric data []primitives.ColorRGBExponent32 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Lighting) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *Lighting) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Lighting) GetData() []primitives.ColorRGBExponent32 { return lump.data } -// Dump this lump back to raw byte data -func (lump *Lighting) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Lighting) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/lump.go b/lumps/lump.go index f2d8368..547065a 100644 --- a/lumps/lump.go +++ b/lumps/lump.go @@ -15,7 +15,7 @@ func (lump *LumpGeneric) Unmarshall(data []byte, length int32) { } // Marshall Dumps this lump back to raw byte data -func (lump *LumpGeneric) Marshall() ([]byte,error) { +func (lump *LumpGeneric) Marshall() ([]byte, error) { return lump.data, nil } diff --git a/lumps/mapflags.go b/lumps/mapflags.go index e9f592f..41af314 100644 --- a/lumps/mapflags.go +++ b/lumps/mapflags.go @@ -7,13 +7,13 @@ import ( "log" ) -// Lump 59: MapFlags +// MapFlags is Lump 59: MapFlags type MapFlags struct { LumpGeneric data primitives.MapFlags } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *MapFlags) Unmarshall(raw []byte, length int32) { if length == 0 { return @@ -26,14 +26,14 @@ func (lump *MapFlags) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *MapFlags) GetData() *primitives.MapFlags { return &lump.data } -// Dump this lump back to raw byte data -func (lump *MapFlags) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *MapFlags) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/model.go b/lumps/model.go index 2958ef0..b5cd4ba 100644 --- a/lumps/model.go +++ b/lumps/model.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 14: Model +// Model is Lump 14: Model type Model struct { LumpGeneric data []primitives.Model } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Model) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.Model, length/int32(unsafe.Sizeof(primitives.Model{}))) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -24,14 +24,14 @@ func (lump *Model) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Model) GetData() []primitives.Model { return lump.data } -// Dump this lump back to raw byte data -func (lump *Model) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Model) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/node.go b/lumps/node.go index 52578ef..0275611 100644 --- a/lumps/node.go +++ b/lumps/node.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 5: Node +// Node is Lump 5: Node type Node struct { LumpGeneric data []primitives.Node // MAP_MAX_NODES = 65536 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Node) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.Node, length/int32(unsafe.Sizeof(primitives.Node{}))) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -24,14 +24,14 @@ func (lump *Node) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Node) GetData() []primitives.Node { return lump.data } -// Dump this lump back to raw byte data -func (lump *Node) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Node) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/occlusion.go b/lumps/occlusion.go index bde047a..4849474 100644 --- a/lumps/occlusion.go +++ b/lumps/occlusion.go @@ -8,7 +8,7 @@ import ( "unsafe" ) -// Lump 9: Occlusion +// Occlusion is Lump 9: Occlusion type Occlusion struct { LumpGeneric Count int32 @@ -19,7 +19,7 @@ type Occlusion struct { VertexIndices []int32 //len(slice) = VertexIndexCount } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Occlusion) Unmarshall(raw []byte, length int32) { if length == 0 { return @@ -66,13 +66,13 @@ func (lump *Occlusion) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Occlusion) GetData() *Occlusion { return lump } -// Dump this lump back to raw byte data -func (lump *Occlusion) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Occlusion) Marshall() ([]byte, error) { var buf bytes.Buffer // write data err := binary.Write(&buf, binary.LittleEndian, lump.Count) @@ -102,5 +102,5 @@ func (lump *Occlusion) Marshall() ([]byte,error) { return nil, err } } - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/overlay.go b/lumps/overlay.go index bda079a..f5fd30e 100644 --- a/lumps/overlay.go +++ b/lumps/overlay.go @@ -8,14 +8,14 @@ import ( "unsafe" ) -// Lump 45: Overlay +// Overlay is Lump 45: Overlay // Consists of an array of Overlay structs type Overlay struct { LumpGeneric data []primitives.Overlay } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Overlay) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *Overlay) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Overlay) GetData() []primitives.Overlay { return lump.data } -// Dump this lump back to raw byte data -func (lump *Overlay) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Overlay) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/overlayfade.go b/lumps/overlayfade.go index 54cdf91..8150436 100644 --- a/lumps/overlayfade.go +++ b/lumps/overlayfade.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 60: Overlayfades +// OverlayFade is Lump 60: Overlayfades type OverlayFade struct { LumpGeneric data []primitives.OverlayFade } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *OverlayFade) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *OverlayFade) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *OverlayFade) GetData() []primitives.OverlayFade { return lump.data } -// Dump this lump back to raw byte data -func (lump *OverlayFade) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *OverlayFade) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/pakfile.go b/lumps/pakfile.go index f874684..95b0daf 100644 --- a/lumps/pakfile.go +++ b/lumps/pakfile.go @@ -8,13 +8,13 @@ import ( "strings" ) -// Lump 40: Pakfile +// Pakfile is Lump 40: Pakfile type Pakfile struct { LumpGeneric zipReader *zip.Reader } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Pakfile) Unmarshall(raw []byte, length int32) { lump.data = raw lump.LumpInfo.SetLength(length) @@ -26,16 +26,16 @@ func (lump *Pakfile) Unmarshall(raw []byte, length int32) { } } -// GetData Get internal format structure data +// GetData GetData gets internal format structure data func (lump *Pakfile) GetData() *zip.Reader { return lump.zipReader } // Marshall Returns the contents of this lump as a []byte -func (lump *Pakfile) Marshall() ([]byte,error) { +func (lump *Pakfile) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } // GetFile Get a specific file from the pak diff --git a/lumps/physcollide.go b/lumps/physcollide.go index dee98cf..3701b95 100644 --- a/lumps/physcollide.go +++ b/lumps/physcollide.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 20: PhysCollide +// PhysCollide is Lump 20: PhysCollide type PhysCollide struct { LumpGeneric data []primitives.PhysCollideEntry } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *PhysCollide) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,30 +28,30 @@ func (lump *PhysCollide) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *PhysCollide) GetData() []primitives.PhysCollideEntry { return lump.data } -// Dump this lump back to raw byte data -func (lump *PhysCollide) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *PhysCollide) Marshall() ([]byte, error) { var buf bytes.Buffer - for _,entry := range lump.data { + for _, entry := range lump.data { err := binary.Write(&buf, binary.LittleEndian, entry.ModelHeader) if err != nil { - return nil,err + return nil, err } - for _,solid := range entry.Solids { + for _, solid := range entry.Solids { if err = binary.Write(&buf, binary.LittleEndian, solid.Size); err != nil { - return nil,err + return nil, err } if err = binary.Write(&buf, binary.LittleEndian, solid.CollisionBinary); err != nil { - return nil,err + return nil, err } } if err = binary.Write(&buf, binary.LittleEndian, []byte(entry.TextBuffer)); err != nil { - return nil,err + return nil, err } } - return buf.Bytes(),nil + return buf.Bytes(), nil } diff --git a/lumps/physdisp.go b/lumps/physdisp.go index 077f176..911ccc3 100644 --- a/lumps/physdisp.go +++ b/lumps/physdisp.go @@ -1,23 +1,23 @@ package lumps -// Lump 28: PhysDisp +// PhysDisp is Lump 28: PhysDisp type PhysDisp struct { LumpGeneric data []byte } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *PhysDisp) Unmarshall(raw []byte, length int32) { lump.data = raw lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *PhysDisp) GetData() []byte { return lump.data } -// Dump this lump back to raw byte data -func (lump *PhysDisp) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *PhysDisp) Marshall() ([]byte, error) { return lump.data, nil } diff --git a/lumps/planes.go b/lumps/planes.go index bf17b81..fdbce95 100644 --- a/lumps/planes.go +++ b/lumps/planes.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 1: Planes +// Planes is Lump 1: Planes type Planes struct { LumpGeneric data []primitives.Plane // MAP_MAX_PLANES = 65536 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Planes) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.Plane, length/int32(unsafe.Sizeof(primitives.Plane{}))) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -24,14 +24,14 @@ func (lump *Planes) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Planes) GetData() []primitives.Plane { return lump.data } -// Dump this lump back to raw byte data -func (lump *Planes) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Planes) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/primindice.go b/lumps/primindice.go index 9fe74b5..24e0320 100644 --- a/lumps/primindice.go +++ b/lumps/primindice.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 39: PrimIndice +// PrimIndice is Lump 39: PrimIndice type PrimIndice struct { LumpGeneric data []uint16 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *PrimIndice) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -26,14 +26,14 @@ func (lump *PrimIndice) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *PrimIndice) GetData() []uint16 { return lump.data } -// Dump this lump back to raw byte data -func (lump *PrimIndice) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *PrimIndice) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/primitive.go b/lumps/primitive.go index ce7d8bb..2e26fab 100644 --- a/lumps/primitive.go +++ b/lumps/primitive.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 36: Primitive +// Primitive is Lump 36: Primitive type Primitive struct { LumpGeneric data []primitives.Primitive } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Primitive) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *Primitive) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Primitive) GetData() []primitives.Primitive { return lump.data } -// Dump this lump back to raw byte data -func (lump *Primitive) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Primitive) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/primvert.go b/lumps/primvert.go index 557068e..a7febb0 100644 --- a/lumps/primvert.go +++ b/lumps/primvert.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 37: PrimVert +// PrimVert is Lump 37: PrimVert type PrimVert struct { LumpGeneric data []primitives.PrimVert } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *PrimVert) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *PrimVert) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *PrimVert) GetData() []primitives.PrimVert { return lump.data } -// Dump this lump back to raw byte data -func (lump *PrimVert) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *PrimVert) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/surfedge.go b/lumps/surfedge.go index 47f3204..c4318a8 100644 --- a/lumps/surfedge.go +++ b/lumps/surfedge.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 13: Surfedge +// Surfedge is Lump 13: Surfedge type Surfedge struct { LumpGeneric data []int32 // MAX_MAP_SURFEDGES = 512000 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Surfedge) Unmarshall(raw []byte, length int32) { lump.data = make([]int32, length/4) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -22,14 +22,14 @@ func (lump *Surfedge) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Surfedge) GetData() []int32 { return lump.data } -// Dump this lump back to raw byte data -func (lump *Surfedge) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Surfedge) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/texdata.go b/lumps/texdata.go index d4bdd5f..fcada24 100644 --- a/lumps/texdata.go +++ b/lumps/texdata.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 2: TexData +// TexData is Lump 2: TexData type TexData struct { LumpGeneric data []primitives.TexData } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *TexData) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.TexData, length/int32(unsafe.Sizeof(primitives.TexData{}))) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -24,14 +24,14 @@ func (lump *TexData) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *TexData) GetData() []primitives.TexData { return lump.data } -// Dump this lump back to raw byte data -func (lump *TexData) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *TexData) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/texdatastringdata.go b/lumps/texdatastringdata.go index a5968e8..a08e724 100644 --- a/lumps/texdatastringdata.go +++ b/lumps/texdatastringdata.go @@ -1,23 +1,23 @@ package lumps -// Lump 43: TexdataStringData -type TexdataStringData struct { +// TexDataStringData is Lump 43: TexDataStringData +type TexDataStringData struct { LumpGeneric data string // MAX_MAP_TEXDATA_STRING_DATA = 256000, TEXTURE_NAME_LENGTH = 128 } -// Import this lump from raw byte data -func (lump *TexdataStringData) Unmarshall(raw []byte, length int32) { +// Unmarshall Imports this lump from raw byte data +func (lump *TexDataStringData) Unmarshall(raw []byte, length int32) { lump.data = string(raw) lump.LumpInfo.SetLength(length) } -// Get internal format structure data -func (lump *TexdataStringData) GetData() string { +// GetData gets internal format structure data +func (lump *TexDataStringData) GetData() string { return lump.data } -// Dump this lump back to raw byte data -func (lump *TexdataStringData) Marshall() ([]byte,error) { - return []byte(lump.data),nil +// Marshall dumps this lump back to raw byte data +func (lump *TexDataStringData) Marshall() ([]byte, error) { + return []byte(lump.data), nil } diff --git a/lumps/texdatastringtable.go b/lumps/texdatastringtable.go index a78ddc4..9b86cca 100644 --- a/lumps/texdatastringtable.go +++ b/lumps/texdatastringtable.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 44: TexDataStringTable +// TexDataStringTable is Lump 44: TexDataStringTable type TexDataStringTable struct { LumpGeneric data []int32 // MAX_MAP_TEXINFO = 2048 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *TexDataStringTable) Unmarshall(raw []byte, length int32) { lump.data = make([]int32, length/4) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -22,14 +22,14 @@ func (lump *TexDataStringTable) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *TexDataStringTable) GetData() []int32 { return lump.data } -// Dump this lump back to raw byte data -func (lump *TexDataStringTable) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *TexDataStringTable) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/texinfo.go b/lumps/texinfo.go index c89b61c..19cf73c 100644 --- a/lumps/texinfo.go +++ b/lumps/texinfo.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 6: TexInfo +// TexInfo is Lump 6: TexInfo type TexInfo struct { LumpGeneric data []primitives.TexInfo } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *TexInfo) Unmarshall(raw []byte, length int32) { lump.data = make([]primitives.TexInfo, length/int32(unsafe.Sizeof(primitives.TexInfo{}))) err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data) @@ -24,14 +24,14 @@ func (lump *TexInfo) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *TexInfo) GetData() []primitives.TexInfo { return lump.data } -// Dump this lump back to raw byte data -func (lump *TexInfo) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *TexInfo) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/unimplemented.go b/lumps/unimplemented.go index c39f8f9..1e00969 100644 --- a/lumps/unimplemented.go +++ b/lumps/unimplemented.go @@ -1,23 +1,23 @@ package lumps -// Lump n: Unimplemented lump type +// Unimplemented is Lump n: Unimplemented lump type type Unimplemented struct { LumpGeneric data []byte } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Unimplemented) Unmarshall(raw []byte, length int32) { lump.data = raw lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Unimplemented) GetData() []byte { return lump.data } -// Dump this lump back to raw byte data -func (lump *Unimplemented) Marshall() ([]byte,error) { - return lump.data,nil +// Marshall dumps this lump back to raw byte data +func (lump *Unimplemented) Marshall() ([]byte, error) { + return lump.data, nil } diff --git a/lumps/vertex.go b/lumps/vertex.go index 12b5b25..26840d7 100644 --- a/lumps/vertex.go +++ b/lumps/vertex.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 3: Vertex +// Vertex is Lump 3: Vertex type Vertex struct { LumpGeneric data []mgl32.Vec3 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Vertex) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *Vertex) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Vertex) GetData() []mgl32.Vec3 { return lump.data } -// Dump this lump back to raw byte data -func (lump *Vertex) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Vertex) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/vertnormal.go b/lumps/vertnormal.go index 31321cd..8450ec1 100644 --- a/lumps/vertnormal.go +++ b/lumps/vertnormal.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 30: VertNormal +// VertNormal is Lump 30: VertNormal type VertNormal struct { LumpGeneric data []primitives.VertNormal } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *VertNormal) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -28,14 +28,14 @@ func (lump *VertNormal) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *VertNormal) GetData() []primitives.VertNormal { return lump.data } -// Dump this lump back to raw byte data -func (lump *VertNormal) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *VertNormal) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/vertnormalindice.go b/lumps/vertnormalindice.go index 77c82d7..ca4815f 100644 --- a/lumps/vertnormalindice.go +++ b/lumps/vertnormalindice.go @@ -6,13 +6,13 @@ import ( "log" ) -// Lump 31: VertNormalIndice +// VertNormalIndice is Lump 31: VertNormalIndice type VertNormalIndice struct { LumpGeneric data []uint16 } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *VertNormalIndice) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -26,14 +26,14 @@ func (lump *VertNormalIndice) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *VertNormalIndice) GetData() []uint16 { return lump.data } -// Dump this lump back to raw byte data -func (lump *VertNormalIndice) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *VertNormalIndice) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/visibility.go b/lumps/visibility.go index 235ea74..290d8c4 100644 --- a/lumps/visibility.go +++ b/lumps/visibility.go @@ -7,13 +7,13 @@ import ( "log" ) -// Lump 4: Visibility +// Visibility is Lump 4: Visibility type Visibility struct { LumpGeneric data primitives.Vis } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *Visibility) Unmarshall(raw []byte, length int32) { err := binary.Read(bytes.NewBuffer(raw), binary.LittleEndian, &lump.data.NumClusters) if err != nil { @@ -33,14 +33,14 @@ func (lump *Visibility) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) } -// Get internal format structure data +// GetData gets internal format structure data func (lump *Visibility) GetData() *primitives.Vis { return &lump.data } -// Dump this lump back to raw byte data -func (lump *Visibility) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *Visibility) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data.BitVectors) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/worldlight.go b/lumps/worldlight.go index 6240c52..fb4f139 100644 --- a/lumps/worldlight.go +++ b/lumps/worldlight.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 15: Worldlight +// WorldLight is Lump 15: Worldlight type WorldLight struct { LumpGeneric data []primitives.WorldLight } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *WorldLight) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *WorldLight) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *WorldLight) GetData() []primitives.WorldLight { return lump.data } -// Dump this lump back to raw byte data -func (lump *WorldLight) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *WorldLight) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/lumps/worldlighthdr.go b/lumps/worldlighthdr.go index 3cb85af..c168636 100644 --- a/lumps/worldlighthdr.go +++ b/lumps/worldlighthdr.go @@ -8,13 +8,13 @@ import ( "unsafe" ) -// Lump 15: Worldlight +// WorldLightHDR is Lump 15: Worldlight type WorldLightHDR struct { LumpGeneric data []primitives.WorldLight } -// Import this lump from raw byte data +// Unmarshall Imports this lump from raw byte data func (lump *WorldLightHDR) Unmarshall(raw []byte, length int32) { lump.LumpInfo.SetLength(length) if length == 0 { @@ -27,14 +27,14 @@ func (lump *WorldLightHDR) Unmarshall(raw []byte, length int32) { } } -// Get internal format structure data +// GetData gets internal format structure data func (lump *WorldLightHDR) GetData() []primitives.WorldLight { return lump.data } -// Dump this lump back to raw byte data -func (lump *WorldLightHDR) Marshall() ([]byte,error) { +// Marshall dumps this lump back to raw byte data +func (lump *WorldLightHDR) Marshall() ([]byte, error) { var buf bytes.Buffer err := binary.Write(&buf, binary.LittleEndian, lump.data) - return buf.Bytes(),err + return buf.Bytes(), err } diff --git a/reader.go b/reader.go index 22392ab..91f0602 100644 --- a/reader.go +++ b/reader.go @@ -127,7 +127,7 @@ func ReadFromFile(filepath string) (*Bsp, error) { if err != nil { err2 := f.Close() if err2 != nil { - return nil,err2 + return nil, err2 } return nil, err } diff --git a/writer.go b/writer.go index 2284817..1fd024d 100644 --- a/writer.go +++ b/writer.go @@ -22,7 +22,7 @@ func (w *Writer) SetBsp(file Bsp) { } // Write bsp to []byte. -func (w *Writer) Write() ([]byte,error) { +func (w *Writer) Write() ([]byte, error) { // First we need to update the header to reflect any lump changes // At the same time we can dump our lumps as bytes to write later lumpBytes := make([][]byte, 64) @@ -36,11 +36,11 @@ func (w *Writer) Write() ([]byte,error) { w.data.lumps[int(index)].SetContents( gamelump.UpdateInternalOffsets(int32(currentOffset) - w.data.header.Lumps[int(index)].Offset)) } - exportBytes,err := w.WriteLump(index) + exportBytes, err := w.WriteLump(index) if err != nil { - return nil,err + return nil, err } - lumpBytes[int(index)] = exportBytes + lumpBytes[int(index)] = exportBytes lumpSize := len(lumpBytes[int(index)]) @@ -60,21 +60,21 @@ func (w *Writer) Write() ([]byte,error) { //Write Header err := binary.Write(&buf, binary.LittleEndian, w.data.header) if err != nil { - return nil,err + return nil, err } //Write lumps for _, lumpData := range lumpBytes { if err = binary.Write(&buf, binary.LittleEndian, lumpData); err != nil { - return nil,err + return nil, err } } - return buf.Bytes(),nil + return buf.Bytes(), nil } // WriteLump Exports a single lump to []byte. -func (w *Writer) WriteLump(index LumpId) ([]byte,error) { +func (w *Writer) WriteLump(index LumpId) ([]byte, error) { lump := w.data.GetLump(index) return lump.Marshall() }