Scene archives (SCENES/**.ZIP)¶
A scene is one ZIP archive on the disc (SCENES/<mission>/<scene>.ZIP, for example SCENES/M05/M05_MAIN.ZIP), plus the scene's effects bank as loose .WAV/.WHD files beside it (dialogue and music stream from PS2_Eng.str). The disc has 71 scene archives: the 14 levels' _main scenes, their briefing (_premission), debriefing (_postmission) and news scenes, the per-mission LOADER_S loading-screen scenes, and the front-end scenes (bootmenu, attractmode, HitmanBloodMoney, saveandcontinue, errormessages). This page lists the members, the order the engine loads them in and how they refer to each other. Each member type has its own page.
The figures below cover the 71 PAL scene archives. To check the bytes for one scene, run these commands from the repository root with the disc image available to disc.py.
mkdir -p build/scene-corpus/M00_MAIN
python3 tools/port/disc.py extract SCENES/M00/M00_MAIN.ZIP build/M00_MAIN.ZIP
python3 -m zipfile -e build/M00_MAIN.ZIP build/scene-corpus/M00_MAIN
python3 tools/port/disc.py extract SCENES/M00/M00_MAIN.WHD build/scene-corpus/M00_MAIN/_disc.WHD
python3 tools/port/disc.py extract SCENES/M00/M00_MAIN.WAV build/scene-corpus/M00_MAIN/_disc.WAV
python3 -I tools/port/scene/roundtrip.py --corpus build/scene-corpus
For the full survey, repeat extraction in a separate folder for each archive returned by python3 tools/port/disc.py list "SCENES/*.ZIP". Check the input counts in the output. A zero denominator means the checker found no files of that type. Expect 71 GMS files and 56 LOC files.
Naming and lookup¶
ZEngineDataBase::DoLoadScene (src/engine/enginedata/enginedatabase.cpp:1824) turns the scene name into m_FileName (Scenes\M05\M05_main.gms). CalcCacheFileName(ext) (line 264) builds each member's name by overwriting the three characters after the last dot. DoLoadScene then mounts the whole archive as a big file (ZSysFile::LoadWholeSceneZip(CalcCacheFileName("zip")), line 1882). Every member is opened by that name, case-insensitively, inside the archive: Scenes/M05/M05_main.BUF and so on. The archives also carry GUI files at their root (menu/*.xml, difficultysettings.xml, money.xml, notoriety.xml), which the menu code opens by name while the archive is mounted. The loading-screen player opens LOADER_S.ZIP on its own (ZLoader_Sequence_PS2::Start, loader_sequence_player_ps2.cpp:115). That archive holds a small scene named Loader_Sequence, of which the player reads the .GMS, .PRM and .TEX.
Members and load order¶
Every archive holds the 14 members below except .LOC, which 56 of the 71 hold (not the loading-screen scenes or errormessages). .COL, .GST and .MAT have getters but appear in no archive. The loader in each row is in enginedatabase.cpp unless stated.
| Step | Member | Loader (line) | Required | Purpose | Page |
|---|---|---|---|---|---|
| 1 | .SUP |
DoLoadScene (1884) |
yes (ZDebugBreak if missing) |
a CHUNKFILE that is loaded and never read; the port finds the scene name by it |
scene-small.md |
| 2 | sizes of .PRM, .TEX, .BUF |
AllocSequence (1023) |
yes, all three | ||
| 3 | .BUF |
GetStaticData (372, at 1040) |
yes | static buffer: names, extra init data, material database and property blobs, all reached by offset | buf.md |
| 4 | .PRM |
GetPrimsData (385, at 1043) |
yes | prim (mesh, light, sprite) records by handle | prm.md |
| 5 | .LOC |
ResourceCollection::LoadFile (locale.cpp:70, at 1045) |
no | localised text resources | loc.md |
| 6 | .SND |
GetSoundData (446, at 1052) |
no | sound definitions, installed at step 15 | snd.md |
| 7 | .ANM |
GetAnimsData (483, at 1059) |
no | packed animations; its child chunk 4 feeds Animation::Manager (1132) |
anm.md |
| 8 | .RMC, .RMI |
LoadRoomTrees (1420) |
no | room collision and room-inside trees for ZCollisionBase |
rooms.md |
| 9 | .OCT |
LoadBoundTrees (1467); used by CreateBoundTrees (1436) after the geoms exist |
no | bound octrees per static container, then collision trees | oct.md |
| 10 | .SGP |
LoadSoundGraph (1491); CreateSoundGraph (1503) at the end |
no | sound propagation graph | sgp.md |
| 11 | .SGD |
LoadPackedStaticGameLevelData (1337) |
no | static game level data; loaded and never read | scene-small.md |
| 12 | .GMS |
GetGeomsData (398, at 1067), unpacked at 1098 |
yes | the compiled geometry tree | gms.md |
| 13 | .ZGF |
GetGeomFilesData (496, at 1074) |
no | files embedded for geometry loaders ("GeomFiles" big file); empty on the disc | scene-small.md |
| 14 | .WHD, .WAV |
sound DLL InstallWaveHeaders, InstallWaves (1093) |
no | wave headers and wave data, loose files beside the archive | snd.md |
| 15 | .SND installed, .PRM compacted and installed (1126), .TEX loaded and installed (InstallTextureBuffer, 354, at 1128) |
yes for .TEX |
textures | tex.md | |
| 16 | material database, animation manager, pathfinder, physics | 1129 to 1146, from offsets in the .GMS header |
gms.md, buf.md | ||
| 17 | .PRP |
CreatePropertyInputStream (405), read in CreateGeoms (550, at 1156) |
yes | ZDefines, then every geom's properties and controllers, in tree order | prp.md |
| — | .COL, .GST |
GetGlobalColiTreeSize/Data (330), GetGlobalStripColiTreeSize/Data (342) |
no | getters exist but nothing calls them in this build; none on the disc | |
| — | .MAT |
GetMaterialsSize/Data (427) |
no | getter with no caller; materials live in the .BUF |
After CreateGeoms, AllocSequence makes the default camera if there is none, builds room and bound trees (CreateRoomTrees is empty, CreateBoundTrees reads .OCT) and dynamic trees. It counts water patches by resolving each ZSTDOBJ's prim. It then runs Init, PostInit and PostInit2 over the tree.
Cross-references¶
| From | Field | To | Meaning |
|---|---|---|---|
.GMS SCompiledGeom |
lOffsetName |
.BUF |
geom name string |
.GMS SCompiledGeom |
lExData |
.BUF |
CHUNKFILE of extra init data ('KEYS', 0x80004, 'CUTS') |
.GMS SCompiledGeom |
lPrim |
.PRM |
prim handle (informational; the .PRP Prim property sets the geom's prim). For ZLoader_Sequence_Setup it is a byte offset into Loader_Sequence.PRM. |
.GMS header |
m_iMaterialDescOffset, m_iWeaponPrimsOffset, m_lPhysicsDataOffset, m_iExcludedAnimNamesOffset |
.BUF |
material database, weapon prim table, physics data, excluded animation names |
.GMS tree |
entry order and nesting | .PRP |
LoadPropertiesRecursive gives the n-th tree entry the n-th property object after the root's, and the .PRP Children counts must match the nesting |
.GMS tree |
lLightListID |
.GMS light table |
word index of the geom's light list |
.GMS SCompiledGeom |
lGeomType |
engine class registry, .PRP |
the class whose properties the .PRP object holds |
.GMS m_iGeomNr |
← .PRP refs, .GMS pathfinder ZLink::m_rDoorController, .BUF material database scene resources, rooms (ZROOM::RemapRefs), game data (RemapRefs) |
pRemaps[geom_nr − 1] turns a geom number into a run-time REF |
|
.GMS light lists |
entries | base-geom slots | (entry + 0x60) / 0x70, the allocation index of a base geom |
.BUF weapon prim table |
prim handles | .PRM |
weapon and ammo prims, purged by PurgePrimBuffer in _main scenes |
.BUF 'KEYS' chunk |
SWFCKeys offsets |
.BUF |
animation key arrays |
.PRP properties |
ExitsOffset, NeighborsOffset, SetupOffset, RawBonesDataOffset, FlowDataOffset, particle animation offsets |
.BUF |
room exits, crowd data, animation tables |
.PRP properties |
prim handles, texture ids | .PRM, .TEX |
see prp.md |
.PRM records |
texture ids | .TEX |
see prm.md |
.OCT |
static containers, in tree order | .GMS groups |
CreateBoundTrees hands blocks to each static ZTreeGroup in tree order |
Members documented elsewhere¶
.PRP, the property stream: prp.md..OCT,.RMCand.RMI, the bound and room trees: oct.md, rooms.md..SGP, the sound graph: sgp.md..PRM, the prims: prm.md..TEX, the textures: tex.md..ANM, the animations: anm.md..SND, the sound definitions: snd.md..LOC, the localised text: loc.md..WAVand.WHD, the wave data and headers: snd.md.
What a new scene needs¶
new-scene.md builds a whole playable scene (a room of our own with 47 in it) and lists every failure on the way. What it showed in practice:
| Member | Minimal content |
|---|---|
.SUP |
The 24-byte default (small.default_sup()). The file must exist. |
.ZGF |
Omit it, or use the 17-byte default (small.default_zgf()). |
.SGD |
Omit it, or use the 8-byte default. |
.GMS |
Header (physics 0xffffffff, material database offset, weapon prims 0), one SCompiledGeom per geom, a tree matching the .PRP, group counters, type counts, an empty light table, room environment list and pathfinder block (or offsets 0). See gms.md. A scene with _main but not m00 in its path loses 0x708 base geoms and 0x32000 extra-geom bytes in CountNrGeoms; a small one underflows. A playable scene can keep _main (it is a mission to the rest of the game) when its type counts stay above that, for example by keeping the base scene's counts, which also cover the ITEM/ZCOB resource geoms. |
.BUF |
The magic, one name per geom, and a material database (copy errormessages'). See buf.md. Appending names to a base scene's buffer keeps every offset the base geoms use. |
.PRM, .TEX |
Required by AllocSequence. See their pages. Appending blocks keeps every handle. |
.PRP |
Required: ZDefines, then one object per geom with matrix, position and prim. Removing subtrees is safe when every path that pointed into them is cleared; the loader resolves paths by name. With no ScriptC controller left, ScriptCModule may be empty. |
.OCT |
One block per static container (the root, every ZROOM and ZBackdrop) in ZGROUP::RecurGetNext order: the root, then each group's children in reverse tree order (AttachGeom prepends), depth first. Bound-tree leaves are run-time slots, which build_scene.simulate_refs computes from the .GMS and which match all the .OCT/.RMC REFs of the disc scenes. |
| collision bits | Hitman's ground and wall tests use COLIMASK_Sight (0x20): ZHitman3Movement line tests and ZLNKWHANDS' GetStrips(COLIMASK_Sight). A walkable mesh needs Sight in the geom's control byte (lGeomAndGroupCon & 0xff, tested by CalcGeomLineCallBack and GeomBoundCubeChk) and in each sub-prim's lColiBits. The disc's visible meshes mostly have only Background (0x2); its walkable surfaces are separate invisible meshes with 0x70. The new room uses 0xe2 on the geom and 0x62 on the prim. |
.RMC, .RMI |
Required as described below; one axis-aligned box per room is enough, and kept rooms keep their boxes with remapped REFs. |
.SGP |
One RoomSpec per ZROOM by name (sgp.build); rooms without exits are fine. A portal is a ZExit slot in both rooms (world-space corners here, room-local in the .BUF). |
| portals | Per room, a ZExit array in the .BUF named by ExitsOffset/m_lNrExits: corners top edge first with (p2 − p1) × (p3 − p1) pointing into the room, the neighbour as a geom number, the neighbour's slot, control 2. With them the room behind a doorway is drawn (new-scene.md). |
| actors | Characters need their prims, textures, animation collection and sounds in the same archive, so the mission in new-scene.md starts from a mission scene and clones its characters. Guards need a guard-quarters object. |
| lighting | A room with no lights draws characters black. A ZENVIRONMENT named _env_character with CharacterLight set, beside the room's EnvironmentLight, lights them (ZENVIRONMENT::ClassInit, ZOldDrawBase::CalcBoneEnvironment). Its prim is a 64-byte SPrimLightEnvironment (type 12). |
| the rest | The loader skips a missing .LOC, .SND, .ANM, .RMI, .OCT, .WAV or .WHD. Keep the others: the static line and box queries read the .RMC room tree without a null check, so write at least an empty 32-byte one (rooms.md); without an .SGP NPCs hear nothing, so write at least the 20-byte empty graph (sgp.md). An .ANM, when present, must have chunks 4, 8 and 9 (anm.md). |
The .GMS and .BUF are written together. buf.BufBuilder places the names and blocks and returns their offsets, gms.GeomList takes those offsets, and gms.write derives the rest. gms.check tests the tree, group counters and geom numbers against the rules CreateGeoms relies on.