Fix some problems with the previous commit

This commit is contained in:
scrawl 2013-11-28 21:49:15 +01:00
parent 076cc9230b
commit b82ee4b44f

View file

@ -2163,27 +2163,38 @@ namespace MWWorld
btVector3 from(pos.x, pos.y, pos.z); btVector3 from(pos.x, pos.y, pos.z);
btVector3 to(newPos.x, newPos.y, newPos.z); btVector3 to(newPos.x, newPos.y, newPos.z);
std::vector<std::pair<float, std::string> > collisions = mPhysEngine->rayTest2(from, to); std::vector<std::pair<float, std::string> > collisions = mPhysEngine->rayTest2(from, to);
for (std::vector<std::pair<float, std::string> >::iterator cIt = collisions.begin(); cIt != collisions.end(); ++cIt) bool explode = false;
for (std::vector<std::pair<float, std::string> >::iterator cIt = collisions.begin(); cIt != collisions.end() && !explode; ++cIt)
{ {
MWWorld::Ptr obstacle = searchPtrViaHandle(cIt->second); MWWorld::Ptr obstacle = searchPtrViaHandle(cIt->second);
if (obstacle.isEmpty())
{
// Terrain. TODO: Explode
continue;
}
if (obstacle == ptr) if (obstacle == ptr)
continue; continue;
explode = true;
MWWorld::Ptr caster = searchPtrViaHandle(it->second.mActorHandle); MWWorld::Ptr caster = searchPtrViaHandle(it->second.mActorHandle);
if (caster.isEmpty()) if (caster.isEmpty())
caster = obstacle; caster = obstacle;
if (obstacle.isEmpty())
{
// Terrain
}
else
{
MWMechanics::CastSpell cast(caster, obstacle); MWMechanics::CastSpell cast(caster, obstacle);
cast.mStack = it->second.mStack; cast.mStack = it->second.mStack;
cast.mId = it->second.mId; cast.mId = it->second.mId;
cast.mSourceName = it->second.mSourceName; cast.mSourceName = it->second.mSourceName;
cast.inflict(obstacle, caster, it->second.mEffects, ESM::RT_Target, false); cast.inflict(obstacle, caster, it->second.mEffects, ESM::RT_Target, false);
}
deleteObject(ptr); deleteObject(ptr);
mProjectiles.erase(it++); mProjectiles.erase(it++);
}
if (explode)
{
// TODO: Explode
continue; continue;
} }