Fix sirens crash#233
Open
CanerKaraca23 wants to merge 2 commits into
Open
Conversation
* 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()`.
Contributor
There was a problem hiding this comment.
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
vehicleDataentries 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
Statesvector.
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 on lines
+614
to
+616
| if (!vehicleData.contains(pVeh)) { | ||
| vehicleData[pVeh] = new VehicleSiren(pVeh); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes a crash related to sirens without using the temporary workaround. The original crash was caused by accessing uninitialized
vehicleDataduring the first few frames. The fix properly checks for existence and initializesvehicleDatainsrc/features/sirens.cppwhile removing the workaround insrc/utils/modelinfomgr.cpp.