OpenTPW

TRACK-002: public consumer audit of the .hmp height profile#

Status#

1. Load path (implemented)#

TrackPieceKit.GetHeightProfile (source/OpenTPW/World/Tracks/TrackPieceKit.cs:77) is the only .hmp load site for pieces: StemOf (:48) → the kit's archive snapshot (:29) → OpenRead (:88) → new HmpFile inside a using → InvalidDataException/IOException become null (:91) → cached per stem including the negative result (:96). A missing file performs zero OpenRead calls (the TryGetValue at :84 guards the open). ObjectHeightMaps.MapOf (source/OpenTPW/World/Objects/ObjectHeightMaps.cs:17) has the same shape for ride models.

Reader bounds (source/OpenTPW.Files/Public/HmpFile.cs:60–:113): 1 MiB cap (:100), header presence (:64), version+magic (:67), samples 1–16 (:73), cells 1–256 (:75), contiguous section offsets (:83), exact length (:85), finite box (:91), bounds-checked accessors (:45, :53).

Prior annotation (TOUR-005, source/OpenTPW/World/Tours/TourApproximations.cs:11): the map of a piece "is never rebuilt here either, its size is not compared with the original's expected size".

2. Consumers#

Original readerOwnerOpenTPW counterpartStatus
0x4511A0 vehicle samplerkart / water / bumper vehiclesTrackSurface via TrackRenderer.SurfaceHeightimplemented; correctly map-free
0x452AE0 tour callerstour carsTrackRenderer.PieceGround ← Level.TourObjectGroundimplemented
0x452AE0 owner routetour cars over an owned objectObjectHeightMaps.Heightimplemented
0x45CDC0, 0x532FC0, 0x536CA0, 0x5370E0; 0x4689F0build ghosts / ride previewnone in the files reviewedopen question
0x466B70instance bounding boxnone in the files reviewedopen question
0x463060 flag copylandscape flagsnone in the files reviewedopen question, settle-able

2.1 Vehicles read no map (implemented, correct)#

Level.Tracks.cs:379 → TrackRenderer.cs:121 → :299 → the probe at :100 → SurfaceHeight (:471), which resolves to TrackSurface faces (:504–:511), the ride object (:516), the add-on delegate (:489) or the landscape (Terrain, :476; TileHeight, :251). TrackSurface.cs contains no reference to HmpFile. This matches the register (TrackApproximations.cs:12); the vehicle side needs no work and must not be re-opened. Note TileHeight is 0x466D70's landscape midrange, not the 0x466B70 map-extremes reader.

2.2 Tour cars — the implemented consumer#

TrackRenderer.PieceGround (TrackRenderer.cs:275–:290) resolves an extension cell to its origin, requires an origin tile of this family with a piece and no add-on flag, then returns map.CellMaxima.Span[index] * ObjectHeightMaps.ByteScale + TileHeight(...)/ModelScale. Level.TourObjectGround (Level.Tours.cs:23–:34) tries the piece branch for every non-bumper family first, then the owner route — the precedence TOUR-005 records.

2.3 Owner-object route#

ObjectHeightMaps.Height (:48–:57) skips deleted and fixed items, takes <mesh>.hmp from the ride archive, indexes through the same CellIndex, and returns the byte scaled by ByteScale = 0.39215687f (:12, 100/255) plus the base height.

2.4 Preview, ghosts, bounds, flag copy#

No counterpart appears in the files reviewed. That is an open question, not a recorded missing implementation: nothing here asserts OpenTPW needs one, and no defect is claimed.

3. Bounds and semantics#

4. Fields actually read at runtime#

Only CellMaxima (and Width/Height via CellIndex). Profile, Sample, CellMaximum, CellFlags, BoundingBox and Scale are parsed and pinned by tests but have no runtime consumer in the files reviewed. Scale is not used even for scaling; ByteScale is a constant.

5. Current tests (read, not executed)#

6. Remaining gates#

  1. Semantic size/rebuild parity (§3) — needs a decision plus evidence, not a bounds fix.

  2. Enforcement of the (5, 100) loader pair and runtime use of Scale remain open; acceptance of (5, 100) is already pinned.

  3. Preview / ghost / bounding-box / flag-copy counterparts — open questions (§2.4).

  4. Asset tests are inconclusive without game data; execution requires an authorized environment with the matching game data.

7. Conclusion#

Implemented: the piece load and its bounds; the vehicle sampler's freedom from the map; the two described tour map lookup routes. TOUR-005 still records fence-post/station and map-rebuild residuals; overall tour parity is not established. Open: the items in §6, none of which this audit turns into code. Not claimed: any test result, any parity, any missing implementation.

Source: docs/proposals/track-002-public-consumer-audit.md in the project repository.