MiniDoom

src/p_setup.ml

Decodes map lumps into runtime geometry, links sector topology, spawns things/specials, and prepares a playable level.

Package
(global)
Reachable
Yes

Imports

Declarations

_PS_EnsureRuntimeArrays

function _PS_EnsureRuntimeArrays()

Ensures player and spawn tables have canonical capacities and rewinds deathmatch-start insertion for the new level.

View source

_PS_I16LE

inline function _PS_I16LE(b, off)

Decodes a two-byte map-lump field with signed 16-bit interpretation.

ParameterTypeDefaultDescription
bdynamic—Second input operand.
offdynamic—Zero-based byte or element offset.

View source

_PS_MapName

inline function _PS_MapName(episode, map)

Maps episode/map numbers to canonical ExMy or MAPnn lump names, with edition-appropriate first-map fallback.

ParameterTypeDefaultDescription
episodedynamic—Episode value supplied to `_PS_MapName`.
mapdynamic—Map value supplied to `_PS_MapName`.

View source

_PS_Name8

inline function _PS_Name8(data, off)

Extracts an eight-byte texture or flat name field from a map record without decoding it prematurely.

ParameterTypeDefaultDescription
datadynamic—Binary or structured data to process.
offdynamic—Zero-based byte or element offset.

View source

_PS_ReadLumpBytes

inline function _PS_ReadLumpBytes(lump)

Allocates an exact-size buffer and copies a map lump into it, returning an empty buffer for zero-length lumps.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `_PS_ReadLumpBytes`.

View source

_PS_U16LE

inline function _PS_U16LE(b, off)

Decodes an unsigned 16-bit little-endian field from a map lump.

ParameterTypeDefaultDescription
bdynamic—Second input operand.
offdynamic—Zero-based byte or element offset.

View source

_PS_VertexOrZero

inline function _PS_VertexOrZero(idx)

Resolves a map vertex index and substitutes an origin vertex for malformed references.

ParameterTypeDefaultDescription
idxdynamic—Zero-based element or table index.

View source

_PSET_IDiv

inline function _PSET_IDiv(a, b)

Returns a signed quotient truncated toward zero, or zero for invalid operands and a zero divisor in `_PSET_IDiv`

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_PSET_IsSeq

inline function _PSET_IsSeq(v)

Recognizes both array and list containers accepted by map geometry and runtime tables.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_PSET_LoadPulse

inline function _PSET_LoadPulse(text)

Keeps the window responsive and updates loading UI during expensive level setup phases.

ParameterTypeDefaultDescription
textdynamic—Text to process.

View source

P_GroupLines

function P_GroupLines()

Assigns subsector sectors and builds each sector's line list, fixed bounds, blockmap bounds, and centered sound origin.

View source

P_Init

function P_Init()

Prepares switch pairs, animated flats/textures, and sprite definitions shared by all subsequently loaded levels.

View source

P_LoadBlockMap

function P_LoadBlockMap(lump)

Decodes BLOCKMAP words, promotes its origin, normalizes cell offsets, and allocates empty per-cell thing chains.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadBlockMap`.

View source

P_LoadLineDefs

function P_LoadLineDefs(lump)

Decodes LINEDEFS, resolves vertices and sectors, and precomputes direction, slope class, and bounding boxes.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadLineDefs`.

View source

P_LoadNodes

function P_LoadNodes(lump)

Decodes BSP partition origins, directions, child bounds, and node-or-subsector child identifiers.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadNodes`.

View source

P_LoadSectors

function P_LoadSectors(lump)

Decodes SECTORS records, resolves flat names, and initializes mutable sound, thing, line, and special ownership fields.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadSectors`.

View source

P_LoadSegs

function P_LoadSegs(lump)

Decodes SEGS geometry and resolves its linedef, sidedef, front sector, and optional opposite sector links.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadSegs`.

View source

P_LoadSideDefs

function P_LoadSideDefs(lump)

Decodes SIDEDEFS offsets and texture names, then resolves each record's owning sector reference.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadSideDefs`.

View source

P_LoadSubsectors

function P_LoadSubsectors(lump)

Decodes SSECTORS seg ranges while leaving sector ownership for the later line-grouping pass.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadSubsectors`.

View source

P_LoadThings

function P_LoadThings(lump)

Decodes THINGS records and spawns edition-compatible map objects, stopping at unsupported commercial actors in noncommercial games.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadThings`.

View source

P_LoadVertexes

function P_LoadVertexes(lump)

Decodes four-byte VERTEXES records and promotes map-unit coordinates to fixed-point runtime vertices.

ParameterTypeDefaultDescription
lumpdynamic—Lump value supplied to `P_LoadVertexes`.

View source

P_SetupLevel

function P_SetupLevel(episode, map, playermask, skill)

Tears down prior level state, loads map lumps in dependency order, links geometry, spawns actors/specials, precaches assets, and enters GS_LEVEL.

ParameterTypeDefaultDescription
episodedynamic—Episode value supplied to `P_SetupLevel`.
mapdynamic—Map value supplied to `P_SetupLevel`.
playermaskdynamic—Playermask value supplied to `P_SetupLevel`.
skilldynamic—Skill value supplied to `P_SetupLevel`.

View source