diff --git a/source/main/Application.h b/source/main/Application.h index 4a9c9f73ea..24bf6d68c6 100644 --- a/source/main/Application.h +++ b/source/main/Application.h @@ -32,6 +32,7 @@ #include "Str.h" #include "ZeroedMemoryAllocator.h" // Legacy +#include #include #include diff --git a/source/main/terrain/TerrainObjectManager.cpp b/source/main/terrain/TerrainObjectManager.cpp index 9b1eefedd5..2012594e72 100644 --- a/source/main/terrain/TerrainObjectManager.cpp +++ b/source/main/terrain/TerrainObjectManager.cpp @@ -579,8 +579,17 @@ void TerrainObjectManager::LoadTerrainObject(const Ogre::String& name, const Ogr { Str<100> ebuf; ebuf << m_entity_counter++ << "-" << odef->header.mesh_name; mo = new MeshObject(odef->header.mesh_name, m_resource_group, ebuf.ToCStr(), tenode); - mo->getEntity()->setCastShadows(odef->header.cast_shadows); - m_mesh_objects.push_back(mo); + if (mo->getEntity()) + { + mo->getEntity()->setCastShadows(odef->header.cast_shadows); + m_mesh_objects.push_back(mo); + } + else + { + delete mo; + App::GetConsole()->putMessage(Console::CONSOLE_MSGTYPE_TERRN, Console::CONSOLE_SYSTEM_WARNING, + fmt::format("ODEF: Could not load mesh {}", odef->header.mesh_name)); + } } tenode->setScale(odef->header.scale);