further MaterialDatabase checks

This commit is contained in:
Kae 2024-06-02 14:02:16 +10:00
parent 41bad6c97c
commit 986db9cfc5
3 changed files with 12 additions and 8 deletions

View File

@ -188,15 +188,21 @@ private:
}; };
inline MaterialRenderProfileConstPtr MaterialDatabase::materialRenderProfile(MaterialId materialId) const { inline MaterialRenderProfileConstPtr MaterialDatabase::materialRenderProfile(MaterialId materialId) const {
if (materialId >= m_materials.size()) if (materialId < m_materials.size()) {
if (auto const& mat = m_materials[materialId])
return mat->materialRenderProfile;
}
return {}; return {};
return m_materials[materialId]->materialRenderProfile;
} }
inline MaterialRenderProfileConstPtr MaterialDatabase::modRenderProfile(ModId modId) const { inline MaterialRenderProfileConstPtr MaterialDatabase::modRenderProfile(ModId modId) const {
if (modId >= m_mods.size()) if (modId < m_mods.size()) {
if (auto const& mod = m_mods[modId])
return mod->modRenderProfile;
}
return {}; return {};
return m_mods[modId]->modRenderProfile;
} }
inline bool MaterialDatabase::foregroundLightTransparent(MaterialId materialId) const { inline bool MaterialDatabase::foregroundLightTransparent(MaterialId materialId) const {

View File

@ -106,7 +106,6 @@ bool TileDrawer::produceTerrainDrawables(Drawables& drawables,
}; };
auto materialRenderProfile = materialDatabase->materialRenderProfile(material); auto materialRenderProfile = materialDatabase->materialRenderProfile(material);
auto modRenderProfile = materialDatabase->modRenderProfile(mod); auto modRenderProfile = materialDatabase->modRenderProfile(mod);
if (materialRenderProfile) { if (materialRenderProfile) {

View File

@ -277,7 +277,6 @@ bool TilePainter::produceTerrainPrimitives(HashMap<QuadZLevel, List<RenderPrimit
}; };
auto materialRenderProfile = materialDatabase->materialRenderProfile(material); auto materialRenderProfile = materialDatabase->materialRenderProfile(material);
auto modRenderProfile = materialDatabase->modRenderProfile(mod); auto modRenderProfile = materialDatabase->modRenderProfile(mod);
if (materialRenderProfile) { if (materialRenderProfile) {