Files
src/p_saveg.ml
Serializes and restores players, world state, thinkers, specials, and cross-object savegame references.
- Package
(global)- Reachable
- Yes
Imports
Declarations
# _PSave_EnsureBuffer
inline function _PSave_EnsureBuffer(size)
Ensures a byte buffer of at least the requested size exists and rewinds the shared stream cursor to zero.
| Parameter | Type | Default | Description |
|---|
size | dynamic | — | Requested size in bytes or elements. |
View source
# _PSV_ArchivePlayerV2
function _PSV_ArchivePlayerV2(p)
Writes the version-two player record in fixed field order, including commands, view, inventory, powers, weapons, counters, frags, and psprites.
| Parameter | Type | Default | Description |
|---|
p | dynamic | — | Object or data record consumed by the operation. |
View source
# _PSV_CheckTag
function _PSV_CheckTag(tag)
Consumes a four-byte section identifier and reports whether it matches the expected zero-padded tag.
| Parameter | Type | Default | Description |
|---|
tag | dynamic | — | Zone-memory or resource-lifetime tag. |
View source
# _PSV_ClearBlockLinks
function _PSV_ClearBlockLinks()
Empties every blockmap thing head before restoring mobj spatial links.
View source
# _PSV_ClearThingLists
function _PSV_ClearThingLists()
Clears sector thing chains before unarchived mobjs are relinked into the reconstructed world.
View source
# _PSV_ObjIndex
function _PSV_ObjIndex(arr, obj)
Resolves an object reference to its stable array index for serialized cross-references, returning -1 when absent.
| Parameter | Type | Default | Description |
|---|
arr | dynamic | — | Arr value supplied to `_PSV_ObjIndex`. |
obj | dynamic | — | Obj value supplied to `_PSV_ObjIndex`. |
View source
# _PSV_PlayerIndex
inline function _PSV_PlayerIndex(p)
Resolves a player record to its slot so mobj/player ownership links can be serialized as integers.
| Parameter | Type | Default | Description |
|---|
p | dynamic | — | Object or data record consumed by the operation. |
View source
# _PSV_ReadBool
inline function _PSV_ReadBool()
Consumes one canonical byte and interprets every nonzero value as true.
View source
# _PSV_ReadCeiling
inline function _PSV_ReadCeiling()
Recreates a ceiling mover, reclaims its sector, registers its thinker, and restores tagged active-ceiling control.
View source
# _PSV_ReadDoor
inline function _PSV_ReadDoor()
Recreates a vertical door from stream fields, reclaims its sector, and registers its movement thinker.
View source
# _PSV_ReadFixedString
function _PSV_ReadFixedString(width)
Consumes a fixed-width byte field and decodes its zero-terminated text prefix.
| Parameter | Type | Default | Description |
|---|
width | dynamic | — | Width of the target in pixels or map units. |
View source
# _PSV_ReadFlash
inline function _PSV_ReadFlash()
Recreates and registers a randomized two-level sector light-flash thinker from stream fields.
View source
# _PSV_ReadFloor
inline function _PSV_ReadFloor()
Recreates a floor mover from stream fields, reclaims its sector, and registers its movement thinker.
View source
# _PSV_ReadGlow
inline function _PSV_ReadGlow()
Recreates and registers a sector glow thinker with its saved brightness bounds and direction.
View source
# _PSV_ReadMapthing
inline function _PSV_ReadMapthing()
Consumes five signed fields and reconstructs one map spawn-point record.
View source
# _PSV_ReadMobj
function _PSV_ReadMobj()
Reconstructs an mobj from serialized fields, restores metadata and player ownership, and relinks its thinker and spatial indices.
View source
# _PSV_ReadPlat
inline function _PSV_ReadPlat()
Recreates a platform mover, reclaims its sector, registers its thinker, and restores tagged active-platform control.
View source
# _PSV_ReadPsprite
inline function _PSV_ReadPsprite()
Consumes a weapon sprite record and resolves its canonical state index back to a runtime reference.
View source
# _PSV_ReadS32
inline function _PSV_ReadS32()
Consumes four little-endian bytes and restores their signed 32-bit interpretation.
View source
# _PSV_ReadSectorRef
inline function _PSV_ReadSectorRef()
Consumes a sector index and returns its validated map reference, or void for malformed input.
View source
# _PSV_ReadStrobe
inline function _PSV_ReadStrobe()
Recreates and registers a sector strobe thinker with its saved countdown and timing bounds.
View source
# _PSV_ReadTiccmd
inline function _PSV_ReadTiccmd()
Consumes six signed fields and reconstructs one player tic command.
View source
# _PSV_ReadU8
inline function _PSV_ReadU8()
Consumes one byte from the shared stream, returning zero but still advancing when the cursor is out of range.
View source
# _PSV_ResolveThinkerMobj
function _PSV_ResolveThinkerMobj(node)
Resolves a thinker owner through current and legacy registries, accepting only objects with the core mobj fields.
| Parameter | Type | Default | Description |
|---|
node | dynamic | — | Node value supplied to `_PSV_ResolveThinkerMobj`. |
View source
# _PSV_SC_CEILING
const _PSV_SC_CEILING = 1
Defines psv sc ceiling for the p saveg subsystem.
View source
# _PSV_SC_DOOR
const _PSV_SC_DOOR = 2
Defines psv sc door for the p saveg subsystem.
View source
# _PSV_SC_FLASH
const _PSV_SC_FLASH = 5
Defines psv sc flash for the p saveg subsystem.
View source
# _PSV_SC_FLOOR
const _PSV_SC_FLOOR = 3
Defines psv sc floor for the p saveg subsystem.
View source
# _PSV_SC_GLOW
const _PSV_SC_GLOW = 7
Defines psv sc glow for the p saveg subsystem.
View source
# _PSV_SC_PLAT
const _PSV_SC_PLAT = 4
Defines psv sc plat for the p saveg subsystem.
View source
# _PSV_SC_STROBE
const _PSV_SC_STROBE = 6
Defines psv sc strobe for the p saveg subsystem.
View source
# _PSV_SectorIndex
inline function _PSV_SectorIndex(sec)
Resolves a sector object to its map-array index for thinker and world-state serialization.
| Parameter | Type | Default | Description |
|---|
sec | dynamic | — | Sec value supplied to `_PSV_SectorIndex`. |
View source
# _PSV_StateFromIndex
inline function _PSV_StateFromIndex(idx)
Restores a validated actor-state reference from its serialized canonical index.
| Parameter | Type | Default | Description |
|---|
idx | dynamic | — | Zero-based element or table index. |
View source
# _PSV_StateToIndex
function _PSV_StateToIndex(st)
Converts an actor-state reference to the canonical metadata index written into the save stream.
| Parameter | Type | Default | Description |
|---|
st | dynamic | — | St value supplied to `_PSV_StateToIndex`. |
View source
# _PSV_TC_MOBJ
const _PSV_TC_MOBJ = 1
Defines psv tc mobj for the p saveg subsystem.
View source
# _PSV_ToS32
inline function _PSV_ToS32(v)
Normalizes nullable savegame values to a stable signed 32-bit integer.
| Parameter | Type | Default | Description |
|---|
v | dynamic | — | Value consumed by the operation. |
View source
# _PSV_UnArchivePlayerV1
function _PSV_UnArchivePlayerV1(p)
Reads the legacy player layout, supplies defaults for fields introduced later, and leaves object links for post-load repair.
| Parameter | Type | Default | Description |
|---|
p | dynamic | — | Object or data record consumed by the operation. |
View source
# _PSV_UnArchivePlayerV2
function _PSV_UnArchivePlayerV2(p)
Reconstructs a version-two player record in stream order while validating enum indices and fixed-size arrays.
| Parameter | Type | Default | Description |
|---|
p | dynamic | — | Object or data record consumed by the operation. |
View source
# _PSV_WriteBool
inline function _PSV_WriteBool(v)
Appends a canonical one-byte boolean, encoding only literal true as one.
| Parameter | Type | Default | Description |
|---|
v | dynamic | — | Value consumed by the operation. |
View source
# _PSV_WriteCeiling
inline function _PSV_WriteCeiling(c)
Appends a ceiling mover's sector index, bounds, speed, crush flag, direction, tag, and saved direction.
| Parameter | Type | Default | Description |
|---|
c | dynamic | — | C value supplied to `_PSV_WriteCeiling`. |
View source
# _PSV_WriteDoor
inline function _PSV_WriteDoor(d)
Appends a vertical door's sector index, type, destination, speed, direction, wait, and countdown.
| Parameter | Type | Default | Description |
|---|
d | dynamic | — | Divisor or direction value used by the operation. |
View source
# _PSV_WriteFixedString
function _PSV_WriteFixedString(s, width)
Appends a fixed-width byte string, truncating excess text and zero-padding unused positions.
| Parameter | Type | Default | Description |
|---|
s | dynamic | — | S value supplied to `_PSV_WriteFixedString`. |
width | dynamic | — | Width of the target in pixels or map units. |
View source
# _PSV_WriteFlash
inline function _PSV_WriteFlash(f)
Appends a light flash's sector, countdown, brightness bounds, and randomized interval limits.
| Parameter | Type | Default | Description |
|---|
f | dynamic | — | F value supplied to `_PSV_WriteFlash`. |
View source
# _PSV_WriteFloor
inline function _PSV_WriteFloor(f)
Appends a floor mover's sector index, type, crush and direction flags, endpoint changes, destination, and speed.
| Parameter | Type | Default | Description |
|---|
f | dynamic | — | F value supplied to `_PSV_WriteFloor`. |
View source
# _PSV_WriteGlow
inline function _PSV_WriteGlow(g)
Appends a glow's sector, brightness bounds, and current oscillation direction.
| Parameter | Type | Default | Description |
|---|
g | dynamic | — | G value supplied to `_PSV_WriteGlow`. |
View source
# _PSV_WriteMapthing
inline function _PSV_WriteMapthing(mt)
Appends a spawn point's five map fields in fixed order, substituting a zero record for an absent spawn point.
| Parameter | Type | Default | Description |
|---|
mt | dynamic | — | Mt value supplied to `_PSV_WriteMapthing`. |
View source
# _PSV_WriteMobj
function _PSV_WriteMobj(mo)
Appends an mobj's position, physics, state, AI counters, player slot, and spawn point while omitting transient links.
| Parameter | Type | Default | Description |
|---|
mo | dynamic | — | Map object affected by the operation. |
View source
# _PSV_WritePlat
function _PSV_WritePlat(p)
Appends a platform's sector, travel bounds, timing, current and saved status, crush flag, tag, and behavior type.
| Parameter | Type | Default | Description |
|---|
p | dynamic | — | Object or data record consumed by the operation. |
View source
# _PSV_WritePsprite
inline function _PSV_WritePsprite(psp)
Appends a weapon sprite's canonical state index, timer, and screen coordinates, with an absent-state sentinel for void.
| Parameter | Type | Default | Description |
|---|
psp | dynamic | — | Psp value supplied to `_PSV_WritePsprite`. |
View source
# _PSV_WriteS32
inline function _PSV_WriteS32(v)
Appends a normalized signed 32-bit value in stable little-endian byte order.
| Parameter | Type | Default | Description |
|---|
v | dynamic | — | Value consumed by the operation. |
View source
# _PSV_WriteStrobe
inline function _PSV_WriteStrobe(s)
Appends a strobe's sector, countdown, brightness bounds, and dark/bright durations.
| Parameter | Type | Default | Description |
|---|
s | dynamic | — | S value supplied to `_PSV_WriteStrobe`. |
View source
# _PSV_WriteTag
function _PSV_WriteTag(tag)
Appends exactly four identifier bytes, padding a short save-section tag with zeros.
| Parameter | Type | Default | Description |
|---|
tag | dynamic | — | Zone-memory or resource-lifetime tag. |
View source
# _PSV_WriteTiccmd
inline function _PSV_WriteTiccmd(cmd)
Appends all six command fields in fixed order, substituting a neutral command when no record is supplied.
| Parameter | Type | Default | Description |
|---|
cmd | dynamic | — | Cmd value supplied to `_PSV_WriteTiccmd`. |
View source
# _PSV_WriteU8
inline function _PSV_WriteU8(v)
Appends the low byte of a normalized value, growing the save buffer before advancing the stream cursor.
| Parameter | Type | Default | Description |
|---|
v | dynamic | — | Value consumed by the operation. |
View source
# P_ArchivePlayers
function P_ArchivePlayers()
Writes the active-player mask followed by one versioned player record for each participating slot.
View source
# P_ArchiveSpecials
function P_ArchiveSpecials()
Serializes supported active ceiling, door, floor, platform, lighting, and button thinkers with sector references and terminates the list.
View source
# P_ArchiveThinkers
function P_ArchiveThinkers()
Counts serializable mobj thinkers and emits a versioned typed thinker section containing each validated owner.
View source
# P_ArchiveWorld
function P_ArchiveWorld()
Serializes mutable sector heights, textures, light, specials, and sidedef texture/offset state in map-array order.
View source
# P_UnArchivePlayers
function P_UnArchivePlayers()
Reads active player records for the detected save version and resets inactive slots to canonical defaults.
View source
# P_UnArchiveSpecials
function P_UnArchiveSpecials()
Recreates serialized special thinkers, reconnects their sector ownership, and rebuilds active ceiling/platform registries.
View source
# P_UnArchiveThinkers
function P_UnArchiveThinkers()
Clears old thinker and spatial ownership, then recreates every typed mobj in the validated thinker section.
View source
# P_UnArchiveWorld
function P_UnArchiveWorld()
Restores mutable sector and sidedef fields in map-array order, validating stream availability before each assignment.
View source
# save_p
save_p
Tracks the mutable save p value used by the p saveg subsystem.
View source
# savebuffer
savebuffer
Holds the optional savebuffer resource used by the p saveg subsystem.
View source