wadgo

package module
v0.0.0-...-be10663 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 19 Imported by: 0

README

Where'd All the Data Go?

WadGo is a Go package that provides a read-only WAD parser, a file type used in the Doom engine and its various source ports, notably ZDoom and its forks. WadGo focuses on providing a full featured preview generator, allowing the creation of PNG maps for the level layouts within a WAD.

In addition to its WAD parsing features, WadGo also provides basic parsers for SECTINFO and MAPINFO, file specifications commonly seen alongside WADs. This allows for enhanced previews and the ability to obtain extra metadata about levels in a given file.

Credits

Credits to Saline and Rozark for BAN09 and NBC01 respectively. They are used solely as test cases for preview generation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HexenLinedefFlags

type HexenLinedefFlags uint16
const (
	HexenMLBlocking                     HexenLinedefFlags = 0x0001
	HexenMLBlockMonsters                HexenLinedefFlags = 0x0002
	HexenMLTwoSided                     HexenLinedefFlags = 0x0004
	HexenMLDontPegTop                   HexenLinedefFlags = 0x0008
	HexenMLDontPegBottom                HexenLinedefFlags = 0x0010
	HexenMLSecret                       HexenLinedefFlags = 0x0020
	HexenMLSoundBlock                   HexenLinedefFlags = 0x0040
	HexenMLDontDraw                     HexenLinedefFlags = 0x0080
	HexenMLMapped                       HexenLinedefFlags = 0x0100
	HexenMLRepeatSpecial                HexenLinedefFlags = 0x0200
	HexenMLPlayerUseActivates           HexenLinedefFlags = 0x0400
	HexenMLMonsterCrossActivates        HexenLinedefFlags = 0x0800
	HexenMLProjectileImpactActivates    HexenLinedefFlags = 0x0C00
	HexenMLPlayerBumpActivates          HexenLinedefFlags = 0x1000
	HexenMLProjectileCrossActivates     HexenLinedefFlags = 0x1400
	HexenMLPlayerUseActivatesUseThrough HexenLinedefFlags = 0x1800
	HexenMLMonstersCanActivate          HexenLinedefFlags = 0x2000
	HexenMLBlockPlayers                 HexenLinedefFlags = 0x4000
	HexenMLBlockEverything              HexenLinedefFlags = 0x8000
)

type LinedefsLump

type LinedefsLump struct {
	Linedefs []LinedefsLumpLinedef
}

func NewLinedefsLumpFromBytes

func NewLinedefsLumpFromBytes(data []byte, hexenFormat bool) (*LinedefsLump, error)

type LinedefsLumpLinedef

type LinedefsLumpLinedef struct {
	V1 int
	V2 int

	Flags HexenLinedefFlags

	HexenSpecial int
	Arg0         int
	Arg1         int
	Arg2         int
	Arg3         int
	Arg4         int

	DoomSpecial int
	Tag         int

	FrontSidedef int
	BackSidedef  int
}

type MapInfoLump

type MapInfoLump struct {
	Maps []*MapInfoLumpEntry
}

func NewMapInfoLump

func NewMapInfoLump() *MapInfoLump

func NewMapInfoLumpFromBytes

func NewMapInfoLumpFromBytes(data []byte) (*MapInfoLump, error)

func NewMapInfoLumpFromFile

func NewMapInfoLumpFromFile(path string) (*MapInfoLump, error)

func NewMapInfoLumpFromReader

func NewMapInfoLumpFromReader(r io.Reader) (*MapInfoLump, error)

type MapInfoLumpEntry

type MapInfoLumpEntry struct {
	MapCode string
	MapName string
}

func NewMapInfoLumpEntry

func NewMapInfoLumpEntry() *MapInfoLumpEntry

type MapPreviewCallback

type MapPreviewCallback *func(dc *gg.Context, wadMap *WadMap, sectInfo *SectInfoLump, minX float64, maxX float64, minY float64, maxY float64, xOffset float64, yOffset float64)

type MapPreviewConfig

type MapPreviewConfig struct {
	Style              MapPreviewStyle
	DrawSpawns         bool
	InitialCallback    MapPreviewCallback
	PreLineCallback    MapPreviewCallback
	PrePointCallback   MapPreviewCallback
	PreSpawnsCallback  MapPreviewCallback
	PreCalloutCallback MapPreviewCallback
	FinalCallback      MapPreviewCallback
}

type MapPreviewStyle

type MapPreviewStyle int
const (
	MapPreviewStyleEditor MapPreviewStyle = iota
	MapPreviewStyleAutomap
	MapPreviewStyleClean
)

type SectInfoCallout

type SectInfoCallout struct {
	Index       int
	CalloutName string
	SectorIDs   []int
}

func NewSectInfoCallout

func NewSectInfoCallout() *SectInfoCallout

type SectInfoLump

type SectInfoLump struct {
	Maps map[string]*SectInfoLumpEntry
}

func NewSectInfoLump

func NewSectInfoLump() *SectInfoLump

func NewSectInfoLumpFromBytes

func NewSectInfoLumpFromBytes(data []byte) (*SectInfoLump, error)

func NewSectInfoLumpFromFile

func NewSectInfoLumpFromFile(path string) (*SectInfoLump, error)

func NewSectInfoLumpFromReader

func NewSectInfoLumpFromReader(r io.Reader) (*SectInfoLump, error)

type SectInfoLumpEntry

type SectInfoLumpEntry struct {
	MapCode string

	// Zandronum
	Callouts []*SectInfoCallout
	Points   []*SectInfoPoint

	// ZDaemon
	Base0 []int
	Base1 []int
}

func NewSectInfoLumpEntry

func NewSectInfoLumpEntry() *SectInfoLumpEntry

type SectInfoPoint

type SectInfoPoint struct {
	Index     int
	PointName string
	SectorIDs []int

	// MM8BDM
	Primary bool
}

func NewSectInfoPoint

func NewSectInfoPoint() *SectInfoPoint

type SectorsLump

type SectorsLump struct {
	Sectors []SectorsLumpSector
}

func NewSectorsLumpFromBytes

func NewSectorsLumpFromBytes(data []byte) (*SectorsLump, error)

type SectorsLumpSector

type SectorsLumpSector struct {
	FloorHeight   int
	CeilingHeight int

	FloorTexture   string
	CeilingTexture string

	LightLevel int
	Special    int
	Tag        int
}

type SidedefsLump

type SidedefsLump struct {
	Sidedefs []SidedefsLumpSidedef
}

func NewSidedefsLumpFromBytes

func NewSidedefsLumpFromBytes(data []byte) (*SidedefsLump, error)

type SidedefsLumpSidedef

type SidedefsLumpSidedef struct {
	XOffset int
	YOffset int

	TopTexture    string
	MiddleTexture string
	BottomTexture string

	Sector int
}

type TextmapLump

type TextmapLump struct {
	Namespace string
	Things    []*TextmapLumpThing
	Vertices  []*TextmapLumpVertex
	Lines     []*TextmapLumpLinedef
	Sides     []*TextmapLumpSidedef
	Sectors   []*TextmapLumpSector
}

func NewTextmapLumpFromBytes

func NewTextmapLumpFromBytes(data []byte) (*TextmapLump, error)

type TextmapLumpLinedef

type TextmapLumpLinedef struct {
	ID int

	V1 int
	V2 int

	Blocking      bool
	BlockMonsters bool
	TwoSided      bool
	DontPegTop    bool
	DontPegBottom bool
	Secret        bool
	BlockSound    bool
	DontDraw      bool
	Mapped        bool

	PassUse bool

	PlayerCross   bool
	PlayerUse     bool
	MonsterCross  bool
	MonsterUse    bool
	Impact        bool
	PlayerPush    bool
	MonsterPush   bool
	MissileCross  bool
	RepeatSpecial bool

	Special int
	Arg0    int
	Arg0Str string // ZDoom
	Arg1    int
	Arg2    int
	Arg3    int
	Arg4    int

	SideFront int
	SideBack  int

	Comment string

	// ZDoom
	Alpha       float64
	RenderStyle string

	PlayerUseBack      bool
	AnyCross           bool
	MonsterActivate    bool
	BlockPlayers       bool
	BlockEverything    bool
	FirstSideOnly      bool
	ZoneBoundary       bool
	ClipMidTex         bool
	WrapMidTex         bool
	MidTex3D           bool
	MidTex3DImpassible bool

	CheckSwitchRange bool
	BlockProjectiles bool
	BlockUse         bool
	BlockSight       bool
	BlockHitscan     bool
	LockNumber       int

	MoreIDs []int

	Transparent bool

	UserBooleans map[string]bool
	UserFloats   map[string]float64
	UserInts     map[string]int
	UserStrings  map[string]string
}

