Ensure mechanics actors/objects are cleared before adding them

This commit is contained in:
Chris Robinson 2013-07-17 21:39:21 -07:00
parent c7692acb79
commit d6324d71bf
2 changed files with 4 additions and 0 deletions

View file

@ -170,6 +170,8 @@ namespace MWMechanics
// erase previous death events since we are currently only tracking them while in an active cell
MWWorld::Class::get(ptr).getCreatureStats(ptr).clearHasDied();
removeActor(ptr);
MWRender::Animation *anim = MWBase::Environment::get().getWorld()->getAnimation(ptr);
mActors.insert(std::make_pair(ptr, new CharacterController(ptr, anim)));
}

View file

@ -16,6 +16,8 @@ Objects::Objects()
void Objects::addObject(const MWWorld::Ptr& ptr)
{
removeObject(ptr);
MWRender::Animation *anim = MWBase::Environment::get().getWorld()->getAnimation(ptr);
if(anim) mObjects.insert(std::make_pair(ptr, new CharacterController(ptr, anim)));
}