Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2024-06-02 14:02:16 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2024-06-02 14:02:16 +1000
commit986db9cfc5a1c9015503b5366c65a377f8c8a259 (patch)
treebaab42f3bfd58aac48c625a4067992a789e5c1ae
parent41bad6c97c60918af640e8d4c558316edd1bd9c7 (diff)
further MaterialDatabase checks
-rw-r--r--source/game/StarMaterialDatabase.hpp18
-rw-r--r--source/game/StarTileDrawer.cpp1
-rw-r--r--source/rendering/StarTilePainter.cpp1
3 files changed, 12 insertions, 8 deletions
diff --git a/source/game/StarMaterialDatabase.hpp b/source/game/StarMaterialDatabase.hpp
index b890e30..f20a3e2 100644
--- a/source/game/StarMaterialDatabase.hpp
+++ b/source/game/StarMaterialDatabase.hpp
@@ -188,15 +188,21 @@ private:
};
inline MaterialRenderProfileConstPtr MaterialDatabase::materialRenderProfile(MaterialId materialId) const {
- if (materialId >= m_materials.size())
- return {};
- return m_materials[materialId]->materialRenderProfile;
+ if (materialId < m_materials.size()) {
+ if (auto const& mat = m_materials[materialId])
+ return mat->materialRenderProfile;
+ }
+
+ return {};
}
inline MaterialRenderProfileConstPtr MaterialDatabase::modRenderProfile(ModId modId) const {
- if (modId >= m_mods.size())
- return {};
- return m_mods[modId]->modRenderProfile;
+ if (modId < m_mods.size()) {
+ if (auto const& mod = m_mods[modId])
+ return mod->modRenderProfile;
+ }
+
+ return {};
}
inline bool MaterialDatabase::foregroundLightTransparent(MaterialId materialId) const {
diff --git a/source/game/StarTileDrawer.cpp b/source/game/StarTileDrawer.cpp
index 3ac8e48..70cd7d0 100644
--- a/source/game/StarTileDrawer.cpp
+++ b/source/game/StarTileDrawer.cpp
@@ -106,7 +106,6 @@ bool TileDrawer::produceTerrainDrawables(Drawables& drawables,
};
auto materialRenderProfile = materialDatabase->materialRenderProfile(material);
-
auto modRenderProfile = materialDatabase->modRenderProfile(mod);
if (materialRenderProfile) {
diff --git a/source/rendering/StarTilePainter.cpp b/source/rendering/StarTilePainter.cpp
index 58d9d28..f9cff34 100644
--- a/source/rendering/StarTilePainter.cpp
+++ b/source/rendering/StarTilePainter.cpp
@@ -277,7 +277,6 @@ bool TilePainter::produceTerrainPrimitives(HashMap<QuadZLevel, List<RenderPrimit
};
auto materialRenderProfile = materialDatabase->materialRenderProfile(material);
-
auto modRenderProfile = materialDatabase->modRenderProfile(mod);
if (materialRenderProfile) {