Merge pull request #594 from LuisAntonRebollo/unit-tests-without-crash

Increased stability Torque3D: unit-tests running without a crash.
This commit is contained in:
Daniel Buckmaster 2014-06-16 10:57:04 +10:00
commit feec36731e
18 changed files with 113 additions and 19 deletions

View file

@ -511,6 +511,12 @@ bool Debris::onAdd()
return false;
}
if( !mDataBlock )
{
Con::errorf("Debris::onAdd - Fail - No datablock");
return false;
}
// create emitters
for( S32 i=0; i<DebrisData::DDC_NUM_EMITTERS; i++ )
{
@ -653,8 +659,11 @@ void Debris::onRemove()
}
}
getSceneManager()->removeObjectFromScene(this);
getContainer()->removeObject(this);
if( getSceneManager() )
getSceneManager()->removeObjectFromScene(this);
if( getContainer() )
getContainer()->removeObject(this);
Parent::onRemove();
}

View file

@ -784,6 +784,7 @@ bool ExplosionData::preload(bool server, String &errorStr)
//--------------------------------------
//
Explosion::Explosion()
: mDataBlock( NULL )
{
mTypeMask |= ExplosionObjectType | LightObjectType;
@ -844,6 +845,12 @@ bool Explosion::onAdd()
if ( !conn || !Parent::onAdd() )
return false;
if( !mDataBlock )
{
Con::errorf("Explosion::onAdd - Fail - No datablok");
return false;
}
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );

View file

@ -303,6 +303,7 @@ bool SplashData::preload(bool server, String &errorStr)
// Splash
//--------------------------------------------------------------------------
Splash::Splash()
: mDataBlock( NULL )
{
dMemset( mEmitterList, 0, sizeof( mEmitterList ) );
@ -353,6 +354,12 @@ bool Splash::onAdd()
if(!conn || !Parent::onAdd())
return false;
if( !mDataBlock )
{
Con::errorf("Splash::onAdd - Fail - No datablock");
return false;
}
mDelayMS = mDataBlock->delayMS + sgRandom.randI( -mDataBlock->delayVariance, mDataBlock->delayVariance );
mEndingMS = mDataBlock->lifetimeMS + sgRandom.randI( -mDataBlock->lifetimeVariance, mDataBlock->lifetimeVariance );
@ -408,8 +415,11 @@ void Splash::onRemove()
ringList.clear();
getSceneManager()->removeObjectFromScene(this);
getContainer()->removeObject(this);
if( getSceneManager() )
getSceneManager()->removeObjectFromScene(this);
if( getContainer() )
getContainer()->removeObject(this);
Parent::onRemove();
}

View file

@ -311,7 +311,8 @@ PhysicsDebris* PhysicsDebris::create( PhysicsDebrisData *datablock,
}
PhysicsDebris::PhysicsDebris()
: mLifetime( 0.0f ),
: mDataBlock( NULL ),
mLifetime( 0.0f ),
mShapeInstance( NULL ),
mWorld( NULL ),
mInitialLinVel( Point3F::Zero )
@ -342,6 +343,12 @@ bool PhysicsDebris::onAdd()
if ( !Parent::onAdd() )
return false;
if( !mDataBlock )
{
Con::errorf("PhysicsDebris::onAdd - Fail - No datablock");
return false;
}
// If it has a fixed lifetime then calculate it.
if ( mDataBlock->lifetime > 0.0f )
{

View file

@ -550,6 +550,7 @@ S32 ProjectileData::scaleValue( S32 value, bool down )
//
Projectile::Projectile()
: mPhysicsWorld( NULL ),
mDataBlock( NULL ),
mCurrPosition( 0, 0, 0 ),
mCurrVelocity( 0, 0, 1 ),
mSourceObjectId( -1 ),
@ -697,6 +698,12 @@ bool Projectile::onAdd()
if(!Parent::onAdd())
return false;
if( !mDataBlock )
{
Con::errorf("Projectile::onAdd - Fail - Not datablock");
return false;
}
if (isServerObject())
{
ShapeBase* ptr;

View file

@ -71,6 +71,12 @@ bool VehicleBlocker::onAdd()
mObjBox.minExtents.set(-mDimensions.x, -mDimensions.y, 0);
mObjBox.maxExtents.set( mDimensions.x, mDimensions.y, mDimensions.z);
if( !mObjBox.isValidBox() )
{
Con::errorf("VehicleBlocker::onAdd - Fail - No valid object box");
return false;
}
resetWorldBox();
setRenderTransform(mObjToWorld);