8  Persistent Data Formats

This walkthrough covers the persistent data formats for map levels in Doom.
We’ll explore how doomdata.h defines the on-disk structures used by the engine to load level geometry and entities.


8.0.1 📄 File: doomdata.h (lines 1–32)

Includes core headers and comments, then introduces enums and typedefs mapping directly to WAD file lumps for levels.


8.0.2 📄 File: doomdata.h (lines 43–56)

The ML_* enum specifies the lump order for each map: - ML_LABEL: separator/name
- ML_THINGS: thing spawn list
- ML_LINEDEFS: line definitions
- ML_SIDEDEFS: wall sides
- ML_VERTEXES: vertex list
- ML_SEGS: BSP segments
- ML_SSECTORS: subsectors
- ML_NODES: BSP nodes
- ML_SECTORS: sector definitions
- ML_REJECT: visibility LUT
- ML_BLOCKMAP: motion-clipping grid


8.0.3 📄 File: doomdata.h (lines 60–64)

mapvertex_t holds on-disk 16-bit vertex coordinates (x, y). These short values are converted into fixed-point (<<FRACBITS) at load time.


8.0.4 📄 File: doomdata.h (lines 69–77)

mapsidedef_t defines wall side appearance and linkage: - textureoffset, rowoffset: texture alignment (fixed-point)
- toptexture, bottomtexture, midtexture: 8-char names
- sector: index of the front (viewer-facing) sector


8.0.5 📄 File: doomdata.h (lines 84–93)

maplinedef_t describes a map line: - v1, v2: vertex indices
- flags: behavior bits (e.g., solidity, two-sided)
- special: effect number
- tag: sector trigger
- sidenum[2]: indices into mapsidedef_t (or -1 if one-sided)


8.0.6 📄 File: doomdata.h (lines 100–108)

LineDef flags: ```c #define ML_BLOCKING 1 // blocks all movement
#define ML_BLOCKMONSTERS 2 // blocks monsters only
#define ML_TWOSIDED 4 // line has two sides
#define ML_SECRET 32 // hide in automap
#define ML_SOUNDBLOCK 64 // blocks sound
#define ML_DONTDRAW 128 // invisible in automap
#define ML_MAPPED 256 // already seen on map