Game Development Community

Potential crash in ShapeBase::prepRenderImage +fix

by Fyodor -bank- Osokin · in Torque Game Engine · 03/12/2008 (6:24 am) · 0 replies

If you look at the
bool ShapeBase::prepRenderImage
You will see that some calls are protected with checking if mShapeInstance is not null, like:
if (mShapeInstance)
         mShapeInstance->animate();
The same check needed to be performed in two more places.
Replace:
if (mCloakLevel == 0.0f && mShapeInstance->hasSolid() && mFadeVal == 1.0f)
with
if (mShapeInstance && mCloakLevel == 0.0f && mShapeInstance->hasSolid() && mFadeVal == 1.0f)

and a bit down replace:
if ((mCloakLevel != 0.0f || mFadeVal != 1.0f || mShapeInstance->hasTranslucency()) ||
          (mMount.object == NULL))
with
if (mShapeInstance && ((mCloakLevel != 0.0f || mFadeVal != 1.0f || mShapeInstance->hasTranslucency()) ||
          (mMount.object == NULL)))

After these changes the code should be more stable.