guards for NULL collisions, possible fix to fountain crash

This commit is contained in:
ZappoMan 2014-12-23 11:30:32 -08:00
parent ff784c27aa
commit 72cced12a6
2 changed files with 13 additions and 2 deletions

View file

@ -144,6 +144,13 @@ void EntityCollisionSystem::updateCollisionWithEntities(EntityItem* entityA) {
penetration = collision->_penetration;
entityB = static_cast<EntityItem*>(collision->_extraData);
// The collision _extraData should be a valid entity, but if for some reason
// it's NULL then continue with a warning.
if (!entityB) {
qDebug() << "UNEXPECTED - we have a collision with missing _extraData. Something went wrong down below!";
continue; // skip this loop pass if the entity is NULL
}
// don't collide entities with unknown IDs,
if (!entityB->isKnownID()) {
continue; // skip this loop pass if the entity has an unknown ID

View file

@ -585,8 +585,12 @@ bool EntityTreeElement::findShapeCollisions(const Shape* shape, CollisionList& c
if (shape != otherCollisionShape && !ignoreForCollisions) {
if (ShapeCollider::collideShapes(shape, otherCollisionShape, collisions)) {
CollisionInfo* lastCollision = collisions.getLastCollision();
lastCollision->_extraData = entity;
atLeastOneCollision = true;
if (lastCollision) {
lastCollision->_extraData = entity;
atLeastOneCollision = true;
} else {
qDebug() << "UNEXPECTED - ShapeCollider::collideShapes() returned true, but no lastCollision.";
}
}
}
++entityItr;