Vehicle lamp lights: same lamp colours on every run #445

Manually merged
github merged 1 commit from github-bot/gh-445 into gh-pr/445/base 2026-11-27 04:42:21 +00:00 AGit
Owner

@⁠holdmysocks on GitHub · 2026-11-27 03:05 UTC · original
holdmysocks:fix/lamp-lights-deterministic → master · +9 −3 · 1 files · 1 commits · merged 2026-11-27 04:36 UTC

Two runs of the same build gave different vehicles[].lights.lamp_lights in vehicles/vehicles.json for about 5 lamps (for example, bone d418625e came out ffb626 in one run and ebff8c in another).

Cause

Index::for_vehicle (crates/sixng-core/src/vehlights.rs) walks a light pack's lamp sets with p.lamp_sets.values(), and lamp_sets is a HashMap, so its order changes from one process to the next. lamp_lights and archetypes use entry(..).or_insert_with(..), so when a bone is in more than one of a pack's lamp sets, whichever set came up first won. That set changed between runs.

Fix

  • A pack's lamp sets are now visited sorted by set name hash. When a bone is in several of a pack's lamp sets, the set with the lowest name hash wins, for lamp_lights and for archetypes. None of the sets has a better claim than the others, so this rule only makes the choice stable. It does not judge which colour is right. The rest of the order is unchanged: the vehicle's light packs in index order come first, then the lamp sets its parts link, in part order.
  • light_table picks the first levels resource that holds a wanted light archetype with find_map_first instead of find_map_any. Without a cache, find_map_any could pick a different resource each time. With a cached vehicle_light_archetypes.json (the normal case), this change has no effect.

Checked

  • cargo test -p sixng-core --lib: 340 passed, 0 failed, 1 ignored.
  • Three sixng vehicles packs --out <dir> runs of this build gave byte-identical vehicles.json files (same SHA-256).
**@⁠holdmysocks** on GitHub · 2026-11-27 03:05 UTC · [original](https://github.com/holdmysocks/SixNG/pull/445) `holdmysocks:fix/lamp-lights-deterministic` → `master` · +9 −3 · 1 files · 1 commits · merged 2026-11-27 04:36 UTC Two runs of the same build gave different `vehicles[].lights.lamp_lights` in `vehicles/vehicles.json` for about 5 lamps (for example, bone `d418625e` came out `ffb626` in one run and `ebff8c` in another). ## Cause `Index::for_vehicle` (`crates/sixng-core/src/vehlights.rs`) walks a light pack's lamp sets with `p.lamp_sets.values()`, and `lamp_sets` is a `HashMap`, so its order changes from one process to the next. `lamp_lights` and `archetypes` use `entry(..).or_insert_with(..)`, so when a bone is in more than one of a pack's lamp sets, whichever set came up first won. That set changed between runs. ## Fix - A pack's lamp sets are now visited sorted by set name hash. **When a bone is in several of a pack's lamp sets, the set with the lowest name hash wins**, for `lamp_lights` and for `archetypes`. None of the sets has a better claim than the others, so this rule only makes the choice stable. It does not judge which colour is right. The rest of the order is unchanged: the vehicle's light packs in index order come first, then the lamp sets its parts link, in part order. - `light_table` picks the first levels resource that holds a wanted light archetype with `find_map_first` instead of `find_map_any`. Without a cache, `find_map_any` could pick a different resource each time. With a cached `vehicle_light_archetypes.json` (the normal case), this change has no effect. ## Checked - `cargo test -p sixng-core --lib`: 340 passed, 0 failed, 1 ignored. - Three `sixng vehicles packs --out <dir>` runs of this build gave byte-identical `vehicles.json` files (same SHA-256).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 03:08:44 +00:00
github-bot changed target branch from master to gh-pr/445/base 2026-11-27 04:42:18 +00:00
github manually merged commit 0f4e32dd0a into gh-pr/445/base 2026-11-27 04:42:21 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.