diff --git a/src/features/sirens.cpp b/src/features/sirens.cpp index 0fcfe46..4e28a98 100755 --- a/src/features/sirens.cpp +++ b/src/features/sirens.cpp @@ -611,13 +611,19 @@ void Sirens::Init() int matIdx = GetSirenIndex(pVeh, pMat); if (matIdx != - 1) { + if (!vehicleData.contains(pVeh)) { + vehicleData[pVeh] = new VehicleSiren(pVeh); + } int curState = vehicleData[pVeh]->GetCurrentState(); - auto& state = modelData[pVeh->m_nModelIndex]->States[curState]; - if (state->Materials.contains(matIdx)) { - if (modelData[pVeh->m_nModelIndex]->isImVehFtSiren) { - return MatStateColor{state->Materials[matIdx]->Color, state->Materials[matIdx]->Color}; - } else { - return MatStateColor{state->Materials[matIdx]->Color, DEFAULT_MAT_COL}; + + if (curState >= 0 && curState < modelData[pVeh->m_nModelIndex]->States.size()) { + auto& state = modelData[pVeh->m_nModelIndex]->States[curState]; + if (state->Materials.contains(matIdx)) { + if (modelData[pVeh->m_nModelIndex]->isImVehFtSiren) { + return MatStateColor{state->Materials[matIdx]->Color, state->Materials[matIdx]->Color}; + } else { + return MatStateColor{state->Materials[matIdx]->Color, DEFAULT_MAT_COL}; + } } } } diff --git a/src/utils/modelinfomgr.cpp b/src/utils/modelinfomgr.cpp index af43e7f..aa69223 100755 --- a/src/utils/modelinfomgr.cpp +++ b/src/utils/modelinfomgr.cpp @@ -240,12 +240,6 @@ RpMaterial *ModelInfoMgr::SetEditableMaterialsCB(RpMaterial *material, void *dat { auto &data = m_VehData.Get(pCurVeh); - // Sirens crash fix TODO: remove this and fix it - if (iLightIndex == eMaterialType::SirenLight && data.nFrameCount <= 10) - { - return material; - } - bool lightOn = false; data.m_MatAvail[iLightIndex] = true;