Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/features/sirens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,9 @@ void Sirens::EventCtor(CVehicle *pVeh)
{
if (Sirens::modelData.contains(pVeh->m_nModelIndex))
{
vehicleData[pVeh] = new VehicleSiren(pVeh);
if (!vehicleData.contains(pVeh)) {
vehicleData[pVeh] = new VehicleSiren(pVeh);
}
}
}

Expand Down Expand Up @@ -611,13 +613,19 @@ void Sirens::Init()
int matIdx = GetSirenIndex(pVeh, pMat);

if (matIdx != - 1) {
if (!vehicleData.contains(pVeh)) {
vehicleData[pVeh] = new VehicleSiren(pVeh);
}
Comment thread
AmeerDotEXE marked this conversation as resolved.
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};
}
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/utils/modelinfomgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading