Skip to content

Fix sirens crash - #233

Merged
AmeerDotEXE merged 1 commit into
user-grinch:mainfrom
CanerKaraca23:fix-sirens-crash-231520137231238520
Aug 1, 2026
Merged

Fix sirens crash#233
AmeerDotEXE merged 1 commit 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.

Copilot AI review requested due to automatic review settings May 8, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

@AmeerDotEXE AmeerDotEXE left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, good one thanks

* 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()`.
@AmeerDotEXE
AmeerDotEXE force-pushed the fix-sirens-crash-231520137231238520 branch from 1275df6 to 533e245 Compare August 1, 2026 20:23
@AmeerDotEXE
AmeerDotEXE merged commit 06a204e into user-grinch:main Aug 1, 2026
1 check failed
@CanerKaraca23
CanerKaraca23 deleted the fix-sirens-crash-231520137231238520 branch August 1, 2026 21:26
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.

3 participants