Skip to content

fix: expand sparse vehicle positions during streaming conversion#133

Merged
fank merged 1 commit into
mainfrom
fix/sparse-vehicle-positions-v2
Feb 5, 2026
Merged

fix: expand sparse vehicle positions during streaming conversion#133
fank merged 1 commit into
mainfrom
fix/sparse-vehicle-positions-v2

Conversation

@fank
Copy link
Copy Markdown
Member

@fank fank commented Feb 5, 2026

Summary

  • Fix static vehicles (DShKs, etc.) disappearing after a few seconds in streaming playback
  • Fix incorrect endFrame calculation for vehicles using sparse position format
  • Previously converted missions need re-conversion after this fix

Problem

Arma 3 vehicles can use a sparse position format where each position entry covers a range of frames via [startFrame, endFrame] at index 4. The JSON frontend handles this correctly via range-based lookup (_positionsHasFrames), but the backend parser ignored the frame ranges entirely — it assigned sequential frame numbers (startFrame + arrayIndex), treating all positions as dense.

For a static DShK with 1 sparse entry covering frames 0–5000, the parser created only 1 position (frame 0). The streaming writer then only included the entity in frame 0 of the chunk data, causing it to disappear after the first frame and reappear only when it started moving (generating more position entries).

This also caused calculateEndFrame to return startFrame + 1 instead of 5000, giving wrong entity lifetime metadata.

Fix

  • collectEntityPositions: Detect sparse vehicle positions (entry[4] is [startFrame, endFrame] array) and expand each sparse entry into one EntityPosition per frame in the range
  • calculateEndFrame: For sparse data, use the last entry's frame range end instead of startFrame + len(positions) - 1

Test plan

  • TestParserV1_Parse_VehicleSparsePositions — verifies sparse→dense expansion (2 sparse entries → 15 dense positions)
  • TestParserV1_Parse_VehicleSparsePositions_ChunkBuild — end-to-end: static vehicle appears in every frame of built chunk
  • TestParserV1_Parse_VehicleDensePositions_Unaffected — regression: dense vehicle positions unchanged
  • TestParserV1_calculateEndFrame_SparseVehicle — endFrame uses last sparse range end
  • Full test suite passes

Arma 3 vehicles can use a sparse position format where each entry covers
a range of frames via [startFrame, endFrame] at index 4. The JSON
frontend handles this with range-based lookup (_positionsHasFrames), but
the parser assigned sequential frame numbers ignoring the ranges. This
caused static vehicles (like DShKs) to disappear after the first frame
in streaming playback, and reappear only when moving.

Expand sparse entries into dense per-frame positions in the parser and
fix calculateEndFrame to use the last sparse range end.

Previously converted missions need re-conversion.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 5, 2026

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/OCAP2/web/internal/storage 40.43% (-0.01%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/OCAP2/web/internal/storage/parser_v1.go 39.28% (+0.05%) 1255 (+103) 493 (+41) 762 (+62) 👍

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files

  • github.com/OCAP2/web/internal/storage/parser_test.go

@fank fank merged commit 40c6e66 into main Feb 5, 2026
2 checks passed
@fank fank deleted the fix/sparse-vehicle-positions-v2 branch February 5, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant