From 9c2f91c11b5a9ba4b6ecf8fbc239ba65d31b380e Mon Sep 17 00:00:00 2001 From: Benau Date: Mon, 15 Jan 2018 11:07:58 +0800 Subject: [PATCH] Don't crash for wip-tracks / karts (wrong shader name or incomplete terrain) --- src/graphics/sp/sp_texture.cpp | 3 ++- src/modes/world.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/graphics/sp/sp_texture.cpp b/src/graphics/sp/sp_texture.cpp index 2ac799941..a8e73bede 100644 --- a/src/graphics/sp/sp_texture.cpp +++ b/src/graphics/sp/sp_texture.cpp @@ -522,7 +522,8 @@ std::shared_ptr { // Load colorization mask std::shared_ptr mask; - if (SP::getSPShader(m_material->getShaderName())->useAlphaChannel()) + SPShader* sps = SP::getSPShader(m_material->getShaderName()); + if (sps && sps->useAlphaChannel()) { Log::debug("SPTexture", "Don't use colorization mask or factor" " with shader using alpha channel for %s", m_path.c_str()); diff --git a/src/modes/world.cpp b/src/modes/world.cpp index db4468b6a..1781cab81 100644 --- a/src/modes/world.cpp +++ b/src/modes/world.cpp @@ -730,7 +730,8 @@ void World::resetAllKarts() for (KartList::iterator i = m_karts.begin(); i != m_karts.end(); i++) { if ((*i)->isGhostKart()) continue; - (*i)->getBody()->setGravity((*i)->getMaterial()->hasGravity() ? + (*i)->getBody()->setGravity( + (*i)->getMaterial() && (*i)->getMaterial()->hasGravity() ? (*i)->getNormal() * -g : Vec3(0, -g, 0)); } for(int i=0; i<60; i++) Physics::getInstance()->update(1.f/60.f);