func NewTextmapLumpLinedef

func NewTextmapLumpLinedef() *TextmapLumpLinedef

type TextmapLumpObject

type TextmapLumpObject interface {
	// contains filtered or unexported methods
}

type TextmapLumpSector

type TextmapLumpSector struct {
	HeightFloor   int
	HeightCeiling int

	TextureFloor   string
	TextureCeiling string

	LightLevel int

	Special int
	ID      int

	Comment string

	// ZDoom
	XPanningFloor   float64
	YPanningFloor   float64
	XPanningCeiling float64
	YPanningCeiling float64
	XScaleFloor     float64
	YScaleFloor     float64
	XScaleCeiling   float64
	YScaleCeiling   float64
	RotationFloor   float64
	RotationCeiling float64

	CeilingPlaneA float64
	CeilingPlaneB float64
	CeilingPlaneC float64
	CeilingPlaneD float64
	FloorPlaneA   float64
	FloorPlaneB   float64
	FloorPlaneC   float64
	FloorPlaneD   float64

	LightFloor           int
	LightCeiling         int
	LightFloorAbsolute   bool
	LightCeilingAbsolute bool
	AlphaFloor           float64
	AlphaCeiling         float64
	RenderStyleFloor     string
	RenderStyleCeiling   string
	Gravity              float64
	LightColor           int
	FadeColor            int
	Desaturation         float64

	Silent              bool
	NoFallingDamage     bool
	DropActors          bool
	NoRespawn           bool
	SoundSequence       string
	Hidden              bool
	WaterZone           bool
	MoreIDs             []int
	DamageAmount        int
	DamageType          string
	DamageInterval      int
	Leakiness           int
	DamageTerrainEffect bool
	FloorTerrain        string
	CeilingTerrain      string

	PortalCeilBlockSound  bool
	PortalCeilDisabled    bool
	PortalCeilNoPass      bool
	PortalCeilNoRender    bool
	PortalCeilOverlayType string

	PortalFloorBlockSound  bool
	PortalFloorDisabled    bool
	PortalFloorNoPass      bool
	PortalFloorNoRender    bool
	PortalFloorOverlayType string

	UserBooleans map[string]bool
	UserFloats   map[string]float64
	UserInts     map[string]int
	UserStrings  map[string]string
}

func NewTextmapLumpSector

func NewTextmapLumpSector() *TextmapLumpSector

type TextmapLumpSidedef

type TextmapLumpSidedef struct {
	OffsetX int
	OffsetY int

	TextureTop    string
	TextureBottom string
	TextureMiddle string

	Sector int

	Comment string

	// ZDoom
	ScaleXTop    float64
	ScaleYTop    float64
	ScaleXMid    float64
	ScaleYMid    float64
	ScaleXBottom float64
	ScaleYBottom float64

	OffsetXTop    float64
	OffsetYTop    float64
	OffsetXMid    float64
	OffsetYMid    float64
	OffsetXBottom float64
	OffsetYBottom float64

	Light          int
	LightAbsolute  bool
	LightFog       bool
	NoFakeContrast bool
	ClipMidTex     bool
	WrapMidTex     bool
	NoDecal        bool

	UserBooleans map[string]bool
	UserFloats   map[string]float64
	UserInts     map[string]int
	UserStrings  map[string]string
}

func NewTextmapLumpSidedef

func NewTextmapLumpSidedef() *TextmapLumpSidedef

type TextmapLumpThing

type TextmapLumpThing struct {
	ID int

	X float64
	Y float64

	Height float64
	Angle  int
	Type   int

	Skill1  bool
	Skill2  bool
	Skill3  bool
	Skill4  bool
	Skill5  bool
	Skill6  bool // ZDoom
	Skill7  bool // ZDoom
	Skill8  bool // ZDoom
	Skill9  bool // ZDoom
	Skill10 bool // ZDoom
	Skill11 bool // ZDoom
	Skill12 bool // ZDoom
	Skill13 bool // ZDoom
	Skill14 bool // ZDoom
	Skill15 bool // ZDoom
	Skill16 bool // ZDoom

	Ambush bool
	Single bool
	DM     bool
	Coop   bool

	Friend bool

	Dormant bool

	Class1  bool
	Class2  bool
	Class3  bool
	Class4  bool
	Class5  bool // ZDoom
	Class6  bool // ZDoom
	Class7  bool // ZDoom
	Class8  bool // ZDoom
	Class9  bool // ZDoom
	Class10 bool // ZDoom
	Class11 bool // ZDoom
	Class12 bool // ZDoom
	Class13 bool // ZDoom
	Class14 bool // ZDoom
	Class15 bool // ZDoom
	Class16 bool // ZDoom

	Standing    bool
	StrifeAlly  bool
	Translucent bool
	Invisible   bool

	Special int
	Arg0    int
	Arg0Str string // ZDoom
	Arg1    int
	Arg2    int
	Arg3    int
	Arg4    int

	Comment string

	Conversation int
	CountSecret  bool
	Gravity      float64

	Health int

	RenderStyle   string
	FillColor     int
	Alpha         float64
	Score         int
	Pitch         int
	Roll          int
	ScaleX        float64
	ScaleY        float64
	Scale         float64
	FloatBobPhase int

	UserBooleans map[string]bool
	UserFloats   map[string]float64
	UserInts     map[string]int
	UserStrings  map[string]string
}

func NewTextmapLumpThing

func NewTextmapLumpThing() *TextmapLumpThing

type TextmapLumpVertex

type TextmapLumpVertex struct {
	X float64
	Y float64

	// ZDoom
	ZFloor   float64
	ZCeiling float64

	UserBooleans map[string]bool
	UserFloats   map[string]float64
	UserInts     map[string]int
	UserStrings  map[string]string
}

func NewTextmapLumpVertex

func NewTextmapLumpVertex() *TextmapLumpVertex

type ThingsLump

type ThingsLump struct {
	Things []ThingsLumpThing
}

func NewThingsLumpFromBytes

func NewThingsLumpFromBytes(data []byte, hexenFormat bool) (*ThingsLump, error)

type ThingsLumpThing

type ThingsLumpThing struct {
	Tag           int
	X             int
	Y             int
	Z             int
	Angle         uint16
	DoomEd        int
	Flags         int16
	ActionSpecial int
	Arg0          int
	Arg1          int
	Arg2          int
	Arg3          int
	Arg4          int
}

type VertexesLump

type VertexesLump struct {
	Vertexes []VertexesLumpVertex
}

func NewVertexesLumpFromBytes

func NewVertexesLumpFromBytes(data []byte) (*VertexesLump, error)

type VertexesLumpVertex

type VertexesLumpVertex struct {
	X int
	Y int
}

type Wad

type Wad struct {
	Header    WadHeader
	Directory []*WadLump
	Maps      []*WadMap
}

func NewWadFromBytes

func NewWadFromBytes(data []byte) (*Wad, error)

func NewWadFromFile

func NewWadFromFile(path string) (*Wad, error)

func NewWadFromReader

func NewWadFromReader(r io.Reader) (*Wad, error)

func (*Wad) GetLump

func (wad *Wad) GetLump(name string) *WadLump

type WadHeader

type WadHeader struct {
	Identification string
	NumLumps       int
	// contains filtered or unexported fields
}

type WadLump

type WadLump struct {
	Name string
	Data []byte

	Things   *ThingsLump
	Vertexes *VertexesLump
	Linedefs *LinedefsLump
	Sidedefs *SidedefsLump
	Sectors  *SectorsLump
	Textmap  *TextmapLump
	// contains filtered or unexported fields
}

type WadMap

type WadMap struct {
	Name   string
	Format string
	Lumps  []*WadLump
	Level  *WadMapLevel
}

func (*WadMap) GeneratePreview

func (wadMap *WadMap) GeneratePreview(config *MapPreviewConfig, sectInfo *SectInfoLump) (*bytes.Buffer, error)

func (*WadMap) GetLump

func (wadMap *WadMap) GetLump(name string) *WadLump

type WadMap3DSector

type WadMap3DSector struct {
	Side          *WadMapSide
	ControlSector *WadMapSector
	TargetSectors []*WadMapSector

	Type WadMap3DSectorType

	FloorAccessible bool
}

func NewWadMap3DSector

func NewWadMap3DSector() *WadMap3DSector

type WadMap3DSectorType

type WadMap3DSectorType int
const (
	WadMap3DSectorVavoomStyle WadMap3DSectorType = iota
	WadMap3DSectorSolid
	WadMap3DSectorSwimmable
	WadMap3DSectorNonSolid
)

type WadMapLevel

type WadMapLevel struct {
	Things        []*WadMapThing
	Vertices      []*WadMapVertex
	Lines         []*WadMapLine
	Sides         []*WadMapSide
	Sectors       []*WadMapSector
	ThreeDSectors []*WadMap3DSector
}

type WadMapLine

type WadMapLine struct {
	V1 *WadMapVertex
	V2 *WadMapVertex

	FrontSide *WadMapSide
	BackSide  *WadMapSide

	FrontSector *WadMapSector
	BackSector  *WadMapSector

	VisibleSectors int
	Crossable      bool
	Bridge         bool

	Hidden     bool
	Secret     bool
	Impassable bool
	Alpha      float64

	Special int
	Arg0    int
	Arg1    int
	Arg2    int
	Arg3    int
	Arg4    int

	Tags []int
}

func NewWadMapLine

func NewWadMapLine() *WadMapLine

type WadMapSector

type WadMapSector struct {
	Sides    []*WadMapSide
	Polygons [][]*WadMapVertex

	Controlled3DSector *WadMap3DSector
	ThreeDSectors      []*WadMap3DSector

	AdjacentSectors []*WadMapSector

	Things []*WadMapThing

	Skybox bool

	Hidden     bool
	LightLevel int

	FloorHeight   float64
	CeilingHeight float64

	HighestSector           *WadMapSector
	HighestAccessibleSector *WadMapSector

	FloorAccessible bool

	FloorTexture   *WadMapTexture
	CeilingTexture *WadMapTexture

	Tags []int
}

func NewWadMapSector

func NewWadMapSector() *WadMapSector

type WadMapSide

type WadMapSide struct {
	Sector *WadMapSector
	Line   *WadMapLine

	TopTexture    *WadMapTexture
	MiddleTexture *WadMapTexture
	BottomTexture *WadMapTexture
}

func NewWadMapSide

func NewWadMapSide() *WadMapSide

type WadMapTexture

type WadMapTexture struct {
	Texture string

	XScale float64
	YScale float64

	XOffset float64
	YOffset float64
}

func NewWadMapTexture

func NewWadMapTexture() *WadMapTexture

type WadMapThing

type WadMapThing struct {
	Index int

	Sector *WadMapSector

	DoomEd int

	X     float64
	Y     float64
	Z     float64
	Angle float64

	Special int
	Arg0    int
	Arg1    int
	Arg2    int
	Arg3    int
	Arg4    int

	Tags []int
}

func NewWadMapThing

func NewWadMapThing() *WadMapThing

type WadMapVertex

type WadMapVertex struct {
	Lines []*WadMapLine

	VisibleLines int

	X float64
	Y float64
}

func NewWadMapVertex

func NewWadMapVertex() *WadMapVertex

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL