Skip to content

Fix sirens crash#233

Open
CanerKaraca23 wants to merge 2 commits into
user-grinch:mainfrom
CanerKaraca23:fix-sirens-crash-231520137231238520
Open

Fix sirens crash#233
CanerKaraca23 wants to merge 2 commits into
user-grinch:mainfrom
CanerKaraca23:fix-sirens-crash-231520137231238520

Conversation

@CanerKaraca23
Copy link
Copy Markdown
Contributor

Fixes a crash related to sirens without using the temporary workaround. The original crash was caused by accessing uninitialized vehicleData during the first few frames. The fix properly checks for existence and initializes vehicleData in src/features/sirens.cpp while removing the workaround in src/utils/modelinfomgr.cpp.

* Remove temporary frame-count workaround in `ModelInfoMgr::SetEditableMaterialsCB`.
* Initialize `vehicleData` entry lazily in `Sirens` `RegisterMaterialColProvider` lambda, preventing null pointer dereferencing when calling `vehicleData[pVeh]->GetCurrentState()`.
* Remove temporary frame-count workaround in `ModelInfoMgr::SetEditableMaterialsCB`.
* Initialize `vehicleData` entry lazily in `Sirens` `RegisterMaterialColProvider` lambda, preventing null pointer dereferencing when calling `vehicleData[pVeh]->GetCurrentState()`.
* Add bounds checking for `curState` against `modelData[pVeh->m_nModelIndex]->States.size()`.
Copilot AI review requested due to automatic review settings May 8, 2026 19:19
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an early-frame siren-related crash by moving the fix to the sirens feature logic (ensuring per-vehicle siren state exists before use) and removing the temporary render-time workaround.

Changes:

  • Removed the temporary “skip siren materials for first N frames” workaround from ModelInfoMgr::SetEditableMaterialsCB.
  • Lazily initializes vehicleData entries in the siren material color provider to avoid dereferencing uninitialized per-vehicle siren state.
  • Added bounds checking around the current siren state index before indexing the States vector.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/utils/modelinfomgr.cpp Removes the temporary early-frame siren material bypass workaround.
src/features/sirens.cpp Adds lazy initialization of vehicleData and guards state indexing to prevent early-frame crashes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/features/sirens.cpp
Comment on lines +614 to +616
if (!vehicleData.contains(pVeh)) {
vehicleData[pVeh] = new VehicleSiren(pVeh);
}
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.

2 participants