Fix crashes if broken mesh is loaded (found in google play)

This commit is contained in:
Benau 2020-04-28 09:27:25 +08:00
parent 720ed698ce
commit e7e702ad39
2 changed files with 9 additions and 1 deletions

View File

@ -68,6 +68,11 @@ scene::IAnimatedMesh* B3DMeshLoader::createMesh(io::IReadFile* f)
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
if (CVS->isGLSL()) if (CVS->isGLSL())
{ {
if (!AnimatedMesh)
{
m_texture_string.clear();
return 0;
}
SP::SPMesh* spm = toSPM(static_cast<scene::CSkinnedMesh*> SP::SPMesh* spm = toSPM(static_cast<scene::CSkinnedMesh*>
(AnimatedMesh->getMesh(m_straight_frame))); (AnimatedMesh->getMesh(m_straight_frame)));
m_texture_string.clear(); m_texture_string.clear();

View File

@ -683,7 +683,10 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
{ {
HeadlightObject& obj = m_headlight_objects[i]; HeadlightObject& obj = m_headlight_objects[i];
std::string full_name = kart_properties.getKartDir() + obj.getFilename(); std::string full_name = kart_properties.getKartDir() + obj.getFilename();
obj.setModel(irr_driver->getMesh(full_name)); scene::IMesh* mesh = irr_driver->getMesh(full_name);
if (!mesh)
continue;
obj.setModel(mesh);
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
SP::uploadSPM(obj.getModel()); SP::uploadSPM(obj.getModel());
#endif #endif