Scene properties (.PRP)¶
Every scene archive (SCENES/**.ZIP) holds one .PRP, the scene's property stream. It carries everything the compiled geometry (.GMS) does not: each geometry's class properties (positions, flags, references to other geometries, outfit, animation set), every controller attached to a geometry (scripts, path followers, doors, inventories, level control), the AI script imports, and the scene's ZDefines. This file describes it from the code that reads it and checks it against all 71 PRPs on the disc. tools/port/scene/prp.py parses and rewrites all 71 byte for byte (python -I tools/port/scene/roundtrip.py --ext PRP prints PRP: 71/71 identical).
A PRP is not a format of its own. It is the level-file stream of IOI's packed serializer, ZPackedOutput/ZPackedInput (src/engine/serializerlib/packed_stream.cpp), and its contents are whatever ZEngineDataBase::CreateGeoms exchanges, in that order. No property names are stored: the stream is written without a dictionary, so a property is identified only by its position in its class's property list.
Loading¶
| Step | Code |
|---|---|
Open <scene>.prp from the scene ZIP as a stream |
ZEngineDataBase::CreatePropertyInputStream, src/engine/enginedata/enginedatabase.cpp:412 |
| Called after the GMS geometries exist | AllocSequence, enginedatabase.cpp:1163; CreateGeoms (line 557) allocates every geometry first, then reads the PRP (lines 760 to 778) |
| Header, string table, object count | ZPackedInput::Init, packed_stream.cpp:405; ZTokenTable_Serializerlib::Load, dictionary.cpp:30 |
| ZDefines | ZEngineDataBase::LoadZDefines, enginedatabase.cpp:802 |
| Geometry tree | LoadProperties and LoadPropertiesRecursive, enginedatabase.cpp:866 and 873 |
| One object | ISerializerStream::Exchange<T> (header tag, ExchangeData, footer tag), IInputSerializerStream::_ExchangeObject (serializerstream.cpp:102: PreLoad, LoadObject, PostLoad), RTP::LoadSerializable (rtp.cpp:26) |
| Property values | ZDataProperty/ZVirtualProperty/ZEnumProperty Load templates and Exchangers, src/hitman3/hitman3/hm3properties.cpp:287 to 480 and 2305 to 2425 |
| Deferred object fix-ups | IInputSerializerStream::PostProcess, serializerstream.cpp:112, run by ZPackedInput::End |
Geometry references in the stream are paths, resolved while loading by ZEngineDataBase::GetREFByName (enginedatabase.cpp:2076) through ZGROUP::FindGeom (src/engine/geomsbase/zgroup.cpp:762). Every geometry already exists at that point, so forward references are fine.
File layout¶
All values are little-endian (big_endian 0 in every file).
| Offset | Field | Value on the disc | Read by |
|---|---|---|---|
| 0x00 | signature | "IOPacked v0.1\0" (14 bytes) |
CheckSignature (packed_stream.cpp:394); the reader skips it without comparing |
| 0x0e | big_endian, u8 |
0 | Init |
| 0x0f | m_Type, i32 (ISerializerStream::EType) |
13 = TYPE_LevelFile = Tags (1) + StringEnums (4) + StringTable (8) |
Init |
| 0x13 | m_Content, i32 (EContent) |
0 = CONTENT_LevelFile |
Init |
| 0x17 | string table: m_LargestToken u32, byte length u32, then the words, each NUL-terminated |
6 to 4,286 words | ZTokenTable_Serializerlib::Load |
| … | numberOfObjects, u32 |
number of TAG_BeginObject tags in the stream |
Init sizes m_ProcessTable with it |
| … | token stream up to and including TAG_EndOfStream (0x7f) |
ZPackedInput CheckTag and ExchangeData |
There is no dictionary block (type bit 2 is clear), no padding, and nothing after the end tag.
String table¶
m_LargestToken is the word count minus one; the reader walks m_LargestToken + 1 NUL-terminated words. A string, an enumerator name and a bitfield bit are all stored as a u32 index into this table. The writer (ZFastDictionary_Serializerlib, ZPackedOutput::End, packed_stream.cpp:857) hands out tokens in order of first use, so in every file on the disc the table is exactly the distinct strings in the order the stream first uses them: no duplicates, no unused words, and the empty string is an ordinary word (it is how an empty geometry reference or message is stored). prp.write rebuilds the table this way.
Tokens¶
Each value is a one-byte tag (ZPackedStream::ETag, packed_stream.h) and its payload. Named tags (bit 7 set, followed by a dictionary token) need a dictionary and never occur.
| Tag | Name | Payload | Count on the disc |
|---|---|---|---|
| 0x01 | TAG_Array |
u32 element count, the elements, then 0x7c | 461,355 |
| 0x02 | TAG_BeginObject |
the object's values, then 0x7e | 232,329 |
| 0x04 | TAG_Container |
u32 count; the count elements follow without a closing tag | 451,282 |
| 0x06 | TAG_Bool |
u8, 0 or 1 | 617,639 |
| 0x07 | TAG_Int8 |
u8 (unsigned char properties) |
36,193 |
| 0x08 | TAG_Int16 |
i16 | 18,515 |
| 0x09 | TAG_Int32 |
i32 (also every uint32) |
356,977 |
| 0x0a | TAG_Float32 |
IEEE single | 2,815,596 |
| 0x0c | TAG_String |
u32 string token | 229,694 |
| 0x0d | TAG_RawData |
u32 size, size bytes | 295 |
| 0x0e | TAG_Enum |
u32 string token of the enumerator's name (ZEnumEntry::m_Name) |
298,021 |
| 0x0f | TAG_Bitfield |
u32 number of set bits, then one string token per set bit, lowest bit first | 3,082 |
| 0x7c | TAG_EndArray |
461,355 | |
| 0x7d | TAG_SkipMark |
(closes a ZScriptC import block, below) | 2,617 |
| 0x7e | TAG_EndObject |
232,329 | |
| 0x7f | TAG_EndOfStream |
71 |
TAG_Reference (3), TAG_Char (5) and TAG_Float64 (11) exist in the reader but no level file uses them. Because enums are stored by name, enumerator values never appear in the file, and a reordered enum in the engine still loads old files.
Stream structure¶
Container N "ZDefines"
N × ZDefine
Geom(ROOT) LoadPropertiesRecursive, depth first, when the GMS contains packed geometries
Bool SimpleRepack only when the GMS has at least one packed geometry
EndOfStream
Geom:
Object the geometry's own class properties
Container C "Controllers"
C × ( String ControllerName, Object )
Container K "Children"
K × Geom
ZDefines¶
Scene-wide variables that LoadZDefines stores in the scene's CCom (GetSceneCom()->SetVal). Each entry is String Name, Int32 Type (CCOM_TYPE, src/engine/zstdlib/ccom.h) and a type-specific tail:
| Type | Tail |
|---|---|
2 INT32 |
Int32 Size, Array[Size] of Int32 |
3 FLOAT |
Int32 Size, Array[Size] of Float32 |
12 STRING, 14 FILE |
String Data |
16 GEOMREF |
String Data, a geometry path (GetREFByName) |
17 GEOMREFTAB |
Container n, n Strings (paths) |
Any other type is a ZDebugBreak. The names on the disc:
| Name | Type | Files | Read by |
|---|---|---|---|
ScriptCModule |
STRING | 71 | ZScriptC::SetName (scriptc.cpp:87): the script module scriptcs/_gamerelease/<name>.ps2 (M05); empty for scenes without scripts |
PostFilterPalettes |
INT32 | 71 | ZPostFilterEvent::PostLoad, postfilter.cpp:104: a prim handle of the palette table; a post-filter controller with this at 0 dereferences null |
PostFilterBoxes |
INT32 | 12 | postfilter.cpp:1108, a prim handle |
CameraNear, CameraFar, CameraFOV, CameraTargetLen, CameraFogBegin, CameraFogFull |
FLOAT | 56 | basecamera.cpp:285 and the camera setup |
CameraBackColor (3 ints), CameraBackgroundColor |
INT32 | 51, 43 | |
MainCamera, MainCamera2 to 4, CameraControlList, HitmanGround |
GEOMREF | 51 | checkinside.cpp:24, selectnotify.cpp:21, scripts |
ItemsGroup, WeaponsGroup |
GEOMREF | 56 | inventory.cpp:46, hm3items.cpp:1262: where items and weapons are spawned |
DefaultPostFilterCamera, DefaultPostFilterReference, DefaultPostFilterCutSeqReference |
GEOMREF | 43 | postfilter.cpp:929 |
PS2_Dot3TurnoffDistance, PS2_SpecularTurnoffDistance |
FLOAT | 27 | |
PS2_EnableStaticShadowSeamsFixup, PS2_DisableStaticShadowAdditive, PC_XBOX_EnableDotFadeDropShadows |
INT32 | 13, 12, 7 | |
StaticShadowSampleHeightLimit |
FLOAT | 5 | renderbase.cpp:151 |
The geometry tree¶
The first record is the root, ROOT, a ZROOM that AllocRootGroup creates (ZGeomBuffer::AllocGeom("ROOT", 0x100021, 0)), not a GMS record. After it, each Children entry takes the next entry of the GMS packed geometry tree (BaseGeoms[], in SPackedGeomsTree order), so a depth-first walk of the PRP tree, root excluded, visits exactly the GMS's packed geometries in order. The two files must agree: the number of non-root records equals the GMS tree count, and each record's children count equals that geometry's children in the GMS tree. Across the disc this holds for all 198,583 geometries (2 to 13,045 records per file including the root, up to 12 levels deep).
The PRP never names a geometry's class. The class is SCompiledGeom::lGeomType of the matching GMS record, the id a ZFactoryProducer<Class>(id, ZGEOMCLASSINFO(...)) registers (0x100001 ZGROUP, 0x100021 ZROOM, 0x200002 ZSTDOBJ, 0x2003e9 ZHM3Actor, 0x2003e8 ZHitman3, 0x100446 ZHM3HmAs, 0x800001a ZLIST, ...; 157 classes, 105 used on the disc). The name is the BUF string at SCompiledGeom::lOffsetName.
Controllers¶
ControllerName is a ZBaseConRout factory name; ZGEOM::AddEvent (src/engine/geomsbase/zgeom.cpp:880) looks it up and creates the controller, then the object that follows is loaded into it. Each controller class registers two names, for example ScriptC and ZGEOM_ScriptC (ZFactoryProducer<ZScriptC>); the disc uses the short ones. A name with no factory makes the loader skip the object (IInputSerializerStream::SkipObject): the 14 CheatMenu controllers on the disc are empty objects of that kind. 33,675 controllers of 150 classes appear on the disc.
Objects and properties¶
An object is the class's level-file properties, in RTP::LoadSerializable order: the super class's list first (recursively up to RTP::cBase), then the class's own, each list in cNode::m_Next order, skipping properties whose m_Filter lacks FILTER_LevelFile (1). The lists are the property graph tools/property_records.py generated from the ELF into the tail of src/hitman3/hitman3/hm3properties.cpp (ZPropertyInfo X::Info = { first, &Super::Info, 0 } and cProperties::NamespaceItem_N). The release ELF leaves every cNode::m_Name at 0, so the tools name a property after what it points at: the member for a ZDataProperty (m_rHitmanAs), the accessor stem for a ZVirtualProperty (GetMatrix/SetMatrix → Matrix). tools/port/scene/prp_schema.py reads the graph from the source.
The graph accounts for every value of every object on the disc: all 232,315 objects with a class decode to exactly their property list, with nothing left over, except ZScriptC, whose PostLoad adds the imports below. The LoadObject overrides that read more (ZGEOM's control word and events, for example) do so only for saved games, and no other class adds values to a level file.
Every geometry starts with ZGEOM's five properties:
| Property | Type | Note |
|---|---|---|
BoundingBox |
enum EBoundingBox: BOUNDING_Static, BOUNDING_Dynamic, BOUNDING_DynamicAutoAssign |
ZGEOM::SetBoundingBox is empty; the GMS control word decides |
Matrix |
float[9] |
SetMatrix (zgeom.cpp:64). An unrotated geometry stores [0,0,1, 0,1,0, 1,0,0]; 198,381 of the matrices have determinant −1 |
Position |
float[3] |
SetPosition, relative to the parent group |
Inactive |
bool | SetInactive is empty |
Prim |
unsigned int |
SetPrim: the PRM prim handle; equals SCompiledGeom::lPrim for every geometry on the disc |
Matrix and Position repeat the GMS's (lOffsetMat, lOffsetPos into the unpacked GMS) for all but 109 and 131 geometries; the PRP's values are applied last and win.
Value encodings¶
The C++ type of a property decides its tokens. These are all the types level-file properties use:
| C++ type | Tokens | Python value (Property.value) |
|---|---|---|
bool |
Bool | bool |
unsigned char |
Int8 | int |
short, unsigned short |
Int16 | int |
int, unsigned int, ZCOLOR, ZAUDIOREF, ZMESHVARIANT, ZSDOwner (m_iSoundDefinitionIndex), TIMETYPE (secs, fixed point) |
Int32 | int |
float |
Float32 | float |
T[N], T[N][M] (float[3], float[9], float[8][4], int[3], unsigned int[128], ...) |
Array of N (or N·M) elements | list |
enum (ZEnumProperty, ZVirtualEnumProperty) |
Enum | enumerator name |
ZBitfield<E> |
Bitfield | list of enumerator names |
ZRTString, ZANIM, ZFILENAME |
String (RTP::LoadConstString, ext_conststring.cpp:12) |
str |
ZGEOMREF, T * (ZROOM *, ZLIST *, ...) |
String, a geometry path; empty for none (Exchanger<ZGEOMREF>::Load, hm3properties.cpp:2403) |
str |
ZMsg |
String, a message name registered with RegisterZMsg; empty for none (Exchanger<ZMsg>::Load, line 2415) |
str |
REFTAB, REFTAB32, REFTAB * |
Container n, then n Strings (paths); a REFTAB * of 0 entries is a null table (Exchanger<REFTAB>::Load, line 2305) |
list of str |
ZRawData |
Container n, then RawData of n bytes when n > 0 (line 1613) | bytes |
The other kinds the graph declares (objects such as ZHM3CameraColi, structures loaded inline such as ZFurniture::ZBits and SMonSeerInfo[32], ZStackArray, ZSimpleArray, ZArray) are all saved-game only; prp.py decodes them too in case a file uses them.
Geometry paths are ROOT\ followed by the group names down to the geometry, separated by \, compared case-insensitively. Names may contain /, ! and # (ROOT\M05/M05_CHARACTERS.zip\Characters!Guards!House!FBI_Patrol01_stuff!WayPointList). FindGeom tries matching groups in order until one resolves the rest of the path.
Script controllers (ZScriptC)¶
ScriptC objects hold the one property Name (ZScriptC::SetName, scriptc.cpp:86: loads the ScriptCModule module and finds the SCRIPTCREATOR with FindScript, which folds case and reads / and \ as _, so m05\m05_donutguard is M05_M05_Donutguard). ZScriptC::PostLoad (scriptc.cpp:125) then reads the script's imports, one per SCRIPTIMPORT entry of the creator's property list, base scripts first:
SCRIPTIMPORT type |
Tokens |
|---|---|
| byte, short, long | Array of count Int32 (narrowed when stored) |
| float | Array of count Float32 |
| string | Array of count Strings |
| REF | count bare Strings, geometry paths |
and the object ends with a SkipMark (stream.Skip(), scriptc.cpp:290), so a loader without the script skips straight to it. The import lists are in src/scripts/<LEVEL>/*.c and src/scripts/Alllevels/*.c (see shared-scripts.json) (<Script>_properties[]), and the variable each import fills is the target of the matching SF.Input call in <Script>_Imports; prp_schema.scripts() reads both for all 436 creators, and all 2,617 script controllers on the disc decode against them. The names are the decompiled sources' (characterType, waypointList, startingWeapon, quarters; some are still placeholders such as flag0_0).
Invariants¶
- Type 13, content 0, little-endian, no dictionary; only unnamed tags.
- The string table is the distinct strings in first-use order;
m_LargestToken= count − 1; the length field is the sum of the word lengths plus their NULs. numberOfObjectsequals the number of BeginObject tags. The loader sizes the table of objects waiting forPostProcesswith it, so it must not be smaller.- Arrays store their element count (no flattened-structure arrays occur in level files).
- The tree has one record per GMS packed geometry plus the root, in GMS tree order, with the GMS's child counts.
SimpleRepackis present (and false) in every file; it follows the tree only when the GMS has geometries.- There are no hashes, checksums, alignment or offsets anywhere in the file: it can be regenerated from its values alone.
Survey of the 71 scene PRPs¶
534 bytes (alllevels/errormessages) to 2.2 MB (M10_main). 198,654 geometry records, 33,675 controllers, 232,329 objects, 2,617 script controllers. The most common geometry classes are ZSTDOBJ (108,513), ZGROUP (10,487), ZParticleEmitter (8,771), ZWINPIC (7,512) and ZWINGROUP (7,264); the most common controllers CTimeOutDelete (6,600), ZShotActivate (3,842), ZScriptC (2,617), ZHM3WeaponUpgradeProperty (2,500) and ZAffectedByLightSwitch (1,623). Every one of the 1,035 ZHM3Actor geometries has a ScriptC controller; 437 also have a PathFollower, 64 an Inventory, 34 an AttachGeomToBone. 307 different scripts drive them, alllevels\guard (138) and alllevels\civilian (47) the most.
Writing a scene¶
prp.py builds objects from property values: new_object(class, {name: value}) fills a class's whole property list in order (omitted properties take False, 0, 0.0, "", [] or the enum's first name), and new_script(name, {import: value}) builds a ScriptC object with its imports and SkipMark. Rebuilding all 232,315 objects on the disc from their decoded values reproduces their tokens exactly. This rebuilds alllevels/errormessages.PRP byte for byte:
IDENTITY = [0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0]
root = Geom(new_object("ZROOM", {"Matrix": IDENTITY, "m_fPFResMultiplier": 1.0,
"LightShinesIn": True, "LightShinesOut": True, "DynamicContainer": True,
"StaticContainer": True, "m_eNoiseLevel": "eNormal", "m_eLocationState": "eUNDEFINED"}))
group = Geom(new_object("ZGROUP", {"Matrix": IDENTITY, "m_fPFResMultiplier": 1.0,
"LightShinesIn": True, "LightShinesOut": True}))
group.children.append(Geom(new_object("ZSTDOBJ", {"Matrix": IDENTITY,
"Position": [4.75579, 0.0, -6.55529], "Prim": 6})))
root.children.append(group)
data = write(PrpFile([ZDefine("ScriptCModule", CCOM_TYPE_STRING, ""),
ZDefine("PostFilterPalettes", CCOM_TYPE_INT32, [7])], root, False))
A minimal scene therefore needs: the ZDefines ScriptCModule (a module name, or empty with no scripts) and PostFilterPalettes (a prim handle in the PRM); a ROOT ZROOM record; one record per GMS geometry with the class's full property list and Prim equal to the GMS lPrim; the SimpleRepack flag. A playable mission scene also sets the camera ZDefines, ItemsGroup/WeaponsGroup, a camera setup and a level-control controller (LevelControlM05, a ZHM3LevelControlMxx that names the mission's targets, items and exits by path), as every _main scene on the disc does.
What a new actor needs¶
An NPC is a group (a ZGROUP whose Position/Matrix place the character) holding a ZHM3Actor geometry, conventionally named Ground; scripts and other records address it as ROOT\...\<group>\Ground. In the GMS it is a 0x2003e9 record with the character mesh's prim. In the PRP it needs:
- the ZHM3Actor object (ZGEOM, ZSTDOBJ, ZLNKOBJ, ZLNKWHANDS, ZActor and ZHM3Actor lists):
Prim(the mesh),m_lVariantId(mesh variant),AnimCollectionProperty(ananmcol:animationdatabase#<set>collection in the scene's ANM),m_SoundMappingMaterialandm_SoundDef/m_MaterialDef(audio and sound-definition indices into the SND data),m_fActorPitch,m_pAudibleRoomList(rooms, usually empty),m_rHitmanAs(the outfit: a ZHM3HmAs group, underClothBundleon the disc),OverrideHitpoints(0 for the default) andm_rActorProperties(an optional ZHM3ActorProperties geometry: known disguises, recognition speed, forget time, inspection distances); - a
ScriptCcontroller with the AI script and its imports.alllevels\guardtakesallowScriptPause,recalculatePriority(bytes),characterType,waypointList(REF),moodProfile,gender,ignoreHelpRequests2,startingWeapon(REF to a weapon geometry underWeaponsGroup),weaponProfile,radioChannel,quarters(REF to a ZGuardQuarterController geometry),registersWithQuarters,keepsWeaponDrawn;alllevels\civilianthe first seven of those; - for
alllevels\guard(and scripts built on it), aquartersobject that has aZGuardQuarterController: without one the script's root enter skips its weapon setup and default states and the guard never patrols (new-scene.md, failure 4); - optionally a
PathFollower(ZPathFollower:m_WayPointLists, a REFTAB of ZLIST geometries whoseGeomListholds the waypoints;m_eTypeLOOPING/PINGPONG/RANDOM/ONEWAY; walk flags) and anInventory(CInventorym_StartInventory, a REFTAB of item geometries).
The outfit, if new, is a ZHM3HmAs record (m_rClothBundleGroup, m_FootwearMaterial, m_rtWeaponsAllowed, m_eDressQuality, m_AllowedZones, m_rtItemContainerAllowed, m_iDisguiseGroup, m_bMayUseLadders, ExtraOptionName). A target is an ordinary actor that the mission's level-control controller and scripts reference by path (ZHM3LevelControlM05::m_rWitness, for example).
Tools¶
tools/port/scene/prp.py:parse(data, geoms=None)→PrpFile(defines,roottree ofGeomwithobject,controllers,children),write(prp)→ bytes,load(path)(reads the sibling GMS and BUF to name classes and geometries),scene_geoms(gms, buf),decode_object,new_object,new_script. AnObjectholdsPropertygroups (engine name, C++ type, tokens,.value) and loose tokens;writeonly emits tokens, so a decoded file rewrites identically.python -I tools/port/scene/prp.py dump <file.PRP> [--all] [--raw]lists ZDefines, then every geometry with its class and properties and every controller (--allincludesBoundingBox,InactiveandPrim). Use--rawto display SkipMarks. See scene archives for the corpus layout.python -I tools/port/scene/prp.py roundtrip build/scene-corpusprints71/71 identical;roundtrip.py --ext PRPruns the same check with full decoding.tools/port/scene/prp_schema.py: the property graph, enum names, geometry and controller class registries and script imports, read fromsrc/.
Unknown¶
- The meaning of most individual properties is only as good as their member names; ranges and defaults per property have not been surveyed.
- Why 109 matrices and 131 positions differ from the GMS's copies (the PRP wins at load).
BoundingBoxandInactiveare ignored by the loader (empty setters); whether a writer may leave them at defaults without side effects in other tools is untested.- Several script import names are decompiler placeholders (for example
importedRef2F4andimportedInt29C); their meaning comes from reading the script. - The engine accepts strings without a string table and enums as integers (other
ETypebits), but no file on the disc uses them andprp.pydoes not write them. - The requirements above come from the loader and the disc data. One new scene has been loaded in the port so far (new-scene.md): a base scene's tree with subtrees removed and a room added.
PC version¶
Every PC .PRP decodes against the PS2 class schema. One thing differs in meaning: the decal systems' m_PreCalcPrims arrays, which on the PS2 name decal prims the tool appended to the .PRM, hold leftover memory on the PC, whose engine makes its decal prims at run time; the PC m_lMaxNrMarks are twice the PS2's (32, 32, 32 and 64). PcConvertProperties (port/engine/system/_sdl/pcdata/pcdecals.{h,cpp}) rewrites those 100 arrays and counts in place to name the decal prims PcConvertPrims appends (Decal prims); nothing else changes and the size stays. It finds the decal systems without the schema, from the token stream alone. The engine opens the .PRP as a stream (CreatePropertyInputStream calls the archive's open), not through ZSysFile::Load, so the converted member has to be served there.