Skip to content

Commit

Permalink
🐛 Fixed segfault when ODEF mesh wasn't found.
Browse files Browse the repository at this point in the history
  • Loading branch information
ohlidalp authored and Petr Ohlídal committed Apr 9, 2021
1 parent 2669a74 commit 7936a6b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions source/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "Str.h"
#include "ZeroedMemoryAllocator.h" // Legacy

#include <fmt/format.h>
#include <OgreStringConverter.h>

#include <assert.h>
Expand Down
13 changes: 11 additions & 2 deletions source/main/terrain/TerrainObjectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 7936a6b

Please # to comment